Skip to content

Commit

Permalink
Merge pull request #1 from jsgriffin/master
Browse files Browse the repository at this point in the history
Fix a bug with replacing falsey values
  • Loading branch information
dbrekalo committed Nov 6, 2018
2 parents 025755e + f9e8f59 commit 91b729d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/translate.js
Expand Up @@ -33,7 +33,7 @@
return translate.whenUndefined(key, locale);
} else {
return templateData ? translation.replace(interpolateRE, function(match, param) {
return templateData[param] || match;
return templateData.hasOwnProperty(param) ? templateData[param] : match;
}) : translation;
}

Expand Down
1 change: 1 addition & 0 deletions test/index.js
Expand Up @@ -97,6 +97,7 @@ describe('translate', function() {
assert.equal(translate('welcomeMessage', {userName: 'George'}), 'Hello George');
assert.equal(translate('welcomeMessage', {}), 'Hello {{userName}}');
assert.equal(translate('taskCounterMessage', {taskCounter: 4, userName: 'George'}), '4 tasks left George');
assert.equal(translate('taskCounterMessage', {taskCounter: 0, userName: 'George'}), '0 tasks left George');

});

Expand Down

0 comments on commit 91b729d

Please sign in to comment.