2026.06.05 frontend javítgatás és új belépési logika megvalósítva
This commit is contained in:
@@ -12,9 +12,31 @@ const messages = {
|
||||
en,
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the initial locale:
|
||||
* 1. If a saved locale exists in localStorage, use it.
|
||||
* 2. Otherwise, detect the browser language (navigator.language).
|
||||
* If it starts with 'hu', use 'hu'. For everything else, use 'en'.
|
||||
*/
|
||||
function detectLocale(): string {
|
||||
const saved = localStorage.getItem('user-locale')
|
||||
if (saved) return saved
|
||||
|
||||
if (typeof navigator !== 'undefined' && navigator.language) {
|
||||
const browserLang = navigator.language.toLowerCase()
|
||||
if (browserLang === 'hu' || browserLang.startsWith('hu-')) {
|
||||
return 'hu'
|
||||
}
|
||||
}
|
||||
|
||||
return 'en'
|
||||
}
|
||||
|
||||
const initialLocale = detectLocale()
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'hu',
|
||||
locale: initialLocale,
|
||||
fallbackLocale: 'en',
|
||||
messages,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user