@lokascript/i18n 1.0.0
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 +286 -0
- package/dist/browser.cjs +7669 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +50 -0
- package/dist/browser.d.ts +50 -0
- package/dist/browser.js +7592 -0
- package/dist/browser.js.map +1 -0
- package/dist/hyperfixi-i18n.min.js +2 -0
- package/dist/hyperfixi-i18n.min.js.map +1 -0
- package/dist/hyperfixi-i18n.mjs +8558 -0
- package/dist/hyperfixi-i18n.mjs.map +1 -0
- package/dist/index.cjs +14205 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +947 -0
- package/dist/index.d.ts +947 -0
- package/dist/index.js +14095 -0
- package/dist/index.js.map +1 -0
- package/dist/transformer-Ckask-yw.d.cts +1041 -0
- package/dist/transformer-Ckask-yw.d.ts +1041 -0
- package/package.json +84 -0
- package/src/browser.ts +122 -0
- package/src/compatibility/browser-tests/grammar-demo.spec.ts +169 -0
- package/src/constants.ts +366 -0
- package/src/dictionaries/ar.ts +233 -0
- package/src/dictionaries/bn.ts +156 -0
- package/src/dictionaries/de.ts +233 -0
- package/src/dictionaries/derive.ts +515 -0
- package/src/dictionaries/en.ts +237 -0
- package/src/dictionaries/es.ts +233 -0
- package/src/dictionaries/fr.ts +233 -0
- package/src/dictionaries/hi.ts +270 -0
- package/src/dictionaries/id.ts +233 -0
- package/src/dictionaries/index.ts +238 -0
- package/src/dictionaries/it.ts +233 -0
- package/src/dictionaries/ja.ts +233 -0
- package/src/dictionaries/ko.ts +233 -0
- package/src/dictionaries/ms.ts +276 -0
- package/src/dictionaries/pl.ts +239 -0
- package/src/dictionaries/pt.ts +237 -0
- package/src/dictionaries/qu.ts +233 -0
- package/src/dictionaries/ru.ts +270 -0
- package/src/dictionaries/sw.ts +233 -0
- package/src/dictionaries/th.ts +156 -0
- package/src/dictionaries/tl.ts +276 -0
- package/src/dictionaries/tr.ts +233 -0
- package/src/dictionaries/uk.ts +270 -0
- package/src/dictionaries/vi.ts +210 -0
- package/src/dictionaries/zh.ts +233 -0
- package/src/enhanced-i18n.test.ts +454 -0
- package/src/enhanced-i18n.ts +713 -0
- package/src/examples/new-languages.ts +326 -0
- package/src/formatting.test.ts +213 -0
- package/src/formatting.ts +416 -0
- package/src/grammar/direct-mappings.ts +353 -0
- package/src/grammar/grammar.test.ts +1053 -0
- package/src/grammar/index.ts +59 -0
- package/src/grammar/profiles/index.ts +860 -0
- package/src/grammar/transformer.ts +1318 -0
- package/src/grammar/types.ts +630 -0
- package/src/index.ts +202 -0
- package/src/new-languages.test.ts +389 -0
- package/src/parser/analyze-conflicts.test.ts +229 -0
- package/src/parser/ar.ts +40 -0
- package/src/parser/create-provider.ts +309 -0
- package/src/parser/de.ts +36 -0
- package/src/parser/es.ts +31 -0
- package/src/parser/fr.ts +31 -0
- package/src/parser/id.ts +34 -0
- package/src/parser/index.ts +50 -0
- package/src/parser/ja.ts +36 -0
- package/src/parser/ko.ts +37 -0
- package/src/parser/locale-manager.test.ts +198 -0
- package/src/parser/locale-manager.ts +197 -0
- package/src/parser/parser-integration.test.ts +439 -0
- package/src/parser/pt.ts +37 -0
- package/src/parser/qu.ts +37 -0
- package/src/parser/sw.ts +37 -0
- package/src/parser/tr.ts +38 -0
- package/src/parser/types.ts +113 -0
- package/src/parser/zh.ts +38 -0
- package/src/plugins/vite.ts +224 -0
- package/src/plugins/webpack.ts +124 -0
- package/src/pluralization.test.ts +197 -0
- package/src/pluralization.ts +393 -0
- package/src/runtime.ts +441 -0
- package/src/ssr-integration.ts +225 -0
- package/src/test-setup.ts +195 -0
- package/src/translation-validation.test.ts +171 -0
- package/src/translator.test.ts +252 -0
- package/src/translator.ts +297 -0
- package/src/types.ts +209 -0
- package/src/utils/locale.ts +190 -0
- package/src/utils/tokenizer-adapter.ts +469 -0
- package/src/utils/tokenizer.ts +19 -0
- package/src/validators/index.ts +174 -0
- package/src/validators/schema.ts +129 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
import { ai as I18nConfig, aj as TranslationOptions, ak as TranslationResult, al as Dictionary, am as ValidationResult$1, an as Token } from './transformer-Ckask-yw.cjs';
|
|
2
|
+
export { D as AdpositionType, au as DICTIONARY_CATEGORIES, ao as DictionaryCategory, E as ENGLISH_COMMANDS, d as ENGLISH_KEYWORDS, H as GrammarRule, ac as GrammarTransformer, G as GrammaticalMarker, K as KeywordProvider, a as KeywordProviderOptions, Q as LANGUAGE_FAMILY_DEFAULTS, F as LanguageProfile, L as LocaleManager, ar as LocaleMetadata, M as MorphologyType, N as ParsedElement, J as ParsedStatement, P as PatternMatcher, I as PatternTransform, S as SemanticRole, at as TokenType, as as TranslationContext, U as UNIVERSAL_ENGLISH_KEYWORDS, O as UNIVERSAL_PATTERNS, ap as ValidationError, aq as ValidationWarning, W as WordOrder, n as arDictionary, m as arKeywords, a3 as arabicProfile, a2 as chineseProfile, b as createEnglishProvider, c as createKeywordProvider, l as deDictionary, k as deKeywords, C as detectBrowserLocale, $ as englishProfile, f as esDictionary, e as esKeywords, ay as findInDictionary, ax as forEachCategory, i as frDictionary, h as frKeywords, aw as getDictionaryCategory, Z as getProfile, _ as getSupportedLocales, ah as grammarExamples, u as idDictionary, s as idKeywords, a9 as indonesianProfile, T as insertMarkers, av as isDictionaryCategory, g as jaDictionary, j as jaKeywords, a0 as japaneseProfile, p as koDictionary, o as koKeywords, a1 as koreanProfile, ad as parseStatement, Y as profiles, B as ptDictionary, A as ptKeywords, w as quDictionary, v as quKeywords, aa as quechuaProfile, R as reorderRoles, a5 as spanishProfile, y as swDictionary, x as swKeywords, ab as swahiliProfile, af as toEnglish, ae as toLocale, r as trDictionary, t as trKeywords, X as transformStatement, ag as translate, az as translateFromEnglish, a4 as turkishProfile, q as zhDictionary, z as zhKeywords } from './transformer-Ckask-yw.cjs';
|
|
3
|
+
import { Plugin } from 'vite';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
declare class HyperscriptTranslator {
|
|
7
|
+
private config;
|
|
8
|
+
private dictionaries;
|
|
9
|
+
private reverseDictionaries;
|
|
10
|
+
constructor(config: I18nConfig);
|
|
11
|
+
translate(text: string, options: TranslationOptions): string;
|
|
12
|
+
translateWithDetails(text: string, options: TranslationOptions): TranslationResult;
|
|
13
|
+
private translateTokens;
|
|
14
|
+
private findTranslation;
|
|
15
|
+
private isTranslatableToken;
|
|
16
|
+
private reconstructText;
|
|
17
|
+
detectLanguage(text: string): string;
|
|
18
|
+
addDictionary(locale: string, dictionary: Dictionary): void;
|
|
19
|
+
getDictionary(locale: string): Dictionary | undefined;
|
|
20
|
+
private getReverseDictionary;
|
|
21
|
+
getSupportedLocales(): string[];
|
|
22
|
+
validateDictionary(locale: string): ValidationResult$1;
|
|
23
|
+
isRTL(locale: string): boolean;
|
|
24
|
+
getCompletions(context: {
|
|
25
|
+
text: string;
|
|
26
|
+
position: number;
|
|
27
|
+
locale: string;
|
|
28
|
+
}): string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Dictionary Index
|
|
33
|
+
*
|
|
34
|
+
* Exports dictionaries for all supported languages.
|
|
35
|
+
*
|
|
36
|
+
* Strategy: Dictionaries are derived from semantic profiles where possible,
|
|
37
|
+
* with fallbacks to manual definitions for categories not in profiles
|
|
38
|
+
* (events, temporal, some values, attributes).
|
|
39
|
+
*
|
|
40
|
+
* The semantic package's language profiles are the single source of truth
|
|
41
|
+
* for command/modifier/logical keyword translations.
|
|
42
|
+
*
|
|
43
|
+
* TRANSITION NOTE: Currently using full legacy overrides to preserve
|
|
44
|
+
* backward compatibility. Once profiles and dictionaries are synchronized,
|
|
45
|
+
* the legacy overrides can be reduced to only non-profile categories.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* English dictionary - uses legacy values for full compatibility.
|
|
50
|
+
*/
|
|
51
|
+
declare const en: Dictionary;
|
|
52
|
+
/**
|
|
53
|
+
* Spanish dictionary - legacy overrides for compatibility.
|
|
54
|
+
*/
|
|
55
|
+
declare const es: Dictionary;
|
|
56
|
+
/**
|
|
57
|
+
* Japanese dictionary - legacy overrides for compatibility.
|
|
58
|
+
*/
|
|
59
|
+
declare const ja: Dictionary;
|
|
60
|
+
/**
|
|
61
|
+
* Korean dictionary - legacy overrides for compatibility.
|
|
62
|
+
*/
|
|
63
|
+
declare const ko: Dictionary;
|
|
64
|
+
/**
|
|
65
|
+
* Chinese dictionary - legacy overrides for compatibility.
|
|
66
|
+
*/
|
|
67
|
+
declare const zh: Dictionary;
|
|
68
|
+
/**
|
|
69
|
+
* French dictionary - legacy overrides for compatibility.
|
|
70
|
+
*/
|
|
71
|
+
declare const fr: Dictionary;
|
|
72
|
+
/**
|
|
73
|
+
* German dictionary - legacy overrides for compatibility.
|
|
74
|
+
*/
|
|
75
|
+
declare const de: Dictionary;
|
|
76
|
+
/**
|
|
77
|
+
* Arabic dictionary - legacy overrides for compatibility.
|
|
78
|
+
*/
|
|
79
|
+
declare const ar: Dictionary;
|
|
80
|
+
/**
|
|
81
|
+
* Turkish dictionary - legacy overrides for compatibility.
|
|
82
|
+
*/
|
|
83
|
+
declare const tr: Dictionary;
|
|
84
|
+
/**
|
|
85
|
+
* Indonesian dictionary - legacy overrides for compatibility.
|
|
86
|
+
*/
|
|
87
|
+
declare const id: Dictionary;
|
|
88
|
+
/**
|
|
89
|
+
* Portuguese dictionary - legacy overrides for compatibility.
|
|
90
|
+
*/
|
|
91
|
+
declare const pt: Dictionary;
|
|
92
|
+
/**
|
|
93
|
+
* Quechua dictionary - legacy overrides for compatibility.
|
|
94
|
+
*/
|
|
95
|
+
declare const qu: Dictionary;
|
|
96
|
+
/**
|
|
97
|
+
* Swahili dictionary - legacy overrides for compatibility.
|
|
98
|
+
*/
|
|
99
|
+
declare const sw: Dictionary;
|
|
100
|
+
/**
|
|
101
|
+
* All available dictionaries indexed by locale code.
|
|
102
|
+
*/
|
|
103
|
+
declare const dictionaries: Record<string, Dictionary>;
|
|
104
|
+
/**
|
|
105
|
+
* Get all supported locale codes.
|
|
106
|
+
*/
|
|
107
|
+
declare const supportedLocales: string[];
|
|
108
|
+
/**
|
|
109
|
+
* Check if a locale is supported.
|
|
110
|
+
*/
|
|
111
|
+
declare const isLocaleSupported: (locale: string) => boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Get dictionary with fallback to another locale.
|
|
114
|
+
*/
|
|
115
|
+
declare const getDictionary: (locale: string, fallback?: string) => Dictionary | null;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Detect the language of hyperscript text
|
|
119
|
+
*/
|
|
120
|
+
declare function detectLocale(text: string, supportedLocales: string[]): string;
|
|
121
|
+
/**
|
|
122
|
+
* Get user's preferred locales from browser
|
|
123
|
+
*/
|
|
124
|
+
declare function getBrowserLocales(): string[];
|
|
125
|
+
/**
|
|
126
|
+
* Check if a locale uses RTL writing
|
|
127
|
+
*/
|
|
128
|
+
declare function isRTL(locale: string): boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Tokenizer Adapter
|
|
132
|
+
*
|
|
133
|
+
* Bridges the semantic package's sophisticated tokenizers to i18n's
|
|
134
|
+
* dictionary-based token categorization system.
|
|
135
|
+
*
|
|
136
|
+
* The semantic tokenizers handle:
|
|
137
|
+
* - Language-specific word boundaries
|
|
138
|
+
* - CSS selectors, URLs, string literals
|
|
139
|
+
* - Grammatical particles (を, に, من)
|
|
140
|
+
* - Morphological normalization
|
|
141
|
+
*
|
|
142
|
+
* This adapter converts semantic tokens to i18n tokens by:
|
|
143
|
+
* 1. Using semantic's tokenize() for sophisticated tokenization
|
|
144
|
+
* 2. Mapping TokenKind to TokenType via dictionary lookup for keywords
|
|
145
|
+
* 3. Preserving position information for round-trip support
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Tokenize input using semantic package's sophisticated tokenizers,
|
|
150
|
+
* converting to i18n-compatible tokens.
|
|
151
|
+
*
|
|
152
|
+
* Falls back to basic tokenization if:
|
|
153
|
+
* - Semantic package not loaded yet
|
|
154
|
+
* - Language not supported by semantic
|
|
155
|
+
* - Any error occurs
|
|
156
|
+
*
|
|
157
|
+
* For best performance, call initSemanticTokenizer() at app startup.
|
|
158
|
+
*/
|
|
159
|
+
declare function tokenize(text: string, locale: string): Token[];
|
|
160
|
+
|
|
161
|
+
declare function validate(dictionary: Dictionary, locale: string): ValidationResult$1;
|
|
162
|
+
|
|
163
|
+
interface HyperscriptI18nViteOptions {
|
|
164
|
+
sourceLocale?: string;
|
|
165
|
+
targetLocale?: string;
|
|
166
|
+
preserveOriginal?: boolean;
|
|
167
|
+
attributes?: string[];
|
|
168
|
+
include?: RegExp | string[];
|
|
169
|
+
exclude?: RegExp | string[];
|
|
170
|
+
}
|
|
171
|
+
declare function hyperscriptI18nVitePlugin(options?: HyperscriptI18nViteOptions): Plugin;
|
|
172
|
+
|
|
173
|
+
interface Compiler {
|
|
174
|
+
hooks: any;
|
|
175
|
+
webpack: any;
|
|
176
|
+
}
|
|
177
|
+
interface WebpackPluginInstance {
|
|
178
|
+
apply(compiler: Compiler): void;
|
|
179
|
+
}
|
|
180
|
+
interface HyperscriptI18nWebpackOptions {
|
|
181
|
+
sourceLocale?: string;
|
|
182
|
+
targetLocale?: string;
|
|
183
|
+
preserveOriginal?: boolean;
|
|
184
|
+
attributes?: string[];
|
|
185
|
+
test?: RegExp;
|
|
186
|
+
}
|
|
187
|
+
declare class HyperscriptI18nWebpackPlugin implements WebpackPluginInstance {
|
|
188
|
+
private options;
|
|
189
|
+
private translator;
|
|
190
|
+
constructor(options?: HyperscriptI18nWebpackOptions);
|
|
191
|
+
apply(compiler: Compiler): void;
|
|
192
|
+
private processAsset;
|
|
193
|
+
private processHtml;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* SSR integration for i18n support
|
|
198
|
+
*/
|
|
199
|
+
interface SSRLocaleContext {
|
|
200
|
+
locale: string;
|
|
201
|
+
direction: 'ltr' | 'rtl';
|
|
202
|
+
preferredLocales: string[];
|
|
203
|
+
userAgent?: string;
|
|
204
|
+
acceptLanguage?: string;
|
|
205
|
+
}
|
|
206
|
+
interface SSRLocaleOptions {
|
|
207
|
+
detectFromHeaders?: boolean;
|
|
208
|
+
detectFromUrl?: boolean;
|
|
209
|
+
fallbackLocale?: string;
|
|
210
|
+
supportedLocales?: string[];
|
|
211
|
+
urlPattern?: RegExp;
|
|
212
|
+
}
|
|
213
|
+
declare class SSRLocaleManager {
|
|
214
|
+
private translator;
|
|
215
|
+
private options;
|
|
216
|
+
constructor(translator: HyperscriptTranslator, options?: SSRLocaleOptions);
|
|
217
|
+
/**
|
|
218
|
+
* Extract locale from SSR request
|
|
219
|
+
*/
|
|
220
|
+
extractLocale(request: {
|
|
221
|
+
url?: string;
|
|
222
|
+
headers?: Record<string, string>;
|
|
223
|
+
userAgent?: string;
|
|
224
|
+
}): SSRLocaleContext;
|
|
225
|
+
/**
|
|
226
|
+
* Generate HTML lang and dir attributes
|
|
227
|
+
*/
|
|
228
|
+
generateHtmlAttributes(context: SSRLocaleContext): string;
|
|
229
|
+
/**
|
|
230
|
+
* Generate meta tags for SEO
|
|
231
|
+
*/
|
|
232
|
+
generateMetaTags(context: SSRLocaleContext, alternateUrls?: Record<string, string>): string[];
|
|
233
|
+
/**
|
|
234
|
+
* Translate hyperscript code for SSR
|
|
235
|
+
*/
|
|
236
|
+
translateForSSR(hyperscriptCode: string, targetLocale: string, options?: Partial<Omit<TranslationOptions, 'to'>>): string;
|
|
237
|
+
/**
|
|
238
|
+
* Generate client-side hydration data
|
|
239
|
+
*/
|
|
240
|
+
generateHydrationData(context: SSRLocaleContext): object;
|
|
241
|
+
private extractLocaleFromUrl;
|
|
242
|
+
private parseAcceptLanguage;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Express middleware for SSR i18n
|
|
246
|
+
*/
|
|
247
|
+
declare function createExpressI18nMiddleware(translator: HyperscriptTranslator, options?: SSRLocaleOptions): (req: any, _res: any, next: any) => void;
|
|
248
|
+
/**
|
|
249
|
+
* Next.js API for SSR i18n
|
|
250
|
+
*/
|
|
251
|
+
declare function withI18n(handler: any, translator: HyperscriptTranslator, options?: SSRLocaleOptions): (req: any, res: any) => Promise<any>;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Pluralization rules for different languages
|
|
255
|
+
*/
|
|
256
|
+
type PluralRule = (n: number) => 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
|
|
257
|
+
/**
|
|
258
|
+
* Pluralization rules based on Unicode CLDR
|
|
259
|
+
*/
|
|
260
|
+
declare const pluralRules: Record<string, PluralRule>;
|
|
261
|
+
/**
|
|
262
|
+
* Plural forms for hyperscript keywords
|
|
263
|
+
*/
|
|
264
|
+
interface PluralForms {
|
|
265
|
+
zero?: string;
|
|
266
|
+
one?: string;
|
|
267
|
+
two?: string;
|
|
268
|
+
few?: string;
|
|
269
|
+
many?: string;
|
|
270
|
+
other: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get the appropriate plural form for a locale and count
|
|
274
|
+
*/
|
|
275
|
+
declare function getPlural(locale: string, count: number, forms: PluralForms): string;
|
|
276
|
+
/**
|
|
277
|
+
* Plural-aware translation for time expressions
|
|
278
|
+
*/
|
|
279
|
+
declare const pluralTimeExpressions: Record<string, Record<string, PluralForms>>;
|
|
280
|
+
/**
|
|
281
|
+
* Enhanced translator with pluralization support
|
|
282
|
+
*/
|
|
283
|
+
declare class PluralAwareTranslator {
|
|
284
|
+
/**
|
|
285
|
+
* Translate time expressions with proper pluralization
|
|
286
|
+
*/
|
|
287
|
+
static translateTimeExpression(value: number, unit: string, locale: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Parse and translate plural-aware hyperscript time expressions
|
|
290
|
+
*/
|
|
291
|
+
static translateHyperscriptTime(text: string, locale: string): string;
|
|
292
|
+
/**
|
|
293
|
+
* Get ordinal numbers (1st, 2nd, 3rd) in different languages
|
|
294
|
+
*/
|
|
295
|
+
static getOrdinal(n: number, locale: string): string;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Locale-aware formatting utilities for i18n
|
|
300
|
+
*/
|
|
301
|
+
interface NumberFormatOptions {
|
|
302
|
+
style?: 'decimal' | 'currency' | 'percent';
|
|
303
|
+
currency?: string;
|
|
304
|
+
minimumFractionDigits?: number;
|
|
305
|
+
maximumFractionDigits?: number;
|
|
306
|
+
useGrouping?: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface DateFormatOptions {
|
|
309
|
+
dateStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
310
|
+
timeStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
311
|
+
year?: 'numeric' | '2-digit';
|
|
312
|
+
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
|
|
313
|
+
day?: 'numeric' | '2-digit';
|
|
314
|
+
hour?: 'numeric' | '2-digit';
|
|
315
|
+
minute?: 'numeric' | '2-digit';
|
|
316
|
+
second?: 'numeric' | '2-digit';
|
|
317
|
+
timeZone?: string;
|
|
318
|
+
}
|
|
319
|
+
interface RelativeTimeFormatOptions {
|
|
320
|
+
style?: 'long' | 'short' | 'narrow';
|
|
321
|
+
numeric?: 'always' | 'auto';
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Format numbers according to locale
|
|
325
|
+
*/
|
|
326
|
+
declare class NumberFormatter {
|
|
327
|
+
private locale;
|
|
328
|
+
private defaultOptions;
|
|
329
|
+
constructor(locale: string, defaultOptions?: NumberFormatOptions);
|
|
330
|
+
format(value: number, options?: NumberFormatOptions): string;
|
|
331
|
+
formatCurrency(value: number, currency: string, options?: Omit<NumberFormatOptions, 'style' | 'currency'>): string;
|
|
332
|
+
formatPercent(value: number, options?: Omit<NumberFormatOptions, 'style'>): string;
|
|
333
|
+
private fallbackFormat;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Format dates according to locale
|
|
337
|
+
*/
|
|
338
|
+
declare class DateFormatter {
|
|
339
|
+
private locale;
|
|
340
|
+
private defaultOptions;
|
|
341
|
+
constructor(locale: string, defaultOptions?: DateFormatOptions);
|
|
342
|
+
format(date: Date | string | number, options?: DateFormatOptions): string;
|
|
343
|
+
formatRelative(date: Date | string | number, options?: RelativeTimeFormatOptions): string;
|
|
344
|
+
private fallbackFormat;
|
|
345
|
+
private fallbackRelativeFormat;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Locale-aware formatting manager
|
|
349
|
+
*/
|
|
350
|
+
declare class LocaleFormatter {
|
|
351
|
+
private locale;
|
|
352
|
+
private numberFormatter;
|
|
353
|
+
private dateFormatter;
|
|
354
|
+
constructor(locale: string);
|
|
355
|
+
formatNumber(value: number, options?: NumberFormatOptions): string;
|
|
356
|
+
formatCurrency(value: number, currency: string, options?: Omit<NumberFormatOptions, 'style' | 'currency'>): string;
|
|
357
|
+
formatPercent(value: number, options?: Omit<NumberFormatOptions, 'style'>): string;
|
|
358
|
+
formatDate(date: Date | string | number, options?: DateFormatOptions): string;
|
|
359
|
+
formatRelativeTime(date: Date | string | number, options?: RelativeTimeFormatOptions): string;
|
|
360
|
+
formatHyperscriptValue(value: any, type?: string): string;
|
|
361
|
+
formatList(items: string[], options?: {
|
|
362
|
+
style?: 'long' | 'short' | 'narrow';
|
|
363
|
+
type?: 'conjunction' | 'disjunction' | 'unit';
|
|
364
|
+
}): string;
|
|
365
|
+
formatUnit(value: number, unit: string, options?: {
|
|
366
|
+
style?: 'long' | 'short' | 'narrow';
|
|
367
|
+
}): string;
|
|
368
|
+
setLocale(locale: string): void;
|
|
369
|
+
getLocale(): string;
|
|
370
|
+
}
|
|
371
|
+
declare function getFormatter(locale: string): LocaleFormatter;
|
|
372
|
+
declare function formatForLocale(locale: string, value: any, type?: string): string;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Runtime i18n manager for client-side locale switching
|
|
376
|
+
*/
|
|
377
|
+
interface RuntimeI18nOptions extends I18nConfig {
|
|
378
|
+
autoDetect?: boolean;
|
|
379
|
+
storageKey?: string;
|
|
380
|
+
urlParam?: string;
|
|
381
|
+
cookieName?: string;
|
|
382
|
+
updateURL?: boolean;
|
|
383
|
+
updateTitle?: boolean;
|
|
384
|
+
updateLang?: boolean;
|
|
385
|
+
updateDir?: boolean;
|
|
386
|
+
}
|
|
387
|
+
declare class RuntimeI18nManager {
|
|
388
|
+
private translator;
|
|
389
|
+
private options;
|
|
390
|
+
private currentLocale;
|
|
391
|
+
private observers;
|
|
392
|
+
private initialized;
|
|
393
|
+
constructor(options?: Partial<RuntimeI18nOptions>);
|
|
394
|
+
/**
|
|
395
|
+
* Initialize the runtime i18n system
|
|
396
|
+
*/
|
|
397
|
+
initialize(): Promise<void>;
|
|
398
|
+
/**
|
|
399
|
+
* Set the current locale
|
|
400
|
+
*/
|
|
401
|
+
setLocale(locale: string, updateStorage?: boolean): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Get the current locale
|
|
404
|
+
*/
|
|
405
|
+
getLocale(): string;
|
|
406
|
+
/**
|
|
407
|
+
* Get supported locales
|
|
408
|
+
*/
|
|
409
|
+
getSupportedLocales(): string[];
|
|
410
|
+
/**
|
|
411
|
+
* Check if a locale is RTL
|
|
412
|
+
*/
|
|
413
|
+
isRTL(locale?: string): boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Translate a hyperscript string
|
|
416
|
+
*/
|
|
417
|
+
translate(text: string, options?: Partial<TranslationOptions>): string;
|
|
418
|
+
/**
|
|
419
|
+
* Format a value according to current locale
|
|
420
|
+
*/
|
|
421
|
+
format(value: any, type?: string): string;
|
|
422
|
+
/**
|
|
423
|
+
* Add dictionary for a locale
|
|
424
|
+
*/
|
|
425
|
+
addDictionary(locale: string, dictionary: Dictionary): void;
|
|
426
|
+
/**
|
|
427
|
+
* Subscribe to locale changes
|
|
428
|
+
*/
|
|
429
|
+
onLocaleChange(callback: (locale: string) => void): () => void;
|
|
430
|
+
/**
|
|
431
|
+
* Create a locale switcher element
|
|
432
|
+
*/
|
|
433
|
+
createLocaleSwitcher(options?: {
|
|
434
|
+
type?: 'dropdown' | 'buttons';
|
|
435
|
+
className?: string;
|
|
436
|
+
showNativeNames?: boolean;
|
|
437
|
+
}): HTMLElement;
|
|
438
|
+
/**
|
|
439
|
+
* Detect initial locale from various sources
|
|
440
|
+
*/
|
|
441
|
+
private detectInitialLocale;
|
|
442
|
+
/**
|
|
443
|
+
* Save locale to storage
|
|
444
|
+
*/
|
|
445
|
+
private saveLocaleToStorage;
|
|
446
|
+
/**
|
|
447
|
+
* Update URL with current locale
|
|
448
|
+
*/
|
|
449
|
+
private updateURL;
|
|
450
|
+
/**
|
|
451
|
+
* Update document attributes
|
|
452
|
+
*/
|
|
453
|
+
private updateDocumentAttributes;
|
|
454
|
+
/**
|
|
455
|
+
* Translate the entire page
|
|
456
|
+
*/
|
|
457
|
+
private translatePage;
|
|
458
|
+
/**
|
|
459
|
+
* Set up event listeners
|
|
460
|
+
*/
|
|
461
|
+
private setupEventListeners;
|
|
462
|
+
/**
|
|
463
|
+
* Notify observers of locale change
|
|
464
|
+
*/
|
|
465
|
+
private notifyObservers;
|
|
466
|
+
/**
|
|
467
|
+
* Get locale display name
|
|
468
|
+
*/
|
|
469
|
+
private getLocaleDisplayName;
|
|
470
|
+
/**
|
|
471
|
+
* Cookie utilities
|
|
472
|
+
*/
|
|
473
|
+
private getCookie;
|
|
474
|
+
private setCookie;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Global runtime instance
|
|
478
|
+
*/
|
|
479
|
+
declare let runtimeI18n: RuntimeI18nManager | null;
|
|
480
|
+
/**
|
|
481
|
+
* Initialize global runtime i18n
|
|
482
|
+
*/
|
|
483
|
+
declare function initializeI18n(options?: RuntimeI18nOptions): RuntimeI18nManager;
|
|
484
|
+
/**
|
|
485
|
+
* Get global runtime i18n instance
|
|
486
|
+
*/
|
|
487
|
+
declare function getI18n(): RuntimeI18nManager;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Enhanced I18n Implementation
|
|
491
|
+
* Type-safe internationalization following enhanced pattern
|
|
492
|
+
*/
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Validation result for i18n operations
|
|
496
|
+
*/
|
|
497
|
+
interface ValidationResult {
|
|
498
|
+
isValid: boolean;
|
|
499
|
+
errors: Array<{
|
|
500
|
+
type: string;
|
|
501
|
+
message: string;
|
|
502
|
+
path?: string;
|
|
503
|
+
}>;
|
|
504
|
+
suggestions?: string[];
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Evaluation result wrapper
|
|
508
|
+
*/
|
|
509
|
+
interface EvaluationResult<T = unknown> {
|
|
510
|
+
success: boolean;
|
|
511
|
+
value?: T;
|
|
512
|
+
type?: string;
|
|
513
|
+
errors?: Array<{
|
|
514
|
+
type: string;
|
|
515
|
+
message: string;
|
|
516
|
+
}>;
|
|
517
|
+
suggestions?: string[];
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Context metadata for enhanced pattern
|
|
521
|
+
*/
|
|
522
|
+
interface ContextMetadata {
|
|
523
|
+
contextId?: string;
|
|
524
|
+
timestamp?: number;
|
|
525
|
+
category: string;
|
|
526
|
+
capabilities?: string[];
|
|
527
|
+
state?: string;
|
|
528
|
+
complexity?: string;
|
|
529
|
+
sideEffects?: string[];
|
|
530
|
+
dependencies?: string[];
|
|
531
|
+
returnTypes?: string[];
|
|
532
|
+
relatedContexts?: string[];
|
|
533
|
+
examples?: Array<{
|
|
534
|
+
input: string;
|
|
535
|
+
description: string;
|
|
536
|
+
expectedOutput: string;
|
|
537
|
+
}>;
|
|
538
|
+
frameworkDependencies?: string[];
|
|
539
|
+
environmentRequirements?: {
|
|
540
|
+
browser?: boolean;
|
|
541
|
+
server?: boolean;
|
|
542
|
+
nodejs?: boolean;
|
|
543
|
+
};
|
|
544
|
+
performance?: {
|
|
545
|
+
averageTime?: number;
|
|
546
|
+
complexity?: string;
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* LLM documentation interface for AI-friendly descriptions
|
|
551
|
+
*/
|
|
552
|
+
interface LLMDocumentation {
|
|
553
|
+
summary: string;
|
|
554
|
+
description?: string;
|
|
555
|
+
examples?: Array<string | {
|
|
556
|
+
title: string;
|
|
557
|
+
code: string;
|
|
558
|
+
explanation: string;
|
|
559
|
+
output: string;
|
|
560
|
+
}>;
|
|
561
|
+
category?: string;
|
|
562
|
+
parameters?: Array<{
|
|
563
|
+
name: string;
|
|
564
|
+
type: string;
|
|
565
|
+
description: string;
|
|
566
|
+
required?: boolean;
|
|
567
|
+
default?: string;
|
|
568
|
+
optional?: boolean;
|
|
569
|
+
examples?: string[];
|
|
570
|
+
}>;
|
|
571
|
+
returns?: {
|
|
572
|
+
type: string;
|
|
573
|
+
description: string;
|
|
574
|
+
examples?: string[];
|
|
575
|
+
};
|
|
576
|
+
tips?: string[];
|
|
577
|
+
commonMistakes?: string[];
|
|
578
|
+
seeAlso?: string[];
|
|
579
|
+
tags?: string[];
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Evaluation type enumeration
|
|
583
|
+
*/
|
|
584
|
+
type EvaluationType = 'sync' | 'async' | 'streaming' | 'Context';
|
|
585
|
+
declare const EnhancedI18nInputSchema: z.ZodObject<{
|
|
586
|
+
/** Locale configuration */
|
|
587
|
+
locale: z.ZodString;
|
|
588
|
+
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
589
|
+
/** Dictionary data for translations */
|
|
590
|
+
dictionaries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
591
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
592
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
593
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
594
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
595
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
596
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
597
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
598
|
+
}, "strip", z.ZodRecord<z.ZodString, z.ZodString>, z.objectOutputType<{
|
|
599
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
600
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
601
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
602
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
603
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
604
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
605
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
606
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">, z.objectInputType<{
|
|
607
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
608
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
609
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
610
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
611
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
612
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
613
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
614
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">>>>;
|
|
615
|
+
/** Translation options */
|
|
616
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
617
|
+
detectLocale: z.ZodDefault<z.ZodBoolean>;
|
|
618
|
+
rtlLocales: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
619
|
+
preserveOriginalAttribute: z.ZodOptional<z.ZodString>;
|
|
620
|
+
validate: z.ZodDefault<z.ZodBoolean>;
|
|
621
|
+
}, "strip", z.ZodTypeAny, {
|
|
622
|
+
detectLocale: boolean;
|
|
623
|
+
rtlLocales: string[];
|
|
624
|
+
validate: boolean;
|
|
625
|
+
preserveOriginalAttribute?: string | undefined;
|
|
626
|
+
}, {
|
|
627
|
+
detectLocale?: boolean | undefined;
|
|
628
|
+
rtlLocales?: string[] | undefined;
|
|
629
|
+
preserveOriginalAttribute?: string | undefined;
|
|
630
|
+
validate?: boolean | undefined;
|
|
631
|
+
}>>;
|
|
632
|
+
/** Context variables for translation */
|
|
633
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
634
|
+
/** Environment and debug settings */
|
|
635
|
+
environment: z.ZodDefault<z.ZodEnum<["frontend", "backend", "universal"]>>;
|
|
636
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
637
|
+
}, "strip", z.ZodTypeAny, {
|
|
638
|
+
locale: string;
|
|
639
|
+
environment: "frontend" | "backend" | "universal";
|
|
640
|
+
debug: boolean;
|
|
641
|
+
fallbackLocale?: string | undefined;
|
|
642
|
+
dictionaries?: Record<string, z.objectOutputType<{
|
|
643
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
644
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
645
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
646
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
647
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
648
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
649
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
650
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">> | undefined;
|
|
651
|
+
options?: {
|
|
652
|
+
detectLocale: boolean;
|
|
653
|
+
rtlLocales: string[];
|
|
654
|
+
validate: boolean;
|
|
655
|
+
preserveOriginalAttribute?: string | undefined;
|
|
656
|
+
} | undefined;
|
|
657
|
+
variables?: Record<string, unknown> | undefined;
|
|
658
|
+
}, {
|
|
659
|
+
locale: string;
|
|
660
|
+
fallbackLocale?: string | undefined;
|
|
661
|
+
dictionaries?: Record<string, z.objectInputType<{
|
|
662
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
663
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
664
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
665
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
666
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
667
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
668
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
669
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">> | undefined;
|
|
670
|
+
options?: {
|
|
671
|
+
detectLocale?: boolean | undefined;
|
|
672
|
+
rtlLocales?: string[] | undefined;
|
|
673
|
+
preserveOriginalAttribute?: string | undefined;
|
|
674
|
+
validate?: boolean | undefined;
|
|
675
|
+
} | undefined;
|
|
676
|
+
variables?: Record<string, unknown> | undefined;
|
|
677
|
+
environment?: "frontend" | "backend" | "universal" | undefined;
|
|
678
|
+
debug?: boolean | undefined;
|
|
679
|
+
}>;
|
|
680
|
+
declare const EnhancedI18nOutputSchema: z.ZodObject<{
|
|
681
|
+
/** Context identifier */
|
|
682
|
+
contextId: z.ZodString;
|
|
683
|
+
timestamp: z.ZodNumber;
|
|
684
|
+
category: z.ZodLiteral<"Universal">;
|
|
685
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
686
|
+
state: z.ZodEnum<["ready", "loading", "error"]>;
|
|
687
|
+
/** I18n specific capabilities */
|
|
688
|
+
translate: z.ZodAny;
|
|
689
|
+
translateHyperscript: z.ZodAny;
|
|
690
|
+
setLocale: z.ZodAny;
|
|
691
|
+
getLocale: z.ZodAny;
|
|
692
|
+
validateTranslation: z.ZodAny;
|
|
693
|
+
/** Locale management */
|
|
694
|
+
locale: z.ZodObject<{
|
|
695
|
+
current: z.ZodString;
|
|
696
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
697
|
+
direction: z.ZodEnum<["ltr", "rtl"]>;
|
|
698
|
+
available: z.ZodArray<z.ZodString, "many">;
|
|
699
|
+
}, "strip", z.ZodTypeAny, {
|
|
700
|
+
direction: "ltr" | "rtl";
|
|
701
|
+
current: string;
|
|
702
|
+
available: string[];
|
|
703
|
+
fallback?: string | undefined;
|
|
704
|
+
}, {
|
|
705
|
+
direction: "ltr" | "rtl";
|
|
706
|
+
current: string;
|
|
707
|
+
available: string[];
|
|
708
|
+
fallback?: string | undefined;
|
|
709
|
+
}>;
|
|
710
|
+
/** Dictionary access */
|
|
711
|
+
dictionary: z.ZodObject<{
|
|
712
|
+
get: z.ZodAny;
|
|
713
|
+
set: z.ZodAny;
|
|
714
|
+
has: z.ZodAny;
|
|
715
|
+
keys: z.ZodAny;
|
|
716
|
+
}, "strip", z.ZodTypeAny, {
|
|
717
|
+
set?: any;
|
|
718
|
+
get?: any;
|
|
719
|
+
has?: any;
|
|
720
|
+
keys?: any;
|
|
721
|
+
}, {
|
|
722
|
+
set?: any;
|
|
723
|
+
get?: any;
|
|
724
|
+
has?: any;
|
|
725
|
+
keys?: any;
|
|
726
|
+
}>;
|
|
727
|
+
/** Formatting utilities */
|
|
728
|
+
format: z.ZodObject<{
|
|
729
|
+
number: z.ZodAny;
|
|
730
|
+
date: z.ZodAny;
|
|
731
|
+
currency: z.ZodAny;
|
|
732
|
+
relative: z.ZodAny;
|
|
733
|
+
}, "strip", z.ZodTypeAny, {
|
|
734
|
+
number?: any;
|
|
735
|
+
currency?: any;
|
|
736
|
+
relative?: any;
|
|
737
|
+
date?: any;
|
|
738
|
+
}, {
|
|
739
|
+
number?: any;
|
|
740
|
+
currency?: any;
|
|
741
|
+
relative?: any;
|
|
742
|
+
date?: any;
|
|
743
|
+
}>;
|
|
744
|
+
}, "strip", z.ZodTypeAny, {
|
|
745
|
+
locale: {
|
|
746
|
+
direction: "ltr" | "rtl";
|
|
747
|
+
current: string;
|
|
748
|
+
available: string[];
|
|
749
|
+
fallback?: string | undefined;
|
|
750
|
+
};
|
|
751
|
+
category: "Universal";
|
|
752
|
+
dictionary: {
|
|
753
|
+
set?: any;
|
|
754
|
+
get?: any;
|
|
755
|
+
has?: any;
|
|
756
|
+
keys?: any;
|
|
757
|
+
};
|
|
758
|
+
contextId: string;
|
|
759
|
+
timestamp: number;
|
|
760
|
+
capabilities: string[];
|
|
761
|
+
state: "error" | "ready" | "loading";
|
|
762
|
+
format: {
|
|
763
|
+
number?: any;
|
|
764
|
+
currency?: any;
|
|
765
|
+
relative?: any;
|
|
766
|
+
date?: any;
|
|
767
|
+
};
|
|
768
|
+
translate?: any;
|
|
769
|
+
translateHyperscript?: any;
|
|
770
|
+
setLocale?: any;
|
|
771
|
+
getLocale?: any;
|
|
772
|
+
validateTranslation?: any;
|
|
773
|
+
}, {
|
|
774
|
+
locale: {
|
|
775
|
+
direction: "ltr" | "rtl";
|
|
776
|
+
current: string;
|
|
777
|
+
available: string[];
|
|
778
|
+
fallback?: string | undefined;
|
|
779
|
+
};
|
|
780
|
+
category: "Universal";
|
|
781
|
+
dictionary: {
|
|
782
|
+
set?: any;
|
|
783
|
+
get?: any;
|
|
784
|
+
has?: any;
|
|
785
|
+
keys?: any;
|
|
786
|
+
};
|
|
787
|
+
contextId: string;
|
|
788
|
+
timestamp: number;
|
|
789
|
+
capabilities: string[];
|
|
790
|
+
state: "error" | "ready" | "loading";
|
|
791
|
+
format: {
|
|
792
|
+
number?: any;
|
|
793
|
+
currency?: any;
|
|
794
|
+
relative?: any;
|
|
795
|
+
date?: any;
|
|
796
|
+
};
|
|
797
|
+
translate?: any;
|
|
798
|
+
translateHyperscript?: any;
|
|
799
|
+
setLocale?: any;
|
|
800
|
+
getLocale?: any;
|
|
801
|
+
validateTranslation?: any;
|
|
802
|
+
}>;
|
|
803
|
+
type EnhancedI18nInput = z.infer<typeof EnhancedI18nInputSchema>;
|
|
804
|
+
type EnhancedI18nOutput = z.infer<typeof EnhancedI18nOutputSchema>;
|
|
805
|
+
declare class TypedI18nContextImplementation {
|
|
806
|
+
readonly name = "i18nContext";
|
|
807
|
+
readonly category: "Universal";
|
|
808
|
+
readonly description = "Type-safe internationalization context with enhanced validation and LLM integration";
|
|
809
|
+
readonly inputSchema: z.ZodObject<{
|
|
810
|
+
/** Locale configuration */
|
|
811
|
+
locale: z.ZodString;
|
|
812
|
+
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
813
|
+
/** Dictionary data for translations */
|
|
814
|
+
dictionaries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
815
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
816
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
817
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
818
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
819
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
820
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
821
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
822
|
+
}, "strip", z.ZodRecord<z.ZodString, z.ZodString>, z.objectOutputType<{
|
|
823
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
824
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
825
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
826
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
827
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
828
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
829
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
830
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">, z.objectInputType<{
|
|
831
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
832
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
833
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
834
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
835
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
836
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
837
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
838
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">>>>;
|
|
839
|
+
/** Translation options */
|
|
840
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
841
|
+
detectLocale: z.ZodDefault<z.ZodBoolean>;
|
|
842
|
+
rtlLocales: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
843
|
+
preserveOriginalAttribute: z.ZodOptional<z.ZodString>;
|
|
844
|
+
validate: z.ZodDefault<z.ZodBoolean>;
|
|
845
|
+
}, "strip", z.ZodTypeAny, {
|
|
846
|
+
detectLocale: boolean;
|
|
847
|
+
rtlLocales: string[];
|
|
848
|
+
validate: boolean;
|
|
849
|
+
preserveOriginalAttribute?: string | undefined;
|
|
850
|
+
}, {
|
|
851
|
+
detectLocale?: boolean | undefined;
|
|
852
|
+
rtlLocales?: string[] | undefined;
|
|
853
|
+
preserveOriginalAttribute?: string | undefined;
|
|
854
|
+
validate?: boolean | undefined;
|
|
855
|
+
}>>;
|
|
856
|
+
/** Context variables for translation */
|
|
857
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
858
|
+
/** Environment and debug settings */
|
|
859
|
+
environment: z.ZodDefault<z.ZodEnum<["frontend", "backend", "universal"]>>;
|
|
860
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
861
|
+
}, "strip", z.ZodTypeAny, {
|
|
862
|
+
locale: string;
|
|
863
|
+
environment: "frontend" | "backend" | "universal";
|
|
864
|
+
debug: boolean;
|
|
865
|
+
fallbackLocale?: string | undefined;
|
|
866
|
+
dictionaries?: Record<string, z.objectOutputType<{
|
|
867
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
868
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
869
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
870
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
871
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
872
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
873
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
874
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">> | undefined;
|
|
875
|
+
options?: {
|
|
876
|
+
detectLocale: boolean;
|
|
877
|
+
rtlLocales: string[];
|
|
878
|
+
validate: boolean;
|
|
879
|
+
preserveOriginalAttribute?: string | undefined;
|
|
880
|
+
} | undefined;
|
|
881
|
+
variables?: Record<string, unknown> | undefined;
|
|
882
|
+
}, {
|
|
883
|
+
locale: string;
|
|
884
|
+
fallbackLocale?: string | undefined;
|
|
885
|
+
dictionaries?: Record<string, z.objectInputType<{
|
|
886
|
+
commands: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
887
|
+
modifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
888
|
+
events: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
889
|
+
logical: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
890
|
+
temporal: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
891
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
892
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
893
|
+
}, z.ZodRecord<z.ZodString, z.ZodString>, "strip">> | undefined;
|
|
894
|
+
options?: {
|
|
895
|
+
detectLocale?: boolean | undefined;
|
|
896
|
+
rtlLocales?: string[] | undefined;
|
|
897
|
+
preserveOriginalAttribute?: string | undefined;
|
|
898
|
+
validate?: boolean | undefined;
|
|
899
|
+
} | undefined;
|
|
900
|
+
variables?: Record<string, unknown> | undefined;
|
|
901
|
+
environment?: "frontend" | "backend" | "universal" | undefined;
|
|
902
|
+
debug?: boolean | undefined;
|
|
903
|
+
}>;
|
|
904
|
+
readonly outputType: EvaluationType;
|
|
905
|
+
private evaluationHistory;
|
|
906
|
+
readonly metadata: ContextMetadata;
|
|
907
|
+
readonly documentation: LLMDocumentation;
|
|
908
|
+
initialize(input: EnhancedI18nInput): Promise<EvaluationResult<EnhancedI18nOutput>>;
|
|
909
|
+
validate(input: unknown): ValidationResult;
|
|
910
|
+
private initializeLocale;
|
|
911
|
+
private loadDictionaries;
|
|
912
|
+
private createTranslateFunction;
|
|
913
|
+
private createHyperscriptTranslator;
|
|
914
|
+
private createLocaleChanger;
|
|
915
|
+
private createValidationFunction;
|
|
916
|
+
private getDictionaryValue;
|
|
917
|
+
private setDictionaryValue;
|
|
918
|
+
private hasDictionaryValue;
|
|
919
|
+
private getDictionaryKeys;
|
|
920
|
+
private createNumberFormatter;
|
|
921
|
+
private createDateFormatter;
|
|
922
|
+
private createCurrencyFormatter;
|
|
923
|
+
private createRelativeTimeFormatter;
|
|
924
|
+
private trackPerformance;
|
|
925
|
+
getPerformanceMetrics(): {
|
|
926
|
+
totalInitializations: number;
|
|
927
|
+
successRate: number;
|
|
928
|
+
averageDuration: number;
|
|
929
|
+
lastEvaluationTime: number;
|
|
930
|
+
evaluationHistory: {
|
|
931
|
+
input: EnhancedI18nInput;
|
|
932
|
+
output: EnhancedI18nOutput | undefined;
|
|
933
|
+
success: boolean;
|
|
934
|
+
duration: number;
|
|
935
|
+
timestamp: number;
|
|
936
|
+
}[];
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
declare function createI18nContext(): TypedI18nContextImplementation;
|
|
940
|
+
declare function createEnhancedI18n(locale: string, options?: Partial<EnhancedI18nInput>): Promise<EvaluationResult<EnhancedI18nOutput>>;
|
|
941
|
+
declare const enhancedI18nImplementation: TypedI18nContextImplementation;
|
|
942
|
+
|
|
943
|
+
declare const defaultTranslator: HyperscriptTranslator;
|
|
944
|
+
|
|
945
|
+
declare const defaultRuntime: RuntimeI18nManager;
|
|
946
|
+
|
|
947
|
+
export { type DateFormatOptions, DateFormatter, Dictionary, type EnhancedI18nInput, EnhancedI18nInputSchema, type EnhancedI18nOutput, EnhancedI18nOutputSchema, HyperscriptI18nWebpackPlugin, HyperscriptTranslator, I18nConfig, LocaleFormatter, type NumberFormatOptions, NumberFormatter, PluralAwareTranslator, type PluralForms, type PluralRule, type RelativeTimeFormatOptions, RuntimeI18nManager, type RuntimeI18nOptions, type SSRLocaleContext, SSRLocaleManager, type SSRLocaleOptions, Token, TranslationOptions, TranslationResult, TypedI18nContextImplementation, ValidationResult$1 as ValidationResult, ar, createEnhancedI18n, createExpressI18nMiddleware, createI18nContext, de, defaultRuntime, defaultTranslator, detectLocale, dictionaries, en, enhancedI18nImplementation, es, formatForLocale, fr, getBrowserLocales, getDictionary, getFormatter, getI18n, getPlural, hyperscriptI18nVitePlugin, id, initializeI18n, isLocaleSupported, isRTL, ja, ko, pluralRules, pluralTimeExpressions, pt, qu, runtimeI18n, supportedLocales, sw, tokenize, tr, validate, withI18n, zh };
|