Skip to content

Commit

Permalink
test is added
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Apr 20, 2016
1 parent c29a445 commit 6fc9aa6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
55 changes: 25 additions & 30 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@
"other": "%s cats"
},
"cats": {
"n": {
"one": "%s cat",
"other": "%s cats"
}
},
"n": {
"one": "%s cat",
"other": "%s cats"
}
},
"nested": {
"deep": {
"plural": {
"one": "plural",
"other": "plurals"
}
},
"path": {
"sub": "nested.path.sub"
}
},
"There is one monkey in the %%s": {
Expand All @@ -40,32 +43,24 @@
"one": "There is one monkey in the tree",
"other": "There are %d monkeys in the tree"
},

"plurals with intervals in string (no object)":"[0] a zero rule|[2,5] two to five (included)|and a catchall rule",

"plurals with intervals in _other_ missing _one_":{
"plurals with intervals in string (no object)": "[0] a zero rule|[2,5] two to five (included)|and a catchall rule",
"plurals with intervals in _other_ missing _one_": {
"other": "[0] a zero rule|[2,5] two to five (included)|and a catchall rule"
},

"plurals with intervals as string":{
"plurals with intervals as string": {
"one": "The default 'one' rule",
"other": "[0] a zero rule|[2,5] two to five (included)|and a catchall rule"
},

"plurals with intervals as string (excluded)":{
"plurals with intervals as string (excluded)": {
"one": "The default 'one' rule",
"other": "[0] a zero rule|]2,5[ two to five (excluded)|and a catchall rule"
},

"plurals in any order":{
"plurals in any order": {
"one": "The default 'one' rule",
"other": "[0] a zero rule|and a catchall rule|[2,5] two to five (included)"
},

"plurals to eternity":"[0,] this will last forever|but only gt 0",

"plurals from eternity":"[,0] this was born long before|but only lt 0",

"plurals to eternity": "[0,] this will last forever|but only gt 0",
"plurals from eternity": "[,0] this was born long before|but only lt 0",
"Hello %s": "Hello %s",
"Hello {{name}}": "Hello {{name}}",
"Hello {{name}}, how was your %s?": "Hello {{name}}, how was your %s?",
Expand All @@ -87,24 +82,24 @@
}
},
"another": {
"nested":{
"extra":{
"deep":{
"example":{
"nested": {
"extra": {
"deep": {
"example": {
"one": "The default 'one' rule",
"other": "[0] a zero rule|[2,5] two to five (included)|and a catchall rule"
}
},
"lazy":{
"example":{
"lazy": {
"example": {
"other": "[0] a zero rule|[2,5] two to five (included)|and a catchall rule"
}
},
"mustache":{
"example":"[0] a zero rule for {{me}}|[2,5] two to five (included) for {{me}}|and a catchall rule for {{me}}"
"mustache": {
"example": "[0] a zero rule for {{me}}|[2,5] two to five (included) for {{me}}|and a catchall rule for {{me}}"
},
"mustacheprintf":{
"example":"[0] %s is zero rule for {{me}}|[2,5] %s is between two and five (included) for {{me}}|and a catchall rule for {{me}} to get my number %s"
"mustacheprintf": {
"example": "[0] %s is zero rule for {{me}}|[2,5] %s is between two and five (included) for {{me}}|and a catchall rule for {{me}} to get my number %s"
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions test/i18n.objectnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ describe('Object Notation', function() {
});

describe('i18nTranslate', function() {

beforeEach(function() {
var catalog = i18n.getCatalog('en');
delete catalog.nested.path;
});

it('should return en translations as expected, using object traversal notation', function() {
i18n.setLocale('en');
should.equal(__('greeting.formal'), 'Hello');
Expand All @@ -51,5 +57,13 @@ describe('Object Notation', function() {
should.equal(singular, 'plural');
should.equal(plural, 'plurals');
});

it('should correctly update files', function() {
should.equal(__("nested.path"), "nested.path");
should.equal(__("nested.path.sub"), "nested.path.sub");
should.deepEqual(__("nested.path"), {
sub: "nested.path.sub"
});
});
});
});

0 comments on commit 6fc9aa6

Please sign in to comment.