Select the primary language according to routing
This commit is contained in:
parent
18aef1c8eb
commit
8e734aa347
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/* CONFIG */
|
/* CONFIG */
|
||||||
|
|
||||||
const locales = ["en", "fr", "ja", "es", "pt-br"];
|
const locales = ["en", "es", "fr", "pt-br", "ja"];
|
||||||
|
|
||||||
/* END CONFIG */
|
/* END CONFIG */
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,23 @@ export default function AppLayout(props: Props): JSX.Element {
|
||||||
});
|
});
|
||||||
const [currencySelect, setCurrencySelect] = useState<number>(-1);
|
const [currencySelect, setCurrencySelect] = useState<number>(-1);
|
||||||
|
|
||||||
|
let defaultPreferredLanguages: string[] = [];
|
||||||
|
|
||||||
|
if (router.locale && router.locales) {
|
||||||
|
if (router.locale === "en") {
|
||||||
|
defaultPreferredLanguages = [router.locale];
|
||||||
|
router.locales.map((locale) => {
|
||||||
|
if (locale !== router.locale) defaultPreferredLanguages.push(locale);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
defaultPreferredLanguages = [router.locale, "en"];
|
||||||
|
router.locales.map((locale) => {
|
||||||
|
if (locale !== router.locale && locale !== "en")
|
||||||
|
defaultPreferredLanguages.push(locale);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (appLayout.currency)
|
if (appLayout.currency)
|
||||||
setCurrencySelect(currencyOptions.indexOf(appLayout.currency));
|
setCurrencySelect(currencyOptions.indexOf(appLayout.currency));
|
||||||
|
@ -272,7 +289,7 @@ export default function AppLayout(props: Props): JSX.Element {
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
: new Map(
|
: new Map(
|
||||||
router.locales.map((locale) => [
|
defaultPreferredLanguages.map((locale) => [
|
||||||
locale,
|
locale,
|
||||||
prettyLanguage(locale, languages),
|
prettyLanguage(locale, languages),
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue