mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-25 07:49:37 +02:00
Fix locale fallback logic: ensure valid fallback locale from navigator language or default to 'en'
This commit is contained in:
parent
958e9de84e
commit
7a3ec33fa7
1 changed files with 5 additions and 1 deletions
|
@ -14,9 +14,13 @@
|
|||
register('nl', () => import('../locales/nl.json'));
|
||||
register('sv', () => import('../locales/sv.json'));
|
||||
|
||||
let locales = ['en', 'es', 'fr', 'de', 'it', 'zh', 'nl', 'sv'];
|
||||
|
||||
if (browser) {
|
||||
init({
|
||||
fallbackLocale: navigator.language.split('-')[0],
|
||||
fallbackLocale: locales.includes(navigator.language.split('-')[0])
|
||||
? navigator.language.split('-')[0]
|
||||
: 'en',
|
||||
initialLocale: data.locale
|
||||
});
|
||||
// get the locale cookie if it exists and set it as the initial locale if it exists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue