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