|
|
@@ -6,6 +6,16 @@ import en from './locales/en.json';
|
|
|
import hu from './locales/hu.json';
|
|
|
import de from './locales/de.json';
|
|
|
|
|
|
+// Detect browser language on first visit
|
|
|
+const storedLanguage = localStorage.getItem('i18nextLng');
|
|
|
+if (!storedLanguage) {
|
|
|
+ const browserLang = navigator.language.split('-')[0]; // Get 'hu' from 'hu-HU'
|
|
|
+ const supportedLanguages = ['en', 'hu', 'de'];
|
|
|
+ if (supportedLanguages.includes(browserLang)) {
|
|
|
+ localStorage.setItem('i18nextLng', browserLang);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
i18n
|
|
|
.use(LanguageDetector) // Detects user language
|
|
|
.use(initReactI18next) // Passes i18n down to react-i18next
|
|
|
@@ -23,9 +33,10 @@ i18n
|
|
|
},
|
|
|
|
|
|
detection: {
|
|
|
- order: ['localStorage', 'navigator', 'htmlTag'],
|
|
|
+ order: ['querystring', 'localStorage', 'navigator', 'htmlTag'],
|
|
|
caches: ['localStorage'],
|
|
|
- lookupLocalStorage: 'i18nextLng'
|
|
|
+ lookupLocalStorage: 'i18nextLng',
|
|
|
+ lookupQuerystring: 'lng'
|
|
|
}
|
|
|
});
|
|
|
|