nestjs-i18n
Advanced tools
Comparing version 9.1.5 to 9.1.6
export default [ | ||
require('/Users/toonvanstrijp/Projects/nestjs-i18n/node_modules/infima/dist/css/default/default.css'), | ||
require('/Users/toonvanstrijp/Projects/nestjs-i18n/node_modules/@docusaurus/theme-classic/lib/prism-include-languages'), | ||
require('/Users/toonvanstrijp/Projects/nestjs-i18n/node_modules/@docusaurus/theme-classic/lib/admonitions.css'), | ||
require('/Users/toonvanstrijp/Projects/nestjs-i18n/node_modules/@docusaurus/theme-classic/lib/nprogress'), | ||
require('/Users/toonvanstrijp/Projects/nestjs-i18n/static/css/custom.css'), | ||
]; |
@@ -6,2 +6,3 @@ { | ||
], | ||
"path": "i18n", | ||
"currentLocale": "en", | ||
@@ -13,5 +14,6 @@ "localeConfigs": { | ||
"htmlLang": "en", | ||
"calendar": "gregory" | ||
"calendar": "gregory", | ||
"path": "en" | ||
} | ||
} | ||
} |
{ | ||
"docusaurusVersion": "2.0.0-beta.21", | ||
"siteVersion": "9.1.3", | ||
"docusaurusVersion": "2.0.0-beta.22", | ||
"siteVersion": "9.1.5", | ||
"pluginVersions": { | ||
@@ -8,3 +8,3 @@ "docusaurus-plugin-content-docs": { | ||
"name": "@docusaurus/plugin-content-docs", | ||
"version": "2.0.0-beta.21" | ||
"version": "2.0.0-beta.22" | ||
}, | ||
@@ -14,3 +14,3 @@ "docusaurus-plugin-content-pages": { | ||
"name": "@docusaurus/plugin-content-pages", | ||
"version": "2.0.0-beta.21" | ||
"version": "2.0.0-beta.22" | ||
}, | ||
@@ -20,3 +20,3 @@ "docusaurus-plugin-debug": { | ||
"name": "@docusaurus/plugin-debug", | ||
"version": "2.0.0-beta.21" | ||
"version": "2.0.0-beta.22" | ||
}, | ||
@@ -26,3 +26,3 @@ "docusaurus-theme-classic": { | ||
"name": "@docusaurus/theme-classic", | ||
"version": "2.0.0-beta.21" | ||
"version": "2.0.0-beta.22" | ||
}, | ||
@@ -32,5 +32,5 @@ "docusaurus-theme-search-algolia": { | ||
"name": "@docusaurus/theme-search-algolia", | ||
"version": "2.0.0-beta.21" | ||
"version": "2.0.0-beta.22" | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Logger } from '@nestjs/common'; | ||
import { Logger, OnModuleDestroy } from '@nestjs/common'; | ||
import { I18nOptions } from '..'; | ||
@@ -16,3 +16,3 @@ import { I18nTranslation } from '../interfaces/i18n-translation.interface'; | ||
}; | ||
export declare class I18nService { | ||
export declare class I18nService implements OnModuleDestroy { | ||
private readonly i18nOptions; | ||
@@ -25,6 +25,9 @@ private readonly logger; | ||
private translations; | ||
private unsubscribe; | ||
constructor(i18nOptions: I18nOptions, translations: Observable<I18nTranslation>, supportedLanguages: Observable<string[]>, logger: Logger, loader: I18nLoader, languagesSubject: BehaviorSubject<string[]>, translationsSubject: BehaviorSubject<I18nTranslation>); | ||
onModuleDestroy(): void; | ||
translate<T = any>(key: string, options?: TranslateOptions): T; | ||
t<T = any>(key: string, options?: TranslateOptions): T; | ||
getSupportedLanguages(): string[]; | ||
getTranslations(): I18nTranslation; | ||
refresh(translations?: I18nTranslation | Observable<I18nTranslation>, languages?: string[] | Observable<string[]>): Promise<void>; | ||
@@ -31,0 +34,0 @@ hbsHelper: (key: string, args: any, options: any) => any; |
@@ -28,2 +28,3 @@ "use strict"; | ||
this.translationsSubject = translationsSubject; | ||
this.unsubscribe = new rxjs_1.Subject(); | ||
this.hbsHelper = (key, args, options) => { | ||
@@ -36,9 +37,13 @@ if (!options) { | ||
}; | ||
supportedLanguages.subscribe((languages) => { | ||
supportedLanguages.pipe((0, operators_1.takeUntil)(this.unsubscribe)).subscribe((languages) => { | ||
this.supportedLanguages = languages; | ||
}); | ||
translations.subscribe((t) => { | ||
translations.pipe((0, operators_1.takeUntil)(this.unsubscribe)).subscribe((t) => { | ||
this.translations = t; | ||
}); | ||
} | ||
onModuleDestroy() { | ||
this.unsubscribe.next(null); | ||
this.unsubscribe.complete(); | ||
} | ||
translate(key, options) { | ||
@@ -77,2 +82,5 @@ options = Object.assign({ lang: this.i18nOptions.fallbackLanguage }, options); | ||
} | ||
getTranslations() { | ||
return this.translations; | ||
} | ||
async refresh(translations, languages) { | ||
@@ -99,6 +107,6 @@ if (!translations) { | ||
translateObject(key, translations, options, rootTranslations) { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
const keys = key.split('.'); | ||
const [firstKey] = keys; | ||
const args = (_a = options === null || options === void 0 ? void 0 : options.args) !== null && _a !== void 0 ? _a : {}; | ||
const args = options === null || options === void 0 ? void 0 : options.args; | ||
if (keys.length > 1 && !translations[key]) { | ||
@@ -110,3 +118,3 @@ const newKey = keys.slice(1, keys.length).join('.'); | ||
} | ||
let translation = (_b = translations[key]) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.defaultValue; | ||
let translation = (_a = translations[key]) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.defaultValue; | ||
if (translation && (args || (args instanceof Array && args.length > 0))) { | ||
@@ -140,3 +148,3 @@ const pluralObject = this.getPluralObject(translation); | ||
for (const nestedTranslation of nestedTranslations) { | ||
const result = (_c = this.translateObject(nestedTranslation.key, rootTranslations, Object.assign(Object.assign({}, options), { args: Object.assign({ parent: options.args }, nestedTranslation.args) }))) !== null && _c !== void 0 ? _c : ''; | ||
const result = (_b = this.translateObject(nestedTranslation.key, rootTranslations, Object.assign(Object.assign({}, options), { args: Object.assign({ parent: options.args }, nestedTranslation.args) }))) !== null && _b !== void 0 ? _b : ''; | ||
translation = | ||
@@ -176,3 +184,3 @@ translation.substring(0, nestedTranslation.index - offset) + | ||
let result; | ||
while ((result = regex.exec(translation))) { | ||
while (result = regex.exec(translation)) { | ||
let key = undefined; | ||
@@ -179,0 +187,0 @@ let args = {}; |
{ | ||
"name": "nestjs-i18n", | ||
"version": "9.1.5", | ||
"version": "9.1.6", | ||
"homepage": "https://nestjs-i18n.com", | ||
@@ -15,4 +15,5 @@ "description": "The i18n module for Nest.", | ||
"scripts": { | ||
"prepare":"npm run build", | ||
"build": "npm run build:lib", | ||
"build:lib": "rm -rf dist && tsc -p tsconfig.build.json", | ||
"build:lib": "npx rimraf dist && tsc -p tsconfig.build.json", | ||
"prepublish:npm": "npm run build", | ||
@@ -41,3 +42,3 @@ "publish:npm": "npm publish --access public", | ||
"@apollo/client": "^3.6.9", | ||
"@docusaurus/core": "^2.0.0-beta.22", | ||
"@docusaurus/core": "^2.0.0-beta.21", | ||
"@docusaurus/module-type-aliases": "^2.0.0-beta.21", | ||
@@ -47,3 +48,3 @@ "@docusaurus/preset-classic": "^2.0.0-beta.21", | ||
"@grpc/proto-loader": "^0.6.13", | ||
"@mdx-js/react": "^2.1.2", | ||
"@mdx-js/react": "^1.6.22", | ||
"@nestjs/apollo": "^10.0.16", | ||
@@ -50,0 +51,0 @@ "@nestjs/common": "^8.4.7", |
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
705558
6493