nestjs-i18n
Advanced tools
Comparing version 8.3.0 to 8.3.1
@@ -178,3 +178,5 @@ "use strict"; | ||
provide: i18n_constants_1.I18N_OPTIONS, | ||
useFactory: options.useFactory, | ||
useFactory: async () => { | ||
return this.sanitizeI18nOptions(await options.useFactory()); | ||
}, | ||
inject: options.inject || [], | ||
@@ -185,3 +187,3 @@ }; | ||
provide: i18n_constants_1.I18N_OPTIONS, | ||
useFactory: async (optionsFactory) => await optionsFactory.createI18nOptions(), | ||
useFactory: async (optionsFactory) => this.sanitizeI18nOptions(await optionsFactory.createI18nOptions()), | ||
inject: [options.useClass || options.useExisting], | ||
@@ -194,3 +196,3 @@ }; | ||
useFactory: async (options) => { | ||
return options.parserOptions; | ||
return this.sanitizeI18nOptions(options.parserOptions); | ||
}, | ||
@@ -197,0 +199,0 @@ inject: [i18n_constants_1.I18N_OPTIONS], |
@@ -13,2 +13,3 @@ import { Logger } from '@nestjs/common'; | ||
}; | ||
debug?: boolean; | ||
}; | ||
@@ -15,0 +16,0 @@ export declare class I18nService { |
@@ -85,5 +85,6 @@ "use strict"; | ||
async translateObject(key, translations, options, rootTranslations) { | ||
var _a; | ||
const keys = key.split('.'); | ||
const [firstKey] = keys; | ||
const { args } = options; | ||
const args = (_a = options === null || options === void 0 ? void 0 : options.args) !== null && _a !== void 0 ? _a : {}; | ||
if (keys.length > 1 && !translations.hasOwnProperty(key)) { | ||
@@ -111,5 +112,9 @@ const newKey = keys.slice(1, keys.length).join('.'); | ||
else if (translation instanceof Object) { | ||
return Object.keys(translation).reduce(async (obj, nestedKey) => { | ||
const result = await Object.keys(translation).reduce(async (obj, nestedKey) => { | ||
return Object.assign(Object.assign({}, (await obj)), { [nestedKey]: await this.translateObject(nestedKey, translation, options, rootTranslations) }); | ||
}, Promise.resolve({})); | ||
if (translation instanceof Array) { | ||
return Object.values(result); | ||
} | ||
return result; | ||
} | ||
@@ -116,0 +121,0 @@ translation = this.i18nOptions.formatter(translation, ...(args instanceof Array ? args || [] : [args])); |
{ | ||
"name": "nestjs-i18n", | ||
"version": "8.3.0", | ||
"version": "8.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Toon van Strijp", |
Sorry, the diff of this file is not supported yet
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
377948
91
2280