@digitaldefiance/i18n-lib 1.3.8 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/plugin-translatable-generic-error.d.ts +29 -0
- package/dist/plugin-translatable-generic-error.js +66 -0
- package/dist/plugin-translatable-handleable-generic.d.ts +28 -0
- package/dist/plugin-translatable-handleable-generic.js +40 -0
- package/dist/plugin-typed-handleable.d.ts +14 -0
- package/dist/plugin-typed-handleable.js +45 -0
- package/dist/translatable.d.ts +5 -0
- package/dist/translatable.js +11 -0
- package/dist/unified-translator.d.ts +29 -0
- package/dist/unified-translator.js +64 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2274,6 +2274,14 @@ For issues, questions, or contributions:
|
|
|
2274
2274
|
|
|
2275
2275
|
## ChangeLog
|
|
2276
2276
|
|
|
2277
|
+
### Version 1.3.10
|
|
2278
|
+
|
|
2279
|
+
- Add UnifiedTranslator
|
|
2280
|
+
|
|
2281
|
+
### Version 1.3.9
|
|
2282
|
+
|
|
2283
|
+
- Add more handleable/typed classes
|
|
2284
|
+
|
|
2277
2285
|
### Version 1.3.8
|
|
2278
2286
|
|
|
2279
2287
|
- Add TypedHandleable
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export * from './i18n-engine';
|
|
|
21
21
|
export * from './language-definition';
|
|
22
22
|
export * from './template';
|
|
23
23
|
export * from './timezone';
|
|
24
|
-
export * from './translatable-generic-error';
|
|
24
|
+
export * from './plugin-translatable-generic-error';
|
|
25
25
|
export * from './typed-error';
|
|
26
26
|
export * from './typed-handleable';
|
|
27
27
|
export * from './types';
|
|
@@ -33,13 +33,18 @@ export * from './core-string-key';
|
|
|
33
33
|
export * from './language-codes';
|
|
34
34
|
export * from './language-registry';
|
|
35
35
|
export * from './plugin-i18n-engine';
|
|
36
|
+
export * from './plugin-translatable-generic-error';
|
|
37
|
+
export * from './plugin-translatable-handleable-generic';
|
|
38
|
+
export * from './plugin-typed-handleable';
|
|
36
39
|
export * from './registry-config';
|
|
37
40
|
export * from './registry-error';
|
|
38
41
|
export * from './registry-error-type';
|
|
39
42
|
export * from './translation-engine';
|
|
40
43
|
export * from './translation-request';
|
|
41
44
|
export * from './translation-response';
|
|
45
|
+
export * from './translatable';
|
|
42
46
|
export * from './create-translation-adapter';
|
|
47
|
+
export * from './unified-translator';
|
|
43
48
|
export { createCoreI18nEngine as createCoreI18n } from './core-i18n';
|
|
44
49
|
export { I18nEngine as I18n } from './i18n-engine';
|
|
45
50
|
export { PluginI18nEngine as PluginI18n } from './plugin-i18n-engine';
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ __exportStar(require("./i18n-engine"), exports);
|
|
|
40
40
|
__exportStar(require("./language-definition"), exports);
|
|
41
41
|
__exportStar(require("./template"), exports);
|
|
42
42
|
__exportStar(require("./timezone"), exports);
|
|
43
|
-
__exportStar(require("./translatable-generic-error"), exports);
|
|
43
|
+
__exportStar(require("./plugin-translatable-generic-error"), exports);
|
|
44
44
|
__exportStar(require("./typed-error"), exports);
|
|
45
45
|
__exportStar(require("./typed-handleable"), exports);
|
|
46
46
|
__exportStar(require("./types"), exports);
|
|
@@ -52,13 +52,18 @@ __exportStar(require("./core-string-key"), exports);
|
|
|
52
52
|
__exportStar(require("./language-codes"), exports);
|
|
53
53
|
__exportStar(require("./language-registry"), exports);
|
|
54
54
|
__exportStar(require("./plugin-i18n-engine"), exports);
|
|
55
|
+
__exportStar(require("./plugin-translatable-generic-error"), exports);
|
|
56
|
+
__exportStar(require("./plugin-translatable-handleable-generic"), exports);
|
|
57
|
+
__exportStar(require("./plugin-typed-handleable"), exports);
|
|
55
58
|
__exportStar(require("./registry-config"), exports);
|
|
56
59
|
__exportStar(require("./registry-error"), exports);
|
|
57
60
|
__exportStar(require("./registry-error-type"), exports);
|
|
58
61
|
__exportStar(require("./translation-engine"), exports);
|
|
59
62
|
__exportStar(require("./translation-request"), exports);
|
|
60
63
|
__exportStar(require("./translation-response"), exports);
|
|
64
|
+
__exportStar(require("./translatable"), exports);
|
|
61
65
|
__exportStar(require("./create-translation-adapter"), exports);
|
|
66
|
+
__exportStar(require("./unified-translator"), exports);
|
|
62
67
|
// Re-export for convenience
|
|
63
68
|
var core_i18n_1 = require("./core-i18n");
|
|
64
69
|
Object.defineProperty(exports, "createCoreI18n", { enumerable: true, get: function () { return core_i18n_1.createCoreI18nEngine; } });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginI18nEngine } from './plugin-i18n-engine';
|
|
2
|
+
/**
|
|
3
|
+
* Generic translatable error that works with any plugin engine and component
|
|
4
|
+
*/
|
|
5
|
+
export declare class PluginTranslatableGenericError<TStringKey extends string = string, TLanguage extends string = string> extends Error {
|
|
6
|
+
readonly stringKey: TStringKey;
|
|
7
|
+
readonly componentId: string;
|
|
8
|
+
readonly language?: TLanguage;
|
|
9
|
+
readonly variables?: Record<string, string | number>;
|
|
10
|
+
readonly metadata?: Record<string, any>;
|
|
11
|
+
/**
|
|
12
|
+
* Create a translatable error
|
|
13
|
+
* @param componentId - The component ID to translate from
|
|
14
|
+
* @param stringKey - The translation key
|
|
15
|
+
* @param variables - Variables for interpolation
|
|
16
|
+
* @param language - Optional language override
|
|
17
|
+
* @param metadata - Additional error metadata
|
|
18
|
+
* @param instanceKey - Optional engine instance key
|
|
19
|
+
*/
|
|
20
|
+
constructor(componentId: string, stringKey: TStringKey, variables?: Record<string, string | number>, language?: TLanguage, metadata?: Record<string, any>, instanceKey?: string);
|
|
21
|
+
/**
|
|
22
|
+
* Create error with explicit engine instance
|
|
23
|
+
*/
|
|
24
|
+
static withEngine<TStringKey extends string, TLanguage extends string>(engine: PluginI18nEngine<TLanguage>, componentId: string, stringKey: TStringKey, variables?: Record<string, string | number>, language?: TLanguage, metadata?: Record<string, any>): PluginTranslatableGenericError<TStringKey, TLanguage>;
|
|
25
|
+
/**
|
|
26
|
+
* Retranslate the error message in a different language
|
|
27
|
+
*/
|
|
28
|
+
retranslate(language: TLanguage, instanceKey?: string): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginTranslatableGenericError = void 0;
|
|
4
|
+
const plugin_i18n_engine_1 = require("./plugin-i18n-engine");
|
|
5
|
+
/**
|
|
6
|
+
* Generic translatable error that works with any plugin engine and component
|
|
7
|
+
*/
|
|
8
|
+
class PluginTranslatableGenericError extends Error {
|
|
9
|
+
/**
|
|
10
|
+
* Create a translatable error
|
|
11
|
+
* @param componentId - The component ID to translate from
|
|
12
|
+
* @param stringKey - The translation key
|
|
13
|
+
* @param variables - Variables for interpolation
|
|
14
|
+
* @param language - Optional language override
|
|
15
|
+
* @param metadata - Additional error metadata
|
|
16
|
+
* @param instanceKey - Optional engine instance key
|
|
17
|
+
*/
|
|
18
|
+
constructor(componentId, stringKey, variables, language, metadata, instanceKey) {
|
|
19
|
+
let translatedMessage;
|
|
20
|
+
try {
|
|
21
|
+
const engine = plugin_i18n_engine_1.PluginI18nEngine.getInstance(instanceKey);
|
|
22
|
+
translatedMessage = engine.safeTranslate(componentId, stringKey, variables, language);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
// If engine not found or translation fails, use fallback format
|
|
26
|
+
translatedMessage = `[${componentId}.${stringKey}]`;
|
|
27
|
+
}
|
|
28
|
+
super(translatedMessage);
|
|
29
|
+
this.name = 'TranslatableGenericError';
|
|
30
|
+
this.stringKey = stringKey;
|
|
31
|
+
this.componentId = componentId;
|
|
32
|
+
this.language = language;
|
|
33
|
+
this.variables = variables;
|
|
34
|
+
this.metadata = metadata;
|
|
35
|
+
// Ensure proper prototype chain for instanceof checks across transpiled targets
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create error with explicit engine instance
|
|
39
|
+
*/
|
|
40
|
+
static withEngine(engine, componentId, stringKey, variables, language, metadata) {
|
|
41
|
+
const translatedMessage = engine.safeTranslate(componentId, stringKey, variables, language);
|
|
42
|
+
const error = Object.create(PluginTranslatableGenericError.prototype);
|
|
43
|
+
Error.call(error, translatedMessage);
|
|
44
|
+
error.name = 'TranslatableGenericError';
|
|
45
|
+
error.stringKey = stringKey;
|
|
46
|
+
error.componentId = componentId;
|
|
47
|
+
error.language = language;
|
|
48
|
+
error.variables = variables;
|
|
49
|
+
error.metadata = metadata;
|
|
50
|
+
error.message = translatedMessage;
|
|
51
|
+
return error;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Retranslate the error message in a different language
|
|
55
|
+
*/
|
|
56
|
+
retranslate(language, instanceKey) {
|
|
57
|
+
try {
|
|
58
|
+
const engine = plugin_i18n_engine_1.PluginI18nEngine.getInstance(instanceKey);
|
|
59
|
+
return engine.safeTranslate(this.componentId, this.stringKey, this.variables, language);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return `[${this.componentId}.${this.stringKey}]`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.PluginTranslatableGenericError = PluginTranslatableGenericError;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IHandleable } from './i-handleable';
|
|
2
|
+
import { PluginTranslatableGenericError } from './plugin-translatable-generic-error';
|
|
3
|
+
/**
|
|
4
|
+
* Generic translatable error that works with any plugin engine and component
|
|
5
|
+
*/
|
|
6
|
+
export declare class PluginTranslatableHandleableGenericError<TStringKey extends string = string, TLanguage extends string = string> extends PluginTranslatableGenericError<TStringKey, TLanguage> implements IHandleable {
|
|
7
|
+
private _handled;
|
|
8
|
+
readonly cause?: Error;
|
|
9
|
+
readonly statusCode: number;
|
|
10
|
+
readonly sourceData?: unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Create a translatable error
|
|
13
|
+
* @param componentId - The component ID to translate from
|
|
14
|
+
* @param stringKey - The translation key
|
|
15
|
+
* @param variables - Variables for interpolation
|
|
16
|
+
* @param language - Optional language override
|
|
17
|
+
* @param metadata - Additional error metadata
|
|
18
|
+
* @param instanceKey - Optional engine instance key
|
|
19
|
+
*/
|
|
20
|
+
constructor(componentId: string, stringKey: TStringKey, variables?: Record<string, string | number>, language?: TLanguage, metadata?: Record<string, any>, instanceKey?: string, handleableOptions?: {
|
|
21
|
+
statusCode?: number;
|
|
22
|
+
cause?: Error;
|
|
23
|
+
sourceData?: unknown;
|
|
24
|
+
});
|
|
25
|
+
get handled(): boolean;
|
|
26
|
+
set handled(value: boolean);
|
|
27
|
+
toJSON(): Record<string, unknown>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginTranslatableHandleableGenericError = void 0;
|
|
4
|
+
const plugin_translatable_generic_error_1 = require("./plugin-translatable-generic-error");
|
|
5
|
+
/**
|
|
6
|
+
* Generic translatable error that works with any plugin engine and component
|
|
7
|
+
*/
|
|
8
|
+
class PluginTranslatableHandleableGenericError extends plugin_translatable_generic_error_1.PluginTranslatableGenericError {
|
|
9
|
+
/**
|
|
10
|
+
* Create a translatable error
|
|
11
|
+
* @param componentId - The component ID to translate from
|
|
12
|
+
* @param stringKey - The translation key
|
|
13
|
+
* @param variables - Variables for interpolation
|
|
14
|
+
* @param language - Optional language override
|
|
15
|
+
* @param metadata - Additional error metadata
|
|
16
|
+
* @param instanceKey - Optional engine instance key
|
|
17
|
+
*/
|
|
18
|
+
constructor(componentId, stringKey, variables, language, metadata, instanceKey, handleableOptions) {
|
|
19
|
+
super(componentId, stringKey, variables, language, metadata, instanceKey);
|
|
20
|
+
this._handled = false;
|
|
21
|
+
this.statusCode = handleableOptions?.statusCode ?? 500;
|
|
22
|
+
this.cause = handleableOptions?.cause;
|
|
23
|
+
this.sourceData = handleableOptions?.sourceData;
|
|
24
|
+
}
|
|
25
|
+
get handled() {
|
|
26
|
+
return this._handled;
|
|
27
|
+
}
|
|
28
|
+
set handled(value) {
|
|
29
|
+
this._handled = value;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
statusCode: this.statusCode,
|
|
34
|
+
message: this.message,
|
|
35
|
+
cause: this.cause,
|
|
36
|
+
sourceData: this.sourceData,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PluginTranslatableHandleableGenericError = PluginTranslatableHandleableGenericError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HandleableErrorOptions } from './i-handleable-error-options';
|
|
2
|
+
import { IHandleable } from './i-handleable';
|
|
3
|
+
import { CompleteReasonMap, PluginTypedError } from './typed-error';
|
|
4
|
+
import { PluginI18nEngine } from './plugin-i18n-engine';
|
|
5
|
+
export declare class PluginTypedHandleableError<TEnum extends Record<string, string>, TStringKey extends string, TLanguages extends string = string> extends PluginTypedError<TEnum, TStringKey, TLanguages> implements IHandleable {
|
|
6
|
+
readonly cause?: Error;
|
|
7
|
+
readonly statusCode: number;
|
|
8
|
+
readonly sourceData?: unknown;
|
|
9
|
+
private _handled;
|
|
10
|
+
constructor(engine: PluginI18nEngine<TLanguages>, componentId: string, type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, source: Error, options?: HandleableErrorOptions, language?: TLanguages, otherVars?: Record<string, string | number>);
|
|
11
|
+
get handled(): boolean;
|
|
12
|
+
set handled(value: boolean);
|
|
13
|
+
toJSON(): Record<string, unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginTypedHandleableError = void 0;
|
|
4
|
+
const handleable_1 = require("./handleable");
|
|
5
|
+
const typed_error_1 = require("./typed-error");
|
|
6
|
+
class PluginTypedHandleableError extends typed_error_1.PluginTypedError {
|
|
7
|
+
constructor(engine, componentId, type, reasonMap, source, options, language, otherVars) {
|
|
8
|
+
super(engine, componentId, type, reasonMap, language, otherVars);
|
|
9
|
+
this.cause = options?.cause ?? source;
|
|
10
|
+
this.statusCode = options?.statusCode ?? 500;
|
|
11
|
+
this._handled = options?.handled ?? false;
|
|
12
|
+
this.sourceData = options?.sourceData;
|
|
13
|
+
// Capture stack trace - prioritize source stack, then capture new one
|
|
14
|
+
if (source.stack) {
|
|
15
|
+
this.stack = source.stack;
|
|
16
|
+
}
|
|
17
|
+
else if (Error.captureStackTrace) {
|
|
18
|
+
Error.captureStackTrace(this, this.constructor);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.stack = new Error().stack;
|
|
22
|
+
}
|
|
23
|
+
this.name = this.constructor.name;
|
|
24
|
+
}
|
|
25
|
+
get handled() {
|
|
26
|
+
return this._handled;
|
|
27
|
+
}
|
|
28
|
+
set handled(value) {
|
|
29
|
+
this._handled = value;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
name: this.name,
|
|
34
|
+
message: this.message,
|
|
35
|
+
statusCode: this.statusCode,
|
|
36
|
+
handled: this.handled,
|
|
37
|
+
stack: this.stack,
|
|
38
|
+
cause: this.cause instanceof handleable_1.HandleableError || this.cause instanceof PluginTypedHandleableError
|
|
39
|
+
? this.cause.toJSON()
|
|
40
|
+
: this.cause?.message,
|
|
41
|
+
...(this.sourceData ? { sourceData: this.sourceData } : {}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.PluginTypedHandleableError = PluginTypedHandleableError;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { I18nEngine } from './i18n-engine';
|
|
2
|
+
import { Language } from './default-config';
|
|
3
|
+
export declare class TranslatableError<TStringKey extends string> extends Error {
|
|
4
|
+
constructor(engine: I18nEngine<TStringKey, Language, any, any>, string: TStringKey, otherVars?: Record<string, string | number>, language?: Language);
|
|
5
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TranslatableError = void 0;
|
|
4
|
+
class TranslatableError extends Error {
|
|
5
|
+
constructor(engine, string, otherVars, language) {
|
|
6
|
+
super(engine.translate(string, otherVars, language));
|
|
7
|
+
this.name = 'TranslatableError';
|
|
8
|
+
Object.setPrototypeOf(this, TranslatableError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.TranslatableError = TranslatableError;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginI18nEngine } from './plugin-i18n-engine';
|
|
2
|
+
import { I18nEngine } from './i18n-engine';
|
|
3
|
+
/**
|
|
4
|
+
* Unified translator with explicit component/engine specification
|
|
5
|
+
*/
|
|
6
|
+
export declare class UnifiedTranslator<TLanguage extends string = string> {
|
|
7
|
+
private sources;
|
|
8
|
+
private defaultLanguage;
|
|
9
|
+
private defaultSource?;
|
|
10
|
+
constructor(defaultLanguage: TLanguage);
|
|
11
|
+
/**
|
|
12
|
+
* Register a plugin component
|
|
13
|
+
*/
|
|
14
|
+
registerPlugin(id: string, engine: PluginI18nEngine<any>, componentId: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Register a legacy engine
|
|
17
|
+
*/
|
|
18
|
+
registerLegacy(id: string, engine: I18nEngine<any, any, any, any>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Set default source for unqualified keys
|
|
21
|
+
*/
|
|
22
|
+
setDefaultSource(id: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Translate with explicit source: 'source:key' or just 'key' (uses default)
|
|
25
|
+
*/
|
|
26
|
+
translate(key: string, vars?: Record<string, string | number>, language?: TLanguage): string;
|
|
27
|
+
setLanguage(language: TLanguage): void;
|
|
28
|
+
getLanguage(): TLanguage;
|
|
29
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnifiedTranslator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Unified translator with explicit component/engine specification
|
|
6
|
+
*/
|
|
7
|
+
class UnifiedTranslator {
|
|
8
|
+
constructor(defaultLanguage) {
|
|
9
|
+
this.sources = new Map();
|
|
10
|
+
this.defaultLanguage = defaultLanguage;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Register a plugin component
|
|
14
|
+
*/
|
|
15
|
+
registerPlugin(id, engine, componentId) {
|
|
16
|
+
this.sources.set(id, { type: 'plugin', engine, componentId });
|
|
17
|
+
if (!this.defaultSource)
|
|
18
|
+
this.defaultSource = id;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Register a legacy engine
|
|
22
|
+
*/
|
|
23
|
+
registerLegacy(id, engine) {
|
|
24
|
+
this.sources.set(id, { type: 'legacy', engine });
|
|
25
|
+
if (!this.defaultSource)
|
|
26
|
+
this.defaultSource = id;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set default source for unqualified keys
|
|
30
|
+
*/
|
|
31
|
+
setDefaultSource(id) {
|
|
32
|
+
if (!this.sources.has(id)) {
|
|
33
|
+
throw new Error(`Source '${id}' not registered`);
|
|
34
|
+
}
|
|
35
|
+
this.defaultSource = id;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Translate with explicit source: 'source:key' or just 'key' (uses default)
|
|
39
|
+
*/
|
|
40
|
+
translate(key, vars, language) {
|
|
41
|
+
const lang = language || this.defaultLanguage;
|
|
42
|
+
const [sourceName, actualKey] = key.includes(':')
|
|
43
|
+
? key.split(':', 2)
|
|
44
|
+
: [this.defaultSource, key];
|
|
45
|
+
if (!sourceName)
|
|
46
|
+
return `[${key}]`;
|
|
47
|
+
const source = this.sources.get(sourceName);
|
|
48
|
+
if (!source)
|
|
49
|
+
return `[${key}]`;
|
|
50
|
+
if (source.type === 'plugin') {
|
|
51
|
+
return source.engine.safeTranslate(source.componentId, actualKey, vars, lang);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return source.engine.safeTranslate(actualKey, vars, lang);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
setLanguage(language) {
|
|
58
|
+
this.defaultLanguage = language;
|
|
59
|
+
}
|
|
60
|
+
getLanguage() {
|
|
61
|
+
return this.defaultLanguage;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.UnifiedTranslator = UnifiedTranslator;
|