Last active
April 21, 2020 14:26
-
-
Save madhurikulkarni/e0027f805ab4cd30a95bf1c5a6211d07 to your computer and use it in GitHub Desktop.
Multilanguage with a language-switcher in NativeScript Vue using vue-i18n
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
<Label @tap="$i18n.locale == 'de'" /> | |
<Label text="EN" @tap="$i18n.locale == 'en'" /> | |
Usage | |
<Label :text="$t('msg')" /> |
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 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; |
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 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