-
-
Save cornelia-schulz/8027717cd0a5e26df6d3bc0c8ddd57f6 to your computer and use it in GitHub Desktop.
Setting up i18next for Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"message": "hallo", | |
"tryitfree": "Probiere es kostenlos", | |
"readytobuild": "Bist du bereit, deine Community aufzubauen?" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"message": "hello", | |
"tryitfree": "Try it free", | |
"readytobuild": "Ready to build your community?" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button class="try"> | |
{{ $t("tryitfree") }} | |
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import i18next from 'i18next' | |
import VueI18Next from '@panter/vue-i18next' | |
import App from './App.vue' | |
import en from './locales/en.json' | |
import de from './locales/de.json' | |
const locales = { | |
en: en, | |
de: de | |
} | |
Vue.use(VueI18Next) | |
i18next.init({ | |
lng: 'en', | |
fallbackLng: 'en', | |
resources: { | |
en: { translation: locales.en }, | |
de: { translation: locales.de } | |
} | |
}) | |
const i18n = new VueI18Next(i18next) | |
if (document.getElementById('app')) { | |
/* eslint-disable-next-line no-new */ | |
new Vue({ | |
el: '#app', | |
i18n: i18n, | |
render: h => h(App) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment