mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 19:18:13 -03:30
Compare commits
1 Commits
22.2.0
...
revert-136
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc8006757a |
@@ -28,7 +28,7 @@ import { getLanguageWithoutRegionCode } from 'util/language';
|
|||||||
import Metrics from 'screens/Metrics';
|
import Metrics from 'screens/Metrics';
|
||||||
import SubscriptionEdit from 'screens/Setting/Subscription/SubscriptionEdit';
|
import SubscriptionEdit from 'screens/Setting/Subscription/SubscriptionEdit';
|
||||||
import useTitle from 'hooks/useTitle';
|
import useTitle from 'hooks/useTitle';
|
||||||
import { dynamicActivate } from './i18nLoader';
|
import { dynamicActivate, locales } from './i18nLoader';
|
||||||
import getRouteConfig from './routeConfig';
|
import getRouteConfig from './routeConfig';
|
||||||
import { SESSION_REDIRECT_URL } from './constants';
|
import { SESSION_REDIRECT_URL } from './constants';
|
||||||
|
|
||||||
@@ -139,15 +139,16 @@ export function ProtectedRoute({ children, ...rest }) {
|
|||||||
function App() {
|
function App() {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { hash, search, pathname } = useLocation();
|
const { hash, search, pathname } = useLocation();
|
||||||
const searchParams = Object.fromEntries(new URLSearchParams(search));
|
let language = getLanguageWithoutRegionCode(navigator);
|
||||||
const pseudolocalization =
|
if (!Object.keys(locales).includes(language)) {
|
||||||
searchParams.pseudolocalization === 'true' || false;
|
// If there isn't a string catalog available for the browser's
|
||||||
const language =
|
// preferred language, default to one that has strings.
|
||||||
searchParams.lang || getLanguageWithoutRegionCode(navigator) || 'en';
|
language = 'en';
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dynamicActivate(language, pseudolocalization);
|
dynamicActivate(language);
|
||||||
}, [language, pseudolocalization]);
|
}, [language]);
|
||||||
|
|
||||||
useTitle();
|
useTitle();
|
||||||
|
|
||||||
|
|||||||
@@ -27,21 +27,8 @@ i18n.loadLocaleData({
|
|||||||
* We do a dynamic import of just the catalog that we need
|
* We do a dynamic import of just the catalog that we need
|
||||||
* @param locale any locale string
|
* @param locale any locale string
|
||||||
*/
|
*/
|
||||||
export async function dynamicActivate(locale, pseudolocalization = false) {
|
export async function dynamicActivate(locale) {
|
||||||
const { messages } = await import(`./locales/${locale}/messages`);
|
const { messages } = await import(`./locales/${locale}/messages`);
|
||||||
|
|
||||||
if (pseudolocalization) {
|
|
||||||
Object.keys(messages).forEach((key) => {
|
|
||||||
if (Array.isArray(messages[key])) {
|
|
||||||
// t`Foo ${param}` -> ["Foo ", ['param']] => [">>", "Foo ", ['param'], "<<"]
|
|
||||||
messages[key] = ['»', ...messages[key], '«'];
|
|
||||||
} else {
|
|
||||||
// simple string
|
|
||||||
messages[key] = `»${messages[key]}«`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
i18n.load(locale, messages);
|
i18n.load(locale, messages);
|
||||||
i18n.activate(locale);
|
i18n.activate(locale);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user