@digitaldefiance/i18n-lib 1.3.13 → 1.3.14
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 +4 -0
- package/package.json +4 -3
- package/src/active-context.d.ts +30 -0
- package/src/active-context.d.ts.map +1 -0
- package/src/active-context.js +3 -0
- package/src/active-context.js.map +1 -0
- package/src/component-definition.d.ts +12 -0
- package/src/component-definition.d.ts.map +1 -0
- package/src/component-definition.js +3 -0
- package/src/component-definition.js.map +1 -0
- package/src/component-registration.d.ts +10 -0
- package/src/component-registration.d.ts.map +1 -0
- package/src/component-registration.js +3 -0
- package/src/component-registration.js.map +1 -0
- package/src/component-registry.d.ts +69 -0
- package/src/component-registry.d.ts.map +1 -0
- package/src/component-registry.js +248 -0
- package/src/component-registry.js.map +1 -0
- package/src/context-error-type.d.ts +4 -0
- package/src/context-error-type.d.ts.map +1 -0
- package/src/context-error-type.js +8 -0
- package/src/context-error-type.js.map +1 -0
- package/src/context-error.d.ts +7 -0
- package/src/context-error.d.ts.map +1 -0
- package/src/context-error.js +18 -0
- package/src/context-error.js.map +1 -0
- package/src/context-manager.d.ts +34 -0
- package/src/context-manager.d.ts.map +1 -0
- package/src/context-manager.js +60 -0
- package/src/context-manager.js.map +1 -0
- package/src/context.d.ts +45 -0
- package/src/context.d.ts.map +1 -0
- package/src/context.js +70 -0
- package/src/context.js.map +1 -0
- package/src/core-i18n.d.ts +63 -0
- package/src/core-i18n.d.ts.map +1 -0
- package/src/core-i18n.js +478 -0
- package/src/core-i18n.js.map +1 -0
- package/src/core-string-key.d.ts +43 -0
- package/src/core-string-key.d.ts.map +1 -0
- package/src/core-string-key.js +51 -0
- package/src/core-string-key.js.map +1 -0
- package/src/create-translation-adapter.d.ts +21 -0
- package/src/create-translation-adapter.d.ts.map +1 -0
- package/src/create-translation-adapter.js +37 -0
- package/src/create-translation-adapter.js.map +1 -0
- package/src/currency-code.d.ts +20 -0
- package/src/currency-code.d.ts.map +1 -0
- package/src/currency-code.js +37 -0
- package/src/currency-code.js.map +1 -0
- package/src/{currency-format.ts → currency-format.d.ts} +5 -5
- package/src/currency-format.d.ts.map +1 -0
- package/src/currency-format.js +3 -0
- package/src/currency-format.js.map +1 -0
- package/src/currency.d.ts +12 -0
- package/src/currency.d.ts.map +1 -0
- package/src/currency.js +49 -0
- package/src/currency.js.map +1 -0
- package/src/default-config.d.ts +33 -0
- package/src/default-config.d.ts.map +1 -0
- package/src/default-config.js +102 -0
- package/src/default-config.js.map +1 -0
- package/src/enum-registry.d.ts +45 -0
- package/src/enum-registry.d.ts.map +1 -0
- package/src/enum-registry.js +103 -0
- package/src/enum-registry.js.map +1 -0
- package/src/global-active-context.d.ts +51 -0
- package/src/global-active-context.d.ts.map +1 -0
- package/src/global-active-context.js +179 -0
- package/src/global-active-context.js.map +1 -0
- package/src/handleable.d.ts +14 -0
- package/src/handleable.d.ts.map +1 -0
- package/src/handleable.js +66 -0
- package/src/handleable.js.map +1 -0
- package/src/i-global-active-context.d.ts +23 -0
- package/src/i-global-active-context.d.ts.map +1 -0
- package/src/i-global-active-context.js +3 -0
- package/src/i-global-active-context.js.map +1 -0
- package/src/i-handleable-error-options.d.ts +7 -0
- package/src/i-handleable-error-options.d.ts.map +1 -0
- package/src/i-handleable-error-options.js +3 -0
- package/src/i-handleable-error-options.js.map +1 -0
- package/src/i-handleable.d.ts +6 -0
- package/src/i-handleable.d.ts.map +1 -0
- package/src/i-handleable.js +3 -0
- package/src/i-handleable.js.map +1 -0
- package/src/i18n-config.d.ts +21 -0
- package/src/i18n-config.d.ts.map +1 -0
- package/src/i18n-config.js +3 -0
- package/src/i18n-config.js.map +1 -0
- package/src/{i18n-context.ts → i18n-context.d.ts} +7 -7
- package/src/i18n-context.d.ts.map +1 -0
- package/src/i18n-context.js +3 -0
- package/src/i18n-context.js.map +1 -0
- package/src/i18n-engine.d.ts +179 -0
- package/src/i18n-engine.d.ts.map +1 -0
- package/src/i18n-engine.js +355 -0
- package/src/i18n-engine.js.map +1 -0
- package/src/{index.ts → index.d.ts} +2 -10
- package/src/index.d.ts.map +1 -0
- package/src/index.js +71 -0
- package/src/index.js.map +1 -0
- package/src/{language-codes.ts → language-codes.d.ts} +12 -23
- package/src/language-codes.d.ts.map +1 -0
- package/src/language-codes.js +32 -0
- package/src/language-codes.js.map +1 -0
- package/src/language-definition.d.ts +14 -0
- package/src/language-definition.d.ts.map +1 -0
- package/src/language-definition.js +3 -0
- package/src/language-definition.js.map +1 -0
- package/src/language-registry.d.ts +114 -0
- package/src/language-registry.d.ts.map +1 -0
- package/src/language-registry.js +217 -0
- package/src/language-registry.js.map +1 -0
- package/src/plugin-i18n-engine.d.ts +147 -0
- package/src/plugin-i18n-engine.d.ts.map +1 -0
- package/src/plugin-i18n-engine.js +369 -0
- package/src/plugin-i18n-engine.js.map +1 -0
- package/src/plugin-translatable-generic-error.d.ts +30 -0
- package/src/plugin-translatable-generic-error.d.ts.map +1 -0
- package/src/plugin-translatable-generic-error.js +72 -0
- package/src/plugin-translatable-generic-error.js.map +1 -0
- package/src/plugin-translatable-handleable-generic.d.ts +29 -0
- package/src/plugin-translatable-handleable-generic.d.ts.map +1 -0
- package/src/plugin-translatable-handleable-generic.js +44 -0
- package/src/plugin-translatable-handleable-generic.js.map +1 -0
- package/src/plugin-typed-handleable.d.ts +15 -0
- package/src/plugin-typed-handleable.d.ts.map +1 -0
- package/src/plugin-typed-handleable.js +51 -0
- package/src/plugin-typed-handleable.js.map +1 -0
- package/src/registry-config.d.ts +15 -0
- package/src/registry-config.d.ts.map +1 -0
- package/src/registry-config.js +3 -0
- package/src/registry-config.js.map +1 -0
- package/src/registry-error-type.d.ts +13 -0
- package/src/registry-error-type.d.ts.map +1 -0
- package/src/registry-error-type.js +17 -0
- package/src/registry-error-type.js.map +1 -0
- package/src/registry-error.d.ts +19 -0
- package/src/registry-error.d.ts.map +1 -0
- package/src/registry-error.js +48 -0
- package/src/registry-error.js.map +1 -0
- package/src/strict-types.d.ts +19 -0
- package/src/strict-types.d.ts.map +1 -0
- package/src/strict-types.js +18 -0
- package/src/strict-types.js.map +1 -0
- package/src/template.d.ts +13 -0
- package/src/template.d.ts.map +1 -0
- package/src/template.js +31 -0
- package/src/template.js.map +1 -0
- package/src/timezone.d.ts +12 -0
- package/src/timezone.d.ts.map +1 -0
- package/src/timezone.js +24 -0
- package/src/timezone.js.map +1 -0
- package/src/translatable.d.ts +6 -0
- package/src/translatable.d.ts.map +1 -0
- package/src/translatable.js +12 -0
- package/src/translatable.js.map +1 -0
- package/src/translation-engine.d.ts +9 -0
- package/src/translation-engine.d.ts.map +1 -0
- package/src/translation-engine.js +3 -0
- package/src/translation-engine.js.map +1 -0
- package/src/translation-request.d.ts +10 -0
- package/src/translation-request.d.ts.map +1 -0
- package/src/translation-request.js +3 -0
- package/src/translation-request.js.map +1 -0
- package/src/translation-response.d.ts +9 -0
- package/src/translation-response.d.ts.map +1 -0
- package/src/translation-response.js +3 -0
- package/src/translation-response.js.map +1 -0
- package/src/typed-error.d.ts +73 -0
- package/src/typed-error.d.ts.map +1 -0
- package/src/typed-error.js +267 -0
- package/src/typed-error.js.map +1 -0
- package/src/typed-handleable.d.ts +15 -0
- package/src/typed-handleable.d.ts.map +1 -0
- package/src/typed-handleable.js +46 -0
- package/src/typed-handleable.js.map +1 -0
- package/src/{types.ts → types.d.ts} +21 -75
- package/src/types.d.ts.map +1 -0
- package/src/types.js +19 -0
- package/src/types.js.map +1 -0
- package/src/unified-translator.d.ts +31 -0
- package/src/unified-translator.d.ts.map +1 -0
- package/src/unified-translator.js +71 -0
- package/src/unified-translator.js.map +1 -0
- package/src/utils.d.ts +65 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +129 -0
- package/src/utils.js.map +1 -0
- package/src/validation-config.d.ts +12 -0
- package/src/validation-config.d.ts.map +1 -0
- package/src/validation-config.js +3 -0
- package/src/validation-config.js.map +1 -0
- package/src/validation-result.d.ts +13 -0
- package/src/validation-result.d.ts.map +1 -0
- package/src/validation-result.js +3 -0
- package/src/validation-result.js.map +1 -0
- package/LICENSE +0 -21
- package/src/active-context.ts +0 -30
- package/src/component-definition.ts +0 -11
- package/src/component-registration.ts +0 -13
- package/src/component-registry.ts +0 -392
- package/src/context-error-type.ts +0 -3
- package/src/context-error.ts +0 -16
- package/src/context-manager.ts +0 -71
- package/src/context.ts +0 -90
- package/src/core-i18n.ts +0 -609
- package/src/core-string-key.ts +0 -49
- package/src/create-translation-adapter.ts +0 -47
- package/src/currency-code.ts +0 -35
- package/src/currency.ts +0 -52
- package/src/default-config.ts +0 -199
- package/src/enum-registry.ts +0 -138
- package/src/global-active-context.ts +0 -255
- package/src/handleable.ts +0 -79
- package/src/i-global-active-context.ts +0 -59
- package/src/i-handleable-error-options.ts +0 -6
- package/src/i-handleable.ts +0 -5
- package/src/i18n-config.ts +0 -29
- package/src/i18n-engine.ts +0 -491
- package/src/language-definition.ts +0 -13
- package/src/language-registry.ts +0 -292
- package/src/plugin-i18n-engine.ts +0 -520
- package/src/plugin-translatable-generic-error.ts +0 -106
- package/src/plugin-translatable-handleable-generic.ts +0 -60
- package/src/plugin-typed-handleable.ts +0 -77
- package/src/registry-config.ts +0 -15
- package/src/registry-error-type.ts +0 -12
- package/src/registry-error.ts +0 -74
- package/src/strict-types.ts +0 -35
- package/src/template.ts +0 -63
- package/src/timezone.ts +0 -20
- package/src/translatable.ts +0 -15
- package/src/translation-engine.ts +0 -8
- package/src/translation-request.ts +0 -12
- package/src/translation-response.ts +0 -8
- package/src/typed-error.ts +0 -384
- package/src/typed-handleable.ts +0 -70
- package/src/unified-translator.ts +0 -96
- package/src/utils.ts +0 -213
- package/src/validation-config.ts +0 -11
- package/src/validation-result.ts +0 -12
package/src/language-registry.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language registry for managing supported languages and their properties
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { LanguageDefinition } from './language-definition';
|
|
6
|
-
import { RegistryError } from './registry-error';
|
|
7
|
-
import { RegistryErrorType } from './registry-error-type';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Static singleton registry for managing supported languages globally
|
|
11
|
-
*/
|
|
12
|
-
export class LanguageRegistry {
|
|
13
|
-
private static languages = new Map<string, LanguageDefinition>();
|
|
14
|
-
private static languagesByCodes = new Map<string, string>();
|
|
15
|
-
private static defaultLanguageId: string | null = null;
|
|
16
|
-
|
|
17
|
-
private constructor() {
|
|
18
|
-
// Private constructor - use static methods
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Register a new language
|
|
23
|
-
*/
|
|
24
|
-
public static registerLanguage(language: LanguageDefinition): void {
|
|
25
|
-
const languageId = language.id;
|
|
26
|
-
|
|
27
|
-
// Check for duplicate language ID
|
|
28
|
-
if (LanguageRegistry.languages.has(languageId)) {
|
|
29
|
-
throw RegistryError.createSimple(
|
|
30
|
-
RegistryErrorType.DuplicateLanguage,
|
|
31
|
-
`Language '${languageId}' is already registered`,
|
|
32
|
-
{ languageId },
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Check for duplicate language code
|
|
37
|
-
if (LanguageRegistry.languagesByCodes.has(language.code)) {
|
|
38
|
-
const existingLanguageId = LanguageRegistry.languagesByCodes.get(language.code)!;
|
|
39
|
-
throw RegistryError.createSimple(
|
|
40
|
-
RegistryErrorType.DuplicateLanguage,
|
|
41
|
-
`Language code '${language.code}' is already used by language '${existingLanguageId}'`,
|
|
42
|
-
{ languageId, code: language.code, existingLanguageId },
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Register the language
|
|
47
|
-
LanguageRegistry.languages.set(languageId, language);
|
|
48
|
-
LanguageRegistry.languagesByCodes.set(language.code, languageId);
|
|
49
|
-
|
|
50
|
-
// Set as default if specified or if it's the first language
|
|
51
|
-
if (language.isDefault || LanguageRegistry.defaultLanguageId === null) {
|
|
52
|
-
LanguageRegistry.defaultLanguageId = languageId;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Register multiple languages at once
|
|
58
|
-
*/
|
|
59
|
-
public static registerLanguages(languages: readonly LanguageDefinition[]): void {
|
|
60
|
-
for (const language of languages) {
|
|
61
|
-
LanguageRegistry.registerLanguage(language);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get a language by its ID
|
|
67
|
-
*/
|
|
68
|
-
public static getLanguage(languageId: string): LanguageDefinition | undefined {
|
|
69
|
-
return LanguageRegistry.languages.get(languageId);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get a language by its code
|
|
74
|
-
*/
|
|
75
|
-
public static getLanguageByCode(code: string): LanguageDefinition | undefined {
|
|
76
|
-
const languageId = LanguageRegistry.languagesByCodes.get(code);
|
|
77
|
-
return languageId ? LanguageRegistry.languages.get(languageId) : undefined;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get all registered languages
|
|
82
|
-
*/
|
|
83
|
-
public static getAllLanguages(): ReadonlyArray<LanguageDefinition> {
|
|
84
|
-
return Array.from(LanguageRegistry.languages.values());
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get all language IDs
|
|
89
|
-
*/
|
|
90
|
-
public static getLanguageIds(): readonly string[] {
|
|
91
|
-
return Array.from(LanguageRegistry.languages.keys());
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get all language codes
|
|
96
|
-
*/
|
|
97
|
-
public static getLanguageCodes(): readonly string[] {
|
|
98
|
-
return Array.from(LanguageRegistry.languagesByCodes.keys());
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Check if a language is registered
|
|
103
|
-
*/
|
|
104
|
-
public static hasLanguage(languageId: string): boolean {
|
|
105
|
-
return LanguageRegistry.languages.has(languageId);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Check if a language code is registered
|
|
110
|
-
*/
|
|
111
|
-
public static hasLanguageCode(code: string): boolean {
|
|
112
|
-
return LanguageRegistry.languagesByCodes.has(code);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Get the default language
|
|
117
|
-
*/
|
|
118
|
-
public static getDefaultLanguage(): LanguageDefinition | null {
|
|
119
|
-
return LanguageRegistry.defaultLanguageId
|
|
120
|
-
? LanguageRegistry.languages.get(LanguageRegistry.defaultLanguageId) || null
|
|
121
|
-
: null;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Get the default language ID
|
|
126
|
-
*/
|
|
127
|
-
public static getDefaultLanguageId(): string | null {
|
|
128
|
-
return LanguageRegistry.defaultLanguageId;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Get matching language code with fallback logic:
|
|
133
|
-
* 1. Try requested code
|
|
134
|
-
* 2. Fall back to user default
|
|
135
|
-
* 3. Fall back to site default
|
|
136
|
-
*/
|
|
137
|
-
public static getMatchingLanguageCode(
|
|
138
|
-
requestedCode?: string,
|
|
139
|
-
userDefaultCode?: string,
|
|
140
|
-
): string {
|
|
141
|
-
// Try requested code first
|
|
142
|
-
if (requestedCode && LanguageRegistry.hasLanguageCode(requestedCode)) {
|
|
143
|
-
return requestedCode;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Try user default
|
|
147
|
-
if (userDefaultCode && LanguageRegistry.hasLanguageCode(userDefaultCode)) {
|
|
148
|
-
return userDefaultCode;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Fall back to site default
|
|
152
|
-
const defaultLanguage = LanguageRegistry.getDefaultLanguage();
|
|
153
|
-
if (!defaultLanguage) {
|
|
154
|
-
throw RegistryError.createSimple(
|
|
155
|
-
RegistryErrorType.LanguageNotFound,
|
|
156
|
-
'No default language configured',
|
|
157
|
-
{},
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return defaultLanguage.code;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Set the default language
|
|
166
|
-
*/
|
|
167
|
-
public static setDefaultLanguage(languageId: string): void {
|
|
168
|
-
if (!LanguageRegistry.languages.has(languageId)) {
|
|
169
|
-
throw RegistryError.createSimple(
|
|
170
|
-
RegistryErrorType.LanguageNotFound,
|
|
171
|
-
`Language '${languageId}' not found`,
|
|
172
|
-
{ languageId },
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
LanguageRegistry.defaultLanguageId = languageId;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Get the number of registered languages
|
|
180
|
-
*/
|
|
181
|
-
public static getLanguageCount(): number {
|
|
182
|
-
return LanguageRegistry.languages.size;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Validate that all required languages are present
|
|
187
|
-
*/
|
|
188
|
-
public static validateRequiredLanguages(
|
|
189
|
-
requiredLanguages: readonly string[],
|
|
190
|
-
): LanguageValidationResult {
|
|
191
|
-
const missingLanguages: string[] = [];
|
|
192
|
-
const errors: string[] = [];
|
|
193
|
-
|
|
194
|
-
for (const languageId of requiredLanguages) {
|
|
195
|
-
if (!LanguageRegistry.languages.has(languageId)) {
|
|
196
|
-
missingLanguages.push(languageId);
|
|
197
|
-
errors.push(`Required language '${languageId}' is not registered`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return {
|
|
202
|
-
isValid: missingLanguages.length === 0,
|
|
203
|
-
missingLanguages,
|
|
204
|
-
errors,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Create a mapping of language IDs to their display names
|
|
210
|
-
*/
|
|
211
|
-
public static getLanguageDisplayNames(): Record<string, string> {
|
|
212
|
-
const result: Record<string, string> = {};
|
|
213
|
-
for (const [languageId, language] of LanguageRegistry.languages) {
|
|
214
|
-
result[languageId] = language.name;
|
|
215
|
-
}
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Create a mapping of language IDs to their codes
|
|
221
|
-
*/
|
|
222
|
-
public static getLanguageCodeMapping(): Record<string, string> {
|
|
223
|
-
const result: Record<string, string> = {};
|
|
224
|
-
for (const [languageId, language] of LanguageRegistry.languages) {
|
|
225
|
-
result[languageId] = language.code;
|
|
226
|
-
}
|
|
227
|
-
return result;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Find languages by partial name match (case-insensitive)
|
|
232
|
-
*/
|
|
233
|
-
public static findLanguagesByName(
|
|
234
|
-
partialName: string,
|
|
235
|
-
): readonly LanguageDefinition[] {
|
|
236
|
-
const searchTerm = partialName.toLowerCase();
|
|
237
|
-
return Array.from(LanguageRegistry.languages.values()).filter((language) =>
|
|
238
|
-
language.name.toLowerCase().includes(searchTerm),
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Clear all registered languages (useful for testing)
|
|
244
|
-
*/
|
|
245
|
-
public static clear(): void {
|
|
246
|
-
LanguageRegistry.languages.clear();
|
|
247
|
-
LanguageRegistry.languagesByCodes.clear();
|
|
248
|
-
LanguageRegistry.defaultLanguageId = null;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Validation result for language operations
|
|
254
|
-
*/
|
|
255
|
-
export interface LanguageValidationResult {
|
|
256
|
-
readonly isValid: boolean;
|
|
257
|
-
readonly missingLanguages: readonly string[];
|
|
258
|
-
readonly errors: readonly string[];
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Helper function to create language definitions with type safety
|
|
263
|
-
*/
|
|
264
|
-
export function createLanguageDefinition(
|
|
265
|
-
id: string,
|
|
266
|
-
name: string,
|
|
267
|
-
code: string,
|
|
268
|
-
isDefault?: boolean,
|
|
269
|
-
): LanguageDefinition {
|
|
270
|
-
return {
|
|
271
|
-
id,
|
|
272
|
-
name,
|
|
273
|
-
code,
|
|
274
|
-
isDefault: isDefault || false,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Helper function to create multiple language definitions
|
|
280
|
-
*/
|
|
281
|
-
export function createLanguageDefinitions(
|
|
282
|
-
languages: Array<{
|
|
283
|
-
id: string;
|
|
284
|
-
name: string;
|
|
285
|
-
code: string;
|
|
286
|
-
isDefault?: boolean;
|
|
287
|
-
}>,
|
|
288
|
-
): LanguageDefinition[] {
|
|
289
|
-
return languages.map((lang) =>
|
|
290
|
-
createLanguageDefinition(lang.id, lang.name, lang.code, lang.isDefault),
|
|
291
|
-
);
|
|
292
|
-
}
|