nestjs-i18n
Advanced tools
Comparing version 10.1.0-next.2 to 10.1.0-next.3
{ | ||
"docusaurusVersion": "2.2.0", | ||
"siteVersion": "10.0.0", | ||
"siteVersion": "10.1.0-next.2", | ||
"pluginVersions": { | ||
@@ -5,0 +5,0 @@ "docusaurus-plugin-content-docs": { |
@@ -6,8 +6,6 @@ "use strict"; | ||
const i18n_context_1 = require("../i18n.context"); | ||
const context_1 = require("../utils/context"); | ||
exports.I18nLang = (0, common_1.createParamDecorator)((data, context) => { | ||
var _a, _b; | ||
const i18n = (_a = i18n_context_1.I18nContext.current()) !== null && _a !== void 0 ? _a : (_b = (0, context_1.getContextObject)(context)) === null || _b === void 0 ? void 0 : _b.i18nContext; | ||
const i18n = i18n_context_1.I18nContext.current(context); | ||
return i18n.lang; | ||
}); | ||
//# sourceMappingURL=i18n-lang.decorator.js.map |
import { ExecutionContext } from '@nestjs/common'; | ||
import { I18nTranslator } from './interfaces/i18n-translator.interface'; | ||
import { I18nValidationError } from './interfaces/i18n-validation-error.interface'; | ||
import { I18nService, TranslateOptions } from './services/i18n.service'; | ||
import { Path, PathValue } from './types'; | ||
export declare class I18nContext<K = Record<string, unknown>> { | ||
export declare class I18nContext<K = Record<string, unknown>> implements I18nTranslator<K> { | ||
readonly lang: string; | ||
@@ -7,0 +8,0 @@ readonly service: I18nService<K>; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const async_hooks_1 = require("async_hooks"); | ||
const i18n_module_1 = require("./i18n.module"); | ||
const context_1 = require("./utils/context"); | ||
@@ -35,3 +36,7 @@ class I18nContext { | ||
var _a, _b; | ||
return (_a = this.storage.getStore()) !== null && _a !== void 0 ? _a : (_b = (0, context_1.getContextObject)(context)) === null || _b === void 0 ? void 0 : _b.i18nContext; | ||
const i18n = (_a = this.storage.getStore()) !== null && _a !== void 0 ? _a : (_b = (0, context_1.getContextObject)(context)) === null || _b === void 0 ? void 0 : _b.i18nContext; | ||
if (!i18n) { | ||
i18n_module_1.logger.error('I18n context not found! Is this function triggered by a processor or cronjob? Please use the I18nService'); | ||
} | ||
return i18n; | ||
} | ||
@@ -38,0 +43,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { DynamicModule, MiddlewareConsumer, OnModuleDestroy } from '@nestjs/common'; | ||
import { DynamicModule, Logger, MiddlewareConsumer, OnModuleDestroy } from '@nestjs/common'; | ||
import { I18nService } from './services/i18n.service'; | ||
@@ -8,2 +8,3 @@ import { I18nAsyncOptions, I18nOptions } from './interfaces/i18n-options.interface'; | ||
import { Observable } from 'rxjs'; | ||
export declare const logger: Logger; | ||
export declare class I18nModule implements OnModuleInit, OnModuleDestroy, NestModule { | ||
@@ -10,0 +11,0 @@ private readonly i18n; |
@@ -27,3 +27,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.I18nModule = void 0; | ||
exports.I18nModule = exports.logger = void 0; | ||
const common_1 = require("@nestjs/common"); | ||
@@ -46,3 +46,3 @@ const i18n_constants_1 = require("./i18n.constants"); | ||
const path = require("path"); | ||
const logger = new common_1.Logger('I18nService'); | ||
exports.logger = new common_1.Logger('I18nService'); | ||
const defaultOptions = { | ||
@@ -68,3 +68,3 @@ resolvers: [], | ||
this.translations.pipe((0, rxjs_1.takeUntil)(this.unsubscribe)).subscribe((t) => { | ||
logger.log('Checking translation changes'); | ||
exports.logger.log('Checking translation changes'); | ||
const object = Object.keys(t).reduce((result, key) => (0, merge_1.mergeDeep)(result, t[key]), {}); | ||
@@ -81,3 +81,5 @@ const i18nTranslationsType = typescript_1.factory.createTypeAliasDeclaration([typescript_1.factory.createModifier(ts.SyntaxKind.ExportKeyword)], typescript_1.factory.createIdentifier('I18nTranslations'), undefined, typescript_1.factory.createTypeLiteralNode((0, util_1.convertObjectToTypeDefinition)(object))); | ||
]); | ||
const outputFile = printer.printList(ts.ListFormat.MultiLine, nodes, sourceFile); | ||
const outputFile = `/* DO NOT EDIT, file generated by nestjs-i18n */ | ||
/* eslint-disable */ | ||
${printer.printList(ts.ListFormat.MultiLine, nodes, sourceFile)}`; | ||
fs.mkdirSync(path.dirname(this.i18nOptions.typesOutputPath), { | ||
@@ -95,6 +97,6 @@ recursive: true, | ||
fs.writeFileSync(this.i18nOptions.typesOutputPath, outputFile); | ||
logger.log(`types generated in: ${this.i18nOptions.typesOutputPath}`); | ||
exports.logger.log(`types generated in: ${this.i18nOptions.typesOutputPath}`); | ||
} | ||
else { | ||
logger.log('no changes detected'); | ||
exports.logger.log('no changes detected'); | ||
} | ||
@@ -108,6 +110,6 @@ }); | ||
hbs.registerHelper('t', this.i18n.hbsHelper); | ||
logger.log('handlebars helper registered'); | ||
exports.logger.log('handlebars helper registered'); | ||
} | ||
catch (e) { | ||
logger.error('hbs module failed to load', e); | ||
exports.logger.error('hbs module failed to load', e); | ||
} | ||
@@ -169,3 +171,3 @@ } | ||
catch (e) { | ||
logger.error('parsing translation error', e); | ||
exports.logger.error('parsing translation error', e); | ||
} | ||
@@ -189,3 +191,3 @@ return i18nTranslationSubject.asObservable(); | ||
catch (e) { | ||
logger.error('parsing translation error', e); | ||
exports.logger.error('parsing translation error', e); | ||
} | ||
@@ -203,3 +205,3 @@ return i18nLanguagesSubject.asObservable(); | ||
providers: [ | ||
{ provide: common_1.Logger, useValue: logger }, | ||
{ provide: common_1.Logger, useValue: exports.logger }, | ||
{ | ||
@@ -251,3 +253,3 @@ provide: core_1.APP_INTERCEPTOR, | ||
providers: [ | ||
{ provide: common_1.Logger, useValue: logger }, | ||
{ provide: common_1.Logger, useValue: exports.logger }, | ||
{ | ||
@@ -315,3 +317,3 @@ provide: core_1.APP_INTERCEPTOR, | ||
catch (e) { | ||
logger.error('parsing translation error', e); | ||
exports.logger.error('parsing translation error', e); | ||
} | ||
@@ -337,3 +339,3 @@ return translationsSubject.asObservable(); | ||
catch (e) { | ||
logger.error('parsing translation error', e); | ||
exports.logger.error('parsing translation error', e); | ||
} | ||
@@ -351,3 +353,3 @@ return languagesSubject.asObservable(); | ||
if (!resolvers || resolvers.length === 0) { | ||
logger.error(`No resolvers provided! nestjs-i18n won't workt properly, please follow the quick-start guide: https://nestjs-i18n.com/quick-start`); | ||
exports.logger.error(`No resolvers provided! nestjs-i18n won't workt properly, please follow the quick-start guide: https://nestjs-i18n.com/quick-start`); | ||
} | ||
@@ -354,0 +356,0 @@ return (resolvers || []) |
@@ -7,2 +7,3 @@ import { Logger, OnModuleDestroy } from '@nestjs/common'; | ||
import { IfAny, Path, PathValue } from '../types'; | ||
import { I18nTranslator } from '../interfaces/i18n-translator.interface'; | ||
export type TranslateOptions = { | ||
@@ -18,3 +19,3 @@ lang?: string; | ||
}; | ||
export declare class I18nService<K = Record<string, unknown>> implements OnModuleDestroy { | ||
export declare class I18nService<K = Record<string, unknown>> implements I18nTranslator<K>, OnModuleDestroy { | ||
protected readonly i18nOptions: I18nOptions; | ||
@@ -21,0 +22,0 @@ private readonly logger; |
{ | ||
"name": "nestjs-i18n", | ||
"version": "10.1.0-next.2", | ||
"version": "10.1.0-next.3", | ||
"homepage": "https://nestjs-i18n.com", | ||
@@ -5,0 +5,0 @@ "description": "The i18n module for Nest.", |
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
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
3902054
308
7447