Skip to content

Commit

Permalink
build new version
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed Oct 19, 2018
1 parent 9743e7a commit 3e2d066
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
### 11.10.0

- Allow missingInterpolationHandler to be provided as t() option [1118](https://github.com/i18next/i18next/pull/1118)

### 11.9.1

- fixes allow overriding of fallbackLng when in options passed to t functions call
Expand Down
10 changes: 6 additions & 4 deletions i18next.js
Expand Up @@ -770,7 +770,7 @@ var Translator = function (_EventEmitter) {
// interpolate
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
if (this.options.interpolation.defaultVariables) data = _extends({}, this.options.interpolation.defaultVariables, data);
res = this.interpolator.interpolate(res, data, options.lng || this.language);
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);

// nesting
if (options.nest !== false) res = this.interpolator.nest(res, function () {
Expand Down Expand Up @@ -1228,7 +1228,7 @@ var Interpolator = function () {
this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
};

Interpolator.prototype.interpolate = function interpolate(str, data, lng) {
Interpolator.prototype.interpolate = function interpolate(str, data, lng, options) {
var _this = this;

var match = void 0;
Expand All @@ -1251,6 +1251,8 @@ var Interpolator = function () {

this.resetRegExp();

var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;

replaces = 0;
// unescape if has unescapePrefix/Suffix
/* eslint no-cond-assign: 0 */
Expand All @@ -1269,8 +1271,8 @@ var Interpolator = function () {
while (match = this.regexp.exec(str)) {
value = handleFormat(match[1].trim());
if (value === undefined) {
if (typeof this.options.missingInterpolationHandler === 'function') {
var temp = this.options.missingInterpolationHandler(str, match);
if (typeof missingInterpolationHandler === 'function') {
var temp = missingInterpolationHandler(str, match);
value = typeof temp === 'string' ? temp : '';
} else {
this.logger.warn('missed to pass in variable ' + match[1] + ' for interpolating ' + str);
Expand Down
2 changes: 1 addition & 1 deletion i18next.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "i18next",
"version": "11.9.1",
"version": "11.10.0",
"description": "i18next internationalization framework",
"main": "./index.js",
"jsnext:main": "dist/es/index.js",
Expand Down

0 comments on commit 3e2d066

Please sign in to comment.