Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed Feb 13, 2019
1 parent 95dfee8 commit 55bcc6d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
### 15.0.3

- typescript: accept templatestringsarray as TKey [1199](https://github.com/i18next/i18next/pull/1199)
- allow arrays on addResources

### 15.0.2

- try fixing UMD build
Expand Down
2 changes: 1 addition & 1 deletion i18next.js
Expand Up @@ -552,7 +552,7 @@

/* eslint no-restricted-syntax: 0 */
for (var m in resources) {
if (typeof resources[m] === 'string') this.addResource(lng, ns, m, resources[m], {
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
silent: true
});
}
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": "15.0.2",
"version": "15.0.3",
"description": "i18next internationalization framework",
"main": "./index.js",
"types": "index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion src/ResourceStore.js
Expand Up @@ -63,7 +63,10 @@ class ResourceStore extends EventEmitter {
addResources(lng, ns, resources, options = { silent: false }) {
/* eslint no-restricted-syntax: 0 */
for (const m in resources) {
if (typeof resources[m] === 'string')
if (
typeof resources[m] === 'string' ||
Object.prototype.toString.apply(resources[m]) === '[object Array]'
)
this.addResource(lng, ns, m, resources[m], { silent: true });
}
if (!options.silent) this.emit('added', lng, ns, resources);
Expand Down
6 changes: 5 additions & 1 deletion src/Translator.js
Expand Up @@ -143,7 +143,11 @@ class Translator extends EventEmitter {
}
res = copy;
}
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
} else if (
handleAsObjectInI18nFormat &&
typeof joinArrays === 'string' &&
resType === '[object Array]'
) {
// array special treatment
res = res.join(joinArrays);
if (res) res = this.extendTranslation(res, keys, options);
Expand Down
8 changes: 4 additions & 4 deletions test/translator/translator.translate.array.spec.js
Expand Up @@ -17,8 +17,8 @@ describe('Translator', () => {
search: {
flagList: [['basic', 'Basic'], ['simple', 'Simple']],
},
keyArray: ["hello world {{count}}", "hey {{count}}"],
keyArray_plural: ["hello world plural {{count}}", "hey plural {{count}}"],
keyArray: ['hello world {{count}}', 'hey {{count}}'],
keyArray_plural: ['hello world plural {{count}}', 'hey plural {{count}}'],
},
},
});
Expand Down Expand Up @@ -62,11 +62,11 @@ describe('Translator', () => {
},
{
args: ['keyArray', { count: 1 }],
expected: ["hello world 1", "hey 1"],
expected: ['hello world 1', 'hey 1'],
},
{
args: ['keyArray', { count: 100 }],
expected: ["hello world plural 100", "hey plural 100"],
expected: ['hello world plural 100', 'hey plural 100'],
},
];

Expand Down

0 comments on commit 55bcc6d

Please sign in to comment.