try to use the browser's default language as out default language

This commit is contained in:
wea_ondara
2023-09-26 17:51:44 +02:00
parent 6cf5a7d84c
commit c246a06f7a

View File

@@ -14,8 +14,15 @@ const datetimeFormats = {
}; };
export function createI18n(): I18n { export function createI18n(): I18n {
let browserLocale = (navigator.language ?? '').toLowerCase();
const match = browserLocale.match(/^([a-z][a-z])/);
if (match) {
browserLocale = match[1];
} else {
browserLocale = 'en';
}
return vueCreateI18n({ return vueCreateI18n({
locale: 'de', locale: browserLocale,
fallbackLocale: 'en', fallbackLocale: 'en',
messages: messages, messages: messages,
datetimeFormats: datetimeFormats, datetimeFormats: datetimeFormats,