Skip to content

Commit

Permalink
adds support for keySeparator = false
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed Jul 6, 2018
1 parent a187e65 commit 95a0cb5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ npm-debug.log.*
node_modules
node_modules/**/*
coverage/**/*
package-lock.json
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v1.1.0
- support for keySeparator = false [222](https://github.com/i18next/i18next-node-fs-backend/issues/222)

### v1.0.0

- support for reading js files (no write supported!) [PR216](https://github.com/i18next/i18next-node-fs-backend/pull/216)
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ var Backend = function () {
if (err) resources = {};

missings.forEach(function (missing) {
utils.setPath(resources, missing.key.split(_this2.coreOptions.keySeparator || '.'), missing.fallbackValue);
var path = _this2.coreOptions.keySeparator === false ? [missing.key] : missing.key.split(_this2.coreOptions.keySeparator || '.');
utils.setPath(resources, path, missing.fallbackValue);
});

_fs2.default.writeFile(filename, JSON.stringify(resources, null, _this2.options.jsonIndent), function (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "i18next-node-fs-backend",
"version": "1.0.0",
"version": "1.1.0",
"description": "node.js backend layer for i18next using fs module to load resources from filesystem",
"main": "./index.js",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class Backend {
if (err) resources = {};

missings.forEach((missing) => {
utils.setPath(resources, missing.key.split(this.coreOptions.keySeparator || '.'), missing.fallbackValue);
const path = this.coreOptions.keySeparator === false ? [missing.key] : (missing.key.split(this.coreOptions.keySeparator || '.'));
utils.setPath(resources, path, missing.fallbackValue);
});

fs.writeFile(filename, JSON.stringify(resources, null, this.options.jsonIndent), (err) => {
Expand Down

0 comments on commit 95a0cb5

Please sign in to comment.