@skyra/i18next-backend
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -5,2 +5,17 @@ # Changelog | ||
# [@skyra/i18next-backend@0.1.0] | ||
(https://github.com/skyra-project/archid-components/tree/@skyra/i18next-backend@0.1.0) - (2022-04-18) | ||
## Bug Fixes | ||
- **hfx-i18n:** Add static `type` field as required by i18next (#56) ([a7315ef](https://github.com/skyra-project/archid-components/commit/a7315ef0c87f61d8b1338ee16a82c17a5876fc5f)) | ||
- **i18next-backend:** Add CJS bundle ([3da6e05](https://github.com/skyra-project/archid-components/commit/3da6e051009a0e23026bf7fd674085f996ca9edf)) | ||
- Ensure proper files array for yarn pack ([38214a3](https://github.com/skyra-project/archid-components/commit/38214a3be182369efe076428c425b6aa43e1ee35)) | ||
- Bump i18next dependency ([1117c38](https://github.com/skyra-project/archid-components/commit/1117c38949f9ec238c72c396df0b623a74ec07c6)) | ||
- Fixed export mapping in package.json ([d217c18](https://github.com/skyra-project/archid-components/commit/d217c18ac357fd83c448fc5682857b292e09da60)) | ||
## Features | ||
- Added i18n packages (#38) ([a55ef56](https://github.com/skyra-project/archid-components/commit/a55ef562219162879f436d80e8f12acef82dd3ec)) | ||
# [@skyra/i18next-backend@0.0.5](https://github.com/skyra-project/archid-components/compare/@skyra/i18next-backend@0.0.4...@skyra/i18next-backend@0.0.5) - (2022-04-12) | ||
@@ -7,0 +22,0 @@ |
@@ -10,6 +10,7 @@ /// <reference types="node" /> | ||
read(language: string, namespace: string, callback: ReadCallback): void; | ||
private readPaths; | ||
private readPathsSync; | ||
private readPathSync; | ||
private readPaths; | ||
private readPath; | ||
static readonly type = "backend"; | ||
private static readPath; | ||
private static readPathSync; | ||
private static handleResults; | ||
@@ -16,0 +17,0 @@ private static resolvePath; |
@@ -47,8 +47,14 @@ "use strict"; | ||
} | ||
async readPaths(language, namespace) { | ||
if (this.paths.length === 1) | ||
return Backend.readPath(Backend.resolvePath(language, namespace, this.paths[0])); | ||
const results = await Promise.allSettled(this.paths.map((path) => Backend.readPath(Backend.resolvePath(language, namespace, path)))); | ||
return Backend.handleResults(results); | ||
} | ||
readPathsSync(language, namespace) { | ||
if (this.paths.length === 1) | ||
return this.readPathSync(Backend.resolvePath(language, namespace, this.paths[0])); | ||
return Backend.readPathSync(Backend.resolvePath(language, namespace, this.paths[0])); | ||
const results = this.paths.map((path) => { | ||
try { | ||
return { status: 'fulfilled', value: this.readPathSync(Backend.resolvePath(language, namespace, path)) }; | ||
return { status: 'fulfilled', value: Backend.readPathSync(Backend.resolvePath(language, namespace, path)) }; | ||
} | ||
@@ -61,14 +67,8 @@ catch (error) { | ||
} | ||
readPathSync(path) { | ||
static async readPath(path) { | ||
return JSON.parse(await (0, promises_1.readFile)(path, 'utf8')); | ||
} | ||
static readPathSync(path) { | ||
return JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8')); | ||
} | ||
async readPaths(language, namespace) { | ||
if (this.paths.length === 1) | ||
return this.readPath(Backend.resolvePath(language, namespace, this.paths[0])); | ||
const results = await Promise.allSettled(this.paths.map((path) => this.readPath(Backend.resolvePath(language, namespace, path)))); | ||
return Backend.handleResults(results); | ||
} | ||
async readPath(path) { | ||
return JSON.parse(await (0, promises_1.readFile)(path, 'utf8')); | ||
} | ||
static handleResults(results) { | ||
@@ -90,2 +90,8 @@ const filtered = results.filter((result) => result.status === 'fulfilled'); | ||
exports.Backend = Backend; | ||
Object.defineProperty(Backend, "type", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 'backend' | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@skyra/i18next-backend", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "A filesystem-based backend for i18next", | ||
@@ -22,4 +22,4 @@ "author": "@skyra", | ||
"prepublishOnly": "yarn build", | ||
"bump": "standard-version --no-verify", | ||
"changelog": "git cliff --prepend ./CHANGELOG.md -l -c ./cliff.toml -r ../../ --include-path 'packages/i18next-backend/*'" | ||
"bump": "cliff-jumper", | ||
"check-update": "cliff-jumper --dry-run" | ||
}, | ||
@@ -26,0 +26,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17439
203