Skip to content
Snippets Groups Projects

Resolve "Language select uses English as default language (and not browser language)"

Files
6
@@ -33,17 +33,33 @@ export default {
type: Array,
required: true,
},
defaultLanguage: {
type: Object,
required: true,
},
},
methods: {
setLanguage: function (languageOption) {
document.cookie = languageOption.cookie;
this.$i18n.locale = languageOption.code;
this.$vuetify.lang.current = languageOption.code;
this.language = languageOption;
},
nameForMenu: function (item) {
return `${item.nameLocal} (${item.code})`;
},
},
mounted() {
if (
this.availableLanguages.filter((lang) => lang.code === this.$i18n.locale)
.length === 0
) {
console.warn(
`Unsupported language ${this.$i18n.locale} selected, defaulting to ${this.defaultLanguage.code}`
);
this.setLanguage(this.defaultLanguage);
}
},
name: "LanguageForm",
};
</script>
Loading