let lang = 'DE' let i18nMap = {} let defaultLang = navigator.language ? navigator.language.substr(0, 2) : 'en' export default (context, inject) => { const translate = (key) => { const t = i18nMap[key] if (!t) { return key } return t[lang] || t[defaultLang] || key } inject('t', translate) inject('i18n', { setLang: (_lang) => { lang = _lang }, map: (_map) => { i18nMap = { ...i18nMap, ..._map, } }, }) }