Skip to content

Commit

Permalink
closes #18 default plurals
Browse files Browse the repository at this point in the history
  • Loading branch information
csimi committed Apr 23, 2018
1 parent 17e2a93 commit 9bb47b5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elvoline/twig",
"version": "2.0.1",
"version": "2.1.0",
"description": "twig.js renderer for elvoline",
"module": "dist/es.js",
"main": "dist/index.js",
Expand Down
7 changes: 6 additions & 1 deletion src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import modifiable from './modifiable';
* @type {Object}
*/

var data = setTranslations();
var data = setTranslations({
'plural': {
'forms': 2,
'expression': 'n != 1',
},
});

/**
* Parses and sets translation data.
Expand Down
14 changes: 14 additions & 0 deletions test/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import twig, {

describe('translations', () => {
describe('setTranslations()', () => {
it('should default to english plural settings', () => {
var template = twig({
'data': `translate {% trans %}single{% plural amountOf %}double{% endtrans %}`,
});

var promise = template
.render({
'amountOf': 2,
})
.then((dom) => dom.text());

return expect(promise).to.eventually.equal('translate double');
});

it('should not crash on transforming blank translation data', () => {
var promise = setTranslations();

Expand Down

0 comments on commit 9bb47b5

Please sign in to comment.