vuex-i18n-remote
This is a small package that can be used to load translations from a remote server.
This is best used with grouped short key based translations (ei. home.welcome
-> 'This is a welcome message.'),
so that you can load groups of translations at a time.
Requirements
Usage
;;;; // file from vuex-i18n-remote plugin // ...setup Axios default config // use VuexVue; // setup storeconst store = // ...config options; // setup vuex-i18n-remoteVue; const app = el: '#app' store;
Once the library is installed, vuex-i18n will also be installed.
Options
Key | Description | Default |
---|---|---|
url | This is the URL where the translations will be fetched from. | translations |
store | This is the Vuex store to be used to store the translations. | new Vuex.Store({}) |
storeModuleName | This is the store module name used to store the translations | i18n |
axios | The Axios instance used for the http requests | Axios |
commonKeys | This is an array of common keys that should be loaded by default if no option is specified by the method. | [] |
onTranslationNotFound | Callback used if translation is not found | function (locale, key) {} |
Methods
Once loaded the plugin will add the following methods to Vue.
Global
Options
Key | Description | Default |
---|---|---|
key | The key to get from the server | commonKeys set above |
locale | The locale to be used | locale from Vue.i18n.locale() |
Usage
Vuei18nRemote;
Instance
Options
Key | Description | Default |
---|---|---|
key | The key to get from the server | commonKeys set above |
locale | The locale to be used | locale from Vue.i18n.locale() |
Usage
this$i18nRemote;