Fix locale-related bugs and test it with screenshots
This commit is contained in:
parent
23529dbd4b
commit
924be8fc2e
6 changed files with 102 additions and 25 deletions
|
@ -8,11 +8,23 @@ register('nl', () => import('../locales/nl.json'));
|
|||
register('es', () => import('../locales/es.json'));
|
||||
register('de', () => import('../locales/de.json'));
|
||||
|
||||
const getInitialLocale = () => {
|
||||
if (!browser) return defaultLocale;
|
||||
|
||||
// Check localStorage first
|
||||
const storedLocale = localStorage.getItem('locale');
|
||||
if (storedLocale) return storedLocale;
|
||||
|
||||
// Get browser locale and normalize it
|
||||
const browserLocale = window.navigator.language;
|
||||
const normalizedLocale = browserLocale.split('-')[0].toLowerCase();
|
||||
|
||||
// Check if we support this locale
|
||||
const supportedLocales = ['en', 'nl', 'es', 'de'];
|
||||
return supportedLocales.includes(normalizedLocale) ? normalizedLocale : defaultLocale;
|
||||
};
|
||||
|
||||
init({
|
||||
fallbackLocale: defaultLocale,
|
||||
initialLocale: browser
|
||||
? browser && localStorage.getItem('locale')
|
||||
? localStorage.getItem('locale')
|
||||
: window.navigator.language.slice(0, 2)
|
||||
: defaultLocale
|
||||
initialLocale: getInitialLocale()
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue