@stacksjs/i18n 0.70.86 → 0.70.88
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/package.json +13 -4
- package/dist/bootstrap.d.ts +0 -14
- package/dist/formatter.d.ts +0 -105
- package/dist/index.d.ts +0 -94
- package/dist/index.js +0 -2
- package/dist/loader.d.ts +0 -52
- package/dist/locale-switch.d.ts +0 -16
- package/dist/pluralization.d.ts +0 -42
- package/dist/translator.d.ts +0 -79
- package/dist/types.d.ts +0 -213
- package/src/bootstrap.ts +0 -107
- package/src/formatter.ts +0 -399
- package/src/index.ts +0 -100
- package/src/loader.ts +0 -335
- package/src/locale-switch.ts +0 -81
- package/src/pluralization.ts +0 -290
- package/src/translator.ts +0 -502
- package/src/types.ts +0 -238
package/src/types.ts
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* i18n Type Definitions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Translation messages - can be nested objects or strings
|
|
7
|
-
*/
|
|
8
|
-
export type TranslationMessages = {
|
|
9
|
-
[key: string]: string | TranslationMessages
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* All translations keyed by locale
|
|
14
|
-
*/
|
|
15
|
-
export type Translations = {
|
|
16
|
-
[locale: string]: TranslationMessages
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Interpolation values for translations
|
|
21
|
-
*/
|
|
22
|
-
export type InterpolationValues = Record<string, string | number | boolean | null | undefined>
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Plural forms for a translation
|
|
26
|
-
*/
|
|
27
|
-
export interface PluralForms {
|
|
28
|
-
zero?: string
|
|
29
|
-
one: string
|
|
30
|
-
two?: string
|
|
31
|
-
few?: string
|
|
32
|
-
many?: string
|
|
33
|
-
other: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* i18n configuration options
|
|
38
|
-
*/
|
|
39
|
-
export interface I18nConfig {
|
|
40
|
-
/**
|
|
41
|
-
* Default locale
|
|
42
|
-
* @default 'en'
|
|
43
|
-
*/
|
|
44
|
-
locale: string
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Fallback locale when translation is not found
|
|
48
|
-
* @default 'en'
|
|
49
|
-
*/
|
|
50
|
-
fallbackLocale: string
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Available locales
|
|
54
|
-
*/
|
|
55
|
-
availableLocales?: string[]
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Initial translations
|
|
59
|
-
*/
|
|
60
|
-
messages?: Translations
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Missing translation handler
|
|
64
|
-
*/
|
|
65
|
-
missingHandler?: (locale: string, key: string) => string | undefined
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Whether to warn about missing translations
|
|
69
|
-
* @default true
|
|
70
|
-
*/
|
|
71
|
-
warnMissing?: boolean
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Escape interpolation values
|
|
75
|
-
* @default false
|
|
76
|
-
*/
|
|
77
|
-
escapeValues?: boolean
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Separator for nested keys
|
|
81
|
-
* @default '.'
|
|
82
|
-
*/
|
|
83
|
-
keySeparator?: string
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Plural separator
|
|
87
|
-
* @default '|'
|
|
88
|
-
*/
|
|
89
|
-
pluralSeparator?: string
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Date/time formatting options
|
|
93
|
-
*/
|
|
94
|
-
dateTimeFormats?: DateTimeFormats
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Number formatting options
|
|
98
|
-
*/
|
|
99
|
-
numberFormats?: NumberFormats
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Date/time format configurations per locale
|
|
104
|
-
*/
|
|
105
|
-
export type DateTimeFormats = {
|
|
106
|
-
[locale: string]: {
|
|
107
|
-
[formatName: string]: Intl.DateTimeFormatOptions
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Number format configurations per locale
|
|
113
|
-
*/
|
|
114
|
-
export type NumberFormats = {
|
|
115
|
-
[locale: string]: {
|
|
116
|
-
[formatName: string]: Intl.NumberFormatOptions
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Translation function
|
|
122
|
-
*/
|
|
123
|
-
export type TranslateFunction = (
|
|
124
|
-
key: string,
|
|
125
|
-
values?: InterpolationValues,
|
|
126
|
-
locale?: string,
|
|
127
|
-
) => string
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Plural translation function
|
|
131
|
-
*/
|
|
132
|
-
export type TranslatePluralFunction = (
|
|
133
|
-
key: string,
|
|
134
|
-
count: number,
|
|
135
|
-
values?: InterpolationValues,
|
|
136
|
-
locale?: string,
|
|
137
|
-
) => string
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* i18n instance interface
|
|
141
|
-
*/
|
|
142
|
-
export interface I18nInstance {
|
|
143
|
-
/**
|
|
144
|
-
* Current locale
|
|
145
|
-
*/
|
|
146
|
-
locale: string
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Fallback locale
|
|
150
|
-
*/
|
|
151
|
-
fallbackLocale: string
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Available locales
|
|
155
|
-
*/
|
|
156
|
-
availableLocales: string[]
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Translate a key
|
|
160
|
-
*/
|
|
161
|
-
t: TranslateFunction
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Translate with pluralization
|
|
165
|
-
*/
|
|
166
|
-
tc: TranslatePluralFunction
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Check if translation exists
|
|
170
|
-
*/
|
|
171
|
-
te: (key: string, locale?: string) => boolean
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Get translation message object
|
|
175
|
-
*/
|
|
176
|
-
tm: (key: string, locale?: string) => TranslationMessages | string | undefined
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Set locale
|
|
180
|
-
*/
|
|
181
|
-
setLocale: (locale: string) => void
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Add translations for a locale
|
|
185
|
-
*/
|
|
186
|
-
addTranslations: (locale: string, messages: TranslationMessages) => void
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Format a date
|
|
190
|
-
*/
|
|
191
|
-
d: (value: Date | number, format?: string) => string
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Format a number
|
|
195
|
-
*/
|
|
196
|
-
n: (value: number, format?: string) => string
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Locale metadata
|
|
201
|
-
*/
|
|
202
|
-
export interface LocaleInfo {
|
|
203
|
-
code: string
|
|
204
|
-
name: string
|
|
205
|
-
nativeName: string
|
|
206
|
-
direction: 'ltr' | 'rtl'
|
|
207
|
-
region?: string
|
|
208
|
-
script?: string
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Common locales with metadata
|
|
213
|
-
*/
|
|
214
|
-
export const LOCALE_INFO: Record<string, LocaleInfo> = {
|
|
215
|
-
en: { code: 'en', name: 'English', nativeName: 'English', direction: 'ltr' },
|
|
216
|
-
'en-US': { code: 'en-US', name: 'English (US)', nativeName: 'English (US)', direction: 'ltr', region: 'US' },
|
|
217
|
-
'en-GB': { code: 'en-GB', name: 'English (UK)', nativeName: 'English (UK)', direction: 'ltr', region: 'GB' },
|
|
218
|
-
es: { code: 'es', name: 'Spanish', nativeName: 'Espa\u00f1ol', direction: 'ltr' },
|
|
219
|
-
fr: { code: 'fr', name: 'French', nativeName: 'Fran\u00e7ais', direction: 'ltr' },
|
|
220
|
-
de: { code: 'de', name: 'German', nativeName: 'Deutsch', direction: 'ltr' },
|
|
221
|
-
it: { code: 'it', name: 'Italian', nativeName: 'Italiano', direction: 'ltr' },
|
|
222
|
-
pt: { code: 'pt', name: 'Portuguese', nativeName: 'Portugu\u00eas', direction: 'ltr' },
|
|
223
|
-
'pt-BR': { code: 'pt-BR', name: 'Portuguese (Brazil)', nativeName: 'Portugu\u00eas (Brasil)', direction: 'ltr', region: 'BR' },
|
|
224
|
-
zh: { code: 'zh', name: 'Chinese', nativeName: '\u4e2d\u6587', direction: 'ltr' },
|
|
225
|
-
'zh-CN': { code: 'zh-CN', name: 'Chinese (Simplified)', nativeName: '\u7b80\u4f53\u4e2d\u6587', direction: 'ltr', region: 'CN' },
|
|
226
|
-
'zh-TW': { code: 'zh-TW', name: 'Chinese (Traditional)', nativeName: '\u7e41\u9ad4\u4e2d\u6587', direction: 'ltr', region: 'TW' },
|
|
227
|
-
ja: { code: 'ja', name: 'Japanese', nativeName: '\u65e5\u672c\u8a9e', direction: 'ltr' },
|
|
228
|
-
ko: { code: 'ko', name: 'Korean', nativeName: '\ud55c\uad6d\uc5b4', direction: 'ltr' },
|
|
229
|
-
ar: { code: 'ar', name: 'Arabic', nativeName: '\u0627\u0644\u0639\u0631\u0628\u064a\u0629', direction: 'rtl' },
|
|
230
|
-
he: { code: 'he', name: 'Hebrew', nativeName: '\u05e2\u05d1\u05e8\u05d9\u05ea', direction: 'rtl' },
|
|
231
|
-
ru: { code: 'ru', name: 'Russian', nativeName: '\u0420\u0443\u0441\u0441\u043a\u0438\u0439', direction: 'ltr' },
|
|
232
|
-
nl: { code: 'nl', name: 'Dutch', nativeName: 'Nederlands', direction: 'ltr' },
|
|
233
|
-
pl: { code: 'pl', name: 'Polish', nativeName: 'Polski', direction: 'ltr' },
|
|
234
|
-
tr: { code: 'tr', name: 'Turkish', nativeName: 'T\u00fcrk\u00e7e', direction: 'ltr' },
|
|
235
|
-
vi: { code: 'vi', name: 'Vietnamese', nativeName: 'Ti\u1ebfng Vi\u1ec7t', direction: 'ltr' },
|
|
236
|
-
th: { code: 'th', name: 'Thai', nativeName: '\u0e44\u0e17\u0e22', direction: 'ltr' },
|
|
237
|
-
hi: { code: 'hi', name: 'Hindi', nativeName: '\u0939\u093f\u0928\u094d\u0926\u0940', direction: 'ltr' },
|
|
238
|
-
}
|