Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed issue with null value as value

  • Loading branch information...
commit 02ef2267d055c53dc867cf4fa05c023d2a54c8bc 1 parent b6bbeef
@jamuhl jamuhl authored
View
2  spec/translate.spec.js
@@ -1,5 +1,7 @@
describe('translation functionality', function() {
+ //= translate/translate.nullValue.spec.js
+
//= translate/translate.emptyValue.spec.js
//= translate/translate.arrayValue.spec.js
View
2  src/i18next.translate.js
@@ -147,7 +147,7 @@ function _translate(key, options){
value = value.join('\n');
value = applyReplacement(value, options);
value = applyReuse(value, options);
- } else {
+ } else if (value !== null) {
if (!o.returnObjectTrees && !options.returnObjectTrees) {
value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' +
'returned a object instead of string.';
View
18 test/test.js
@@ -704,6 +704,24 @@ describe('i18next', function() {
});
describe('translation functionality', function() {
+ describe('resource string is null', function() {
+ var resStore = {
+ dev: { translation: { key1: null, key2: { key3: null } } },
+ en: { translation: { } },
+ 'en-US': { translation: { } }
+ };
+
+ beforeEach(function(done) {
+ i18n.init( $.extend(opts, { resStore: resStore, returnObjectTrees: true }),
+ function(t) { done(); });
+ });
+
+ it('it should translate value', function() {
+ expect(i18n.t('key1')).to.be(null);
+ expect(i18n.t('key2')).to.eql({ key3: null });
+ });
+ });
+
describe('key with empty string value as valid option', function() {
var resStore = {
dev: { translation: { empty: '' } },
Please sign in to comment.
Something went wrong with that request. Please try again.