Skip to content

Instantly share code, notes, and snippets.

@madhurikulkarni
Last active April 21, 2020 14:26
Show Gist options
  • Save madhurikulkarni/e0027f805ab4cd30a95bf1c5a6211d07 to your computer and use it in GitHub Desktop.
Save madhurikulkarni/e0027f805ab4cd30a95bf1c5a6211d07 to your computer and use it in GitHub Desktop.
Multilanguage with a language-switcher in NativeScript Vue using vue-i18n
<Label @tap="$i18n.locale == 'de'" />
<Label text="EN" @tap="$i18n.locale == 'en'" />
Usage
<Label :text="$t('msg')" />
import Vue from 'vue';
import VueI18n from 'vue-i18n';
Vue.use(VueI18n);
const messages = {
'en': {
msg: "Hello World"
},
'de': {
msg: "Hallo Welt"
}
};
const i18n = new VueI18n({
locale: 'de', // set locale
fallbackLocale: 'de', // set fallback locale
messages
});
export default i18n;
import i18n from './plugins/i18n';
new Vue({
i18n,
render: h => h("frame", [h(App)])
}).$start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment