A VueJS (1.x, 2.0+) plugin for basic translations.
What is this?
Is a plugin to handle basic translations for your components, it adds a mixin and a directive to handle it the most comfortable way.
Yes and no, Vue-i18n is a great plugin and is a lot more complete than this. This handle translations too, but is a more basic idea and smaller file (is just one file!).
What to expect?
Just translations, it is that simple.
;;Vue;var myComp = Vue;var vm =el: '#app'components: myComptemplate: `<div><my-comp></my-comp></div>`;
You can do this in three different ways:
localesoption in your component:
- Inside a component's method:
- Globally when loading the plugin:
Changing the language to use
setLang method of the
$translate property, like this:
You can listen to custom events emitted by the
You can use the method
textWithParams if you would like to insert parameters in your translation strings.
this$translate// In locales.js'translation.string': 'My name is %keyA%. My brother is named %keyB%.'// Result'My name is Glenn. My brother is named John.'
When the first language is set.
When the language to use was changed from the previous value.
Everytime a language is changed, either is the first time or not.
When locales are loaded either by any of the 3 options