feat:#60 format, lint and fix build

This commit is contained in:
masterElmar
2023-11-16 23:45:45 +01:00
parent 9f937afe94
commit e9db7cb4b0
24 changed files with 307 additions and 271 deletions

View File

@@ -1,14 +1,14 @@
import { createI18n } from "vue-i18n";
import en from './translations/en.json'
import de from './translations/de.json'
import en from "./translations/en.json";
import de from "./translations/de.json";
import localeStore from "../store/localeStore.ts";
export const supportedLocales= {
'en': { name: 'English'},
'de': { name: 'Deutsch'},
}
export const supportedLocales = {
en: { name: "English" },
de: { name: "Deutsch" },
};
// Private instance of VueI18n object
let _i18n: any
let _i18n: any;
// Initializer
function setup() {
_i18n = createI18n({
@@ -17,30 +17,30 @@ function setup() {
fallbackLocale: "en",
messages: {
en,
de
de,
},
})
return _i18n
});
return _i18n;
}
// Sets the active locale.
function setLocale(newLocale : any) {
_i18n.global.locale = newLocale
setDocumentAttributesFor(newLocale)
function setLocale(newLocale: any) {
_i18n.global.locale = newLocale;
setDocumentAttributesFor(newLocale);
}
function setDocumentAttributesFor(locale: any) {
const htmlElement = document.querySelector('html')
const htmlElement = document.querySelector("html");
htmlElement?.setAttribute('lang', locale)
htmlElement?.setAttribute("lang", locale);
}
// Public interface
export default {
// Expose the VueI18n instance via a getter
get vueI18n() {
return _i18n
return _i18n;
},
setup,
setLocale,
}
};