Localization plugin for vue.js 2.0 using vuex as store
Hot fix for version 1.12.0
This release adds very basic typescript information to the plugin. A new version is in the works, which will be written completely in typescript.
This release adds a new filter translateIn to translate a message in a specific language:
{{ 'message' | translateIn('en') }}
Thanks to @zhangqiangoffice for the corresponding pull request #91 which was adapted for this.
This release fixes an issue with the previous build. Due to babel directory constraints, the previous build would not transpile the code correctly.
See #104 for details.
This release restores the compatibility with variable substitutions that are comprised of a single character i.e. $t('this is some {0} information', {'0': 'important'})
.
Should fix #104 and also address #102.
This release contains a restructured directory with better specification of the build directory, an initial documentation in vuepress, an example for a todo mvc and the slides of a recent talk regarding vue-i18n and vuex-i18n at a vue-meetup in Switzerland.
Improvements:
As per request #66 we added a method to fetch all current locales. An example is given in the test repository.
Please keep in mind that this is a method that will be invoked on every render cycle. To make use of vue's caching system I would recommend to create a getter method or computed property like this.
locales() {
return Object.keys(this.$store.state.i18n.translations);
}
This is a hotfix for version 1.10.
Module initialization was change in 1.10.0 to include the option preserveState. This would not correctly initialize the module as intended for the plugin.
Version 1.10.4 fixes this and allows you to specify preserveState via configuration parameter if actually necessary for server side rendering.
Thanks to the pull request #41 from @galchenkov it is now possible to specifies pluralizations via arrays instead of using ::: as delimiter.
$i18n.add('en', {'comments': [
'{count} comment',
'{count} comments',
]});
$i18n.add('ru', {'comments': [
'{count} комментарий',
'{count} комментария',
'{count} комментариев',
]});
$i18n.set('en');
$t('comments', {count: 5}, 5); // 5 comments
$i18n.set('ru');
$t('comments', {count: 5}, 5); // 5 комментариев
As indicated in the title