@molecule/app-i18n-i18next 1.0.4 → 1.0.5
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 +34 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-11-08T06:05:42.905Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-i18n-i18next
|
|
@@ -129,22 +129,27 @@ interface LocaleConfig {
|
|
|
129
129
|
* Locale code (e.g., 'en-US', 'fr-FR').
|
|
130
130
|
*/
|
|
131
131
|
code: string
|
|
132
|
+
|
|
132
133
|
/**
|
|
133
134
|
* Display name (e.g., 'English (US)', 'Francais').
|
|
134
135
|
*/
|
|
135
136
|
name: string
|
|
137
|
+
|
|
136
138
|
/**
|
|
137
139
|
* Native display name.
|
|
138
140
|
*/
|
|
139
141
|
nativeName?: string
|
|
142
|
+
|
|
140
143
|
/**
|
|
141
144
|
* Text direction.
|
|
142
145
|
*/
|
|
143
146
|
direction?: 'ltr' | 'rtl'
|
|
147
|
+
|
|
144
148
|
/**
|
|
145
149
|
* Translations for this locale.
|
|
146
150
|
*/
|
|
147
151
|
translations?: Translations
|
|
152
|
+
|
|
148
153
|
/**
|
|
149
154
|
* Lazy loader for translations. Called on first setLocale() to this locale.
|
|
150
155
|
* When provided, translations can be omitted and will be loaded on demand.
|
|
@@ -163,18 +168,22 @@ interface NumberFormatOptions {
|
|
|
163
168
|
* Number style.
|
|
164
169
|
*/
|
|
165
170
|
style?: 'decimal' | 'currency' | 'percent' | 'unit'
|
|
171
|
+
|
|
166
172
|
/**
|
|
167
173
|
* Currency code (for currency style).
|
|
168
174
|
*/
|
|
169
175
|
currency?: string
|
|
176
|
+
|
|
170
177
|
/**
|
|
171
178
|
* Minimum fraction digits.
|
|
172
179
|
*/
|
|
173
180
|
minimumFractionDigits?: number
|
|
181
|
+
|
|
174
182
|
/**
|
|
175
183
|
* Maximum fraction digits.
|
|
176
184
|
*/
|
|
177
185
|
maximumFractionDigits?: number
|
|
186
|
+
|
|
178
187
|
/**
|
|
179
188
|
* Use grouping separators.
|
|
180
189
|
*/
|
|
@@ -192,14 +201,17 @@ interface DateFormatOptions {
|
|
|
192
201
|
* Date style.
|
|
193
202
|
*/
|
|
194
203
|
dateStyle?: 'full' | 'long' | 'medium' | 'short'
|
|
204
|
+
|
|
195
205
|
/**
|
|
196
206
|
* Time style.
|
|
197
207
|
*/
|
|
198
208
|
timeStyle?: 'full' | 'long' | 'medium' | 'short'
|
|
209
|
+
|
|
199
210
|
/**
|
|
200
211
|
* Custom format string (implementation-specific).
|
|
201
212
|
*/
|
|
202
213
|
format?: string
|
|
214
|
+
|
|
203
215
|
/**
|
|
204
216
|
* Relative time.
|
|
205
217
|
*/
|
|
@@ -219,6 +231,7 @@ interface I18nProvider {
|
|
|
219
231
|
* Gets the current locale.
|
|
220
232
|
*/
|
|
221
233
|
getLocale(): string
|
|
234
|
+
|
|
222
235
|
/**
|
|
223
236
|
* Sets the current locale.
|
|
224
237
|
*
|
|
@@ -233,14 +246,17 @@ interface I18nProvider {
|
|
|
233
246
|
* from a working one until a user notices the wrong language on screen.
|
|
234
247
|
*/
|
|
235
248
|
setLocale(locale: string): Promise<void>
|
|
249
|
+
|
|
236
250
|
/**
|
|
237
251
|
* Gets all available locales.
|
|
238
252
|
*/
|
|
239
253
|
getLocales(): LocaleConfig[]
|
|
254
|
+
|
|
240
255
|
/**
|
|
241
256
|
* Adds a locale.
|
|
242
257
|
*/
|
|
243
258
|
addLocale(config: LocaleConfig): void
|
|
259
|
+
|
|
244
260
|
/**
|
|
245
261
|
* Removes a locale by code, notifying subscribers so language pickers
|
|
246
262
|
* built on `onLocaleChange` re-render their list. If the removed locale
|
|
@@ -252,6 +268,7 @@ interface I18nProvider {
|
|
|
252
268
|
* otherwise.
|
|
253
269
|
*/
|
|
254
270
|
removeLocale(code: string): boolean
|
|
271
|
+
|
|
255
272
|
/**
|
|
256
273
|
* Adds translations to a locale. Auto-creates the locale if it doesn't exist.
|
|
257
274
|
*
|
|
@@ -262,6 +279,7 @@ interface I18nProvider {
|
|
|
262
279
|
* contract on the API side.
|
|
263
280
|
*/
|
|
264
281
|
addTranslations(locale: string, translations: Translations, namespace?: string): void
|
|
282
|
+
|
|
265
283
|
/**
|
|
266
284
|
* Translates a key with optional interpolation values and pluralization.
|
|
267
285
|
*
|
|
@@ -279,11 +297,9 @@ interface I18nProvider {
|
|
|
279
297
|
t(
|
|
280
298
|
key: string,
|
|
281
299
|
values?: InterpolationValues,
|
|
282
|
-
options?: {
|
|
283
|
-
defaultValue?: string
|
|
284
|
-
count?: number
|
|
285
|
-
},
|
|
300
|
+
options?: { defaultValue?: string; count?: number },
|
|
286
301
|
): string
|
|
302
|
+
|
|
287
303
|
/**
|
|
288
304
|
* Checks if a translation key exists.
|
|
289
305
|
*
|
|
@@ -298,46 +314,42 @@ interface I18nProvider {
|
|
|
298
314
|
* @returns `true` if the key has a translation.
|
|
299
315
|
*/
|
|
300
316
|
exists(key: string): boolean
|
|
317
|
+
|
|
301
318
|
/**
|
|
302
319
|
* Formats a number according to the current locale.
|
|
303
320
|
*
|
|
304
321
|
* @returns The locale-formatted number string.
|
|
305
322
|
*/
|
|
306
323
|
formatNumber(value: number, options?: NumberFormatOptions): string
|
|
324
|
+
|
|
307
325
|
/**
|
|
308
326
|
* Formats a date according to the current locale.
|
|
309
327
|
*
|
|
310
328
|
* @returns The locale-formatted date string.
|
|
311
329
|
*/
|
|
312
330
|
formatDate(value: Date | number | string, options?: DateFormatOptions): string
|
|
331
|
+
|
|
313
332
|
/**
|
|
314
333
|
* Formats a relative time (e.g. "2 hours ago").
|
|
315
334
|
*
|
|
316
335
|
* @returns The locale-formatted relative time string.
|
|
317
336
|
*/
|
|
318
|
-
formatRelativeTime(
|
|
319
|
-
|
|
320
|
-
options?: {
|
|
321
|
-
unit?: Intl.RelativeTimeFormatUnit
|
|
322
|
-
},
|
|
323
|
-
): string
|
|
337
|
+
formatRelativeTime(value: Date | number, options?: { unit?: Intl.RelativeTimeFormatUnit }): string
|
|
338
|
+
|
|
324
339
|
/**
|
|
325
340
|
* Formats a list (e.g. "A, B, and C").
|
|
326
341
|
*
|
|
327
342
|
* @returns The locale-formatted list string.
|
|
328
343
|
*/
|
|
329
|
-
formatList(
|
|
330
|
-
|
|
331
|
-
options?: {
|
|
332
|
-
type?: 'conjunction' | 'disjunction' | 'unit'
|
|
333
|
-
},
|
|
334
|
-
): string
|
|
344
|
+
formatList(values: string[], options?: { type?: 'conjunction' | 'disjunction' | 'unit' }): string
|
|
345
|
+
|
|
335
346
|
/**
|
|
336
347
|
* Subscribes to locale changes.
|
|
337
348
|
*
|
|
338
349
|
* @returns An unsubscribe function.
|
|
339
350
|
*/
|
|
340
351
|
onLocaleChange(listener: (locale: string) => void): () => void
|
|
352
|
+
|
|
341
353
|
/**
|
|
342
354
|
* Gets a counter that advances for every change `onLocaleChange` announces:
|
|
343
355
|
* a locale switch, a locale-list change, or translations added for a locale
|
|
@@ -359,24 +371,29 @@ interface I18nProvider {
|
|
|
359
371
|
* @returns The provider's current revision.
|
|
360
372
|
*/
|
|
361
373
|
getRevision?(): number
|
|
374
|
+
|
|
362
375
|
/**
|
|
363
376
|
* Gets the text direction for the current locale.
|
|
364
377
|
*
|
|
365
378
|
* @returns `'ltr'` or `'rtl'`.
|
|
366
379
|
*/
|
|
367
380
|
getDirection(): 'ltr' | 'rtl'
|
|
381
|
+
|
|
368
382
|
/**
|
|
369
383
|
* Checks if a translation key exists (alias for exists).
|
|
370
384
|
*/
|
|
371
385
|
hasKey?(key: string): boolean
|
|
386
|
+
|
|
372
387
|
/**
|
|
373
388
|
* Checks if the provider is ready.
|
|
374
389
|
*/
|
|
375
390
|
isReady?(): boolean
|
|
391
|
+
|
|
376
392
|
/**
|
|
377
393
|
* Registers a callback for when the provider is ready.
|
|
378
394
|
*/
|
|
379
395
|
onReady?(callback: () => void): () => void
|
|
396
|
+
|
|
380
397
|
/**
|
|
381
398
|
* Registers a lazily-loaded content module for automatic reload on locale changes.
|
|
382
399
|
* All registered content is reloaded during `setLocale()` before listeners fire,
|