Skip to content

Commit

Permalink
[build] 2.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
kemar committed Jul 25, 2017
1 parent 4004bda commit e1e43a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions dist/vue-gettext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* vue-gettext v2.0.19
* vue-gettext v2.0.20
* (c) 2017 Polyconseil
* @license MIT
*/
Expand Down Expand Up @@ -381,6 +381,10 @@ var Component = {
type: String,
required: false,
},
translateParams: {
type: Object,
required: false,
},
// `translateComment` is used exclusively by `easygettext`'s `gettext-extract`.
translateComment: {
type: String,
Expand All @@ -397,7 +401,14 @@ var Component = {
this.isPlural ? this.translatePlural : null,
this.$language.current
);
return this.$gettextInterpolate(translation, this.$parent)

var context = this.$parent;

if (this.translateParams) {
context = Object.assign({}, this.$parent, this.translateParams);
}

return this.$gettextInterpolate(translation, context)
},
},

Expand Down Expand Up @@ -503,11 +514,20 @@ var updateTranslation = function (el, binding, vnode) {
var translateN = attrs['translate-n'];
var translatePlural = attrs['translate-plural'];
var isPlural = translateN !== undefined && translatePlural !== undefined;
var context = vnode.context;

if (!isPlural && (translateN || translatePlural)) {
throw new Error('`translate-n` and `translate-plural` attributes must be used together:' + msgid + '.')
}

if (!_Vue.config.getTextPluginSilent && attrs['translate-params']) {
console.warn(("`translate-params` is required as an expression for v-translate directive. Please change to `v-translate='params'`: " + msgid));
}

if (binding.value && typeof binding.value === 'object') {
context = Object.assign({}, vnode.context, binding.value);
}

var translation = translate.getTranslation(
msgid,
translateN,
Expand All @@ -516,7 +536,7 @@ var updateTranslation = function (el, binding, vnode) {
el.dataset.currentLanguage
);

var msg = interpolate(translation, vnode.context);
var msg = interpolate(translation, context);

el.innerHTML = msg;

Expand Down
4 changes: 2 additions & 2 deletions dist/vue-gettext.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1e43a2

Please sign in to comment.