How to create internationalization page using vueI18n #419
Unanswered
PatrykMaternicki
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi I am working(testing) a new tools to create ssg. And one of point for requirements is enable to create internalization page. My configuration it looks like this:
const i18n = createI18n({ legacy: false, locale: navigator.getDefaultLang(), fallbackLocale: 'en', messages, }) as I18n
`const ENABLES_LANGUAGES = ['pl', 'en']
export const useNavigator = () => {
const isAvaibleLangRegex = new RegExp(ENABLES_LANGUAGES.join('|'))
const getDefaultLang = () => {
let savedLang: string | null
let browserLang: string
}
const isAllowedLanguage = (lang: string) => {
return isAvaibleLangRegex.test(lang.toLowerCase()) ? lang : getDefaultLang()
}
return {
getDefaultLang,
isAllowedLanguage,
}
}`
Because localStorage, navigator it always undefined (make sense, because build is generate by node.js) . I don't know how to set default Language equal polish language when route is /pl/something and english language when route is /en/something
Beta Was this translation helpful? Give feedback.
All reactions