inline-i18n-multi 0.12.0 → 0.13.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 CHANGED
@@ -83,6 +83,7 @@ See "Hello" in your app? Just search for "Hello" in your codebase. **Done.**
83
83
  - **Translation Key Listing** - `getTranslationKeys(locale?, namespace?)` returns all loaded translation keys
84
84
  - **Missing Translation Tracker** - Runtime collection of missing translation keys (`trackMissingKeys(true/false)`, `getMissingKeys()`, `clearMissingKeys()`)
85
85
  - **Locale Change Event** — Subscribe to locale changes with `onLocaleChange()` (v0.12.0)
86
+ - **Formatting Utilities** — Locale-aware `formatNumber`, `formatDate`, `formatList` powered by `Intl` APIs (v0.13.0)
86
87
 
87
88
  ---
88
89
 
@@ -1017,6 +1018,9 @@ Available helpers:
1017
1018
  | `clearMissingKeys()` | Clear the tracked missing keys list |
1018
1019
  | `onLocaleChange(callback)` | Subscribe to locale changes, returns unsubscribe function |
1019
1020
  | `clearLocaleListeners()` | Remove all locale change listeners |
1021
+ | `formatNumber(value, options?, locale?)` | Format numbers (currency, percent, etc.) |
1022
+ | `formatDate(value, options?, locale?)` | Format dates and times |
1023
+ | `formatList(values, options?, locale?)` | Format lists (conjunction, disjunction) |
1020
1024
 
1021
1025
  ### Custom Formatters
1022
1026
 
package/dist/index.d.mts CHANGED
@@ -367,6 +367,33 @@ declare function detectLocale(options: DetectLocaleOptions): Locale;
367
367
  */
368
368
  declare function createScope(namespace: string): (key: string, vars?: TranslationVars, locale?: Locale) => string;
369
369
 
370
+ /**
371
+ * Format a number for the given locale using Intl.NumberFormat.
372
+ *
373
+ * @example
374
+ * formatNumber(1234.5) // "1,234.5" (en)
375
+ * formatNumber(1234.5, { style: 'currency', currency: 'USD' }) // "$1,234.50"
376
+ * formatNumber(0.85, { style: 'percent' }, 'ko') // "85%"
377
+ */
378
+ declare function formatNumber(value: number, options?: Intl.NumberFormatOptions, locale?: Locale): string;
379
+ /**
380
+ * Format a date for the given locale using Intl.DateTimeFormat.
381
+ *
382
+ * @example
383
+ * formatDate(new Date()) // "3/30/2026" (en)
384
+ * formatDate(new Date(), { dateStyle: 'full' }, 'ja') // "2026年3月30日月曜日"
385
+ */
386
+ declare function formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions, locale?: Locale): string;
387
+ /**
388
+ * Format a list for the given locale using Intl.ListFormat.
389
+ *
390
+ * @example
391
+ * formatList(['A', 'B', 'C']) // "A, B, and C" (en)
392
+ * formatList(['A', 'B', 'C'], { type: 'disjunction' }) // "A, B, or C"
393
+ * formatList(['りんご', 'みかん'], {}, 'ja') // "りんごとみかん"
394
+ */
395
+ declare function formatList(values: string[], options?: Intl.ListFormatOptions, locale?: Locale): string;
396
+
370
397
  /**
371
398
  * Rich Text segment types
372
399
  */
@@ -395,4 +422,4 @@ interface RichTextSegment {
395
422
  */
396
423
  declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
397
424
 
398
- export { type Config, type CustomFormatter, type DebugModeOptions, type DetectLocaleOptions, type DetectSource, type Dictionaries, type Dictionary, type Locale, type PluralRules, type RichTextSegment, type TranslationVars, type TranslationWarning, type Translations, type WarningHandler, __i18n_lookup, clearDictionaries, clearFormatters, clearICUCache, clearLocaleListeners, clearMissingKeys, configure, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getConfig, getDictionary, getLoadedLocales, getLoadedNamespaces, getLocale, getLocaleDisplayName, getMissingKeys, getTranslationKeys, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, onLocaleChange, parseRichText, registerFormatter, resetConfig, restoreLocale, setLocale, t, trackMissingKeys, zh_es };
425
+ export { type Config, type CustomFormatter, type DebugModeOptions, type DetectLocaleOptions, type DetectSource, type Dictionaries, type Dictionary, type Locale, type PluralRules, type RichTextSegment, type TranslationVars, type TranslationWarning, type Translations, type WarningHandler, __i18n_lookup, clearDictionaries, clearFormatters, clearICUCache, clearLocaleListeners, clearMissingKeys, configure, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, formatDate, formatList, formatNumber, getConfig, getDictionary, getLoadedLocales, getLoadedNamespaces, getLocale, getLocaleDisplayName, getMissingKeys, getTranslationKeys, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, onLocaleChange, parseRichText, registerFormatter, resetConfig, restoreLocale, setLocale, t, trackMissingKeys, zh_es };
package/dist/index.d.ts CHANGED
@@ -367,6 +367,33 @@ declare function detectLocale(options: DetectLocaleOptions): Locale;
367
367
  */
368
368
  declare function createScope(namespace: string): (key: string, vars?: TranslationVars, locale?: Locale) => string;
369
369
 
370
+ /**
371
+ * Format a number for the given locale using Intl.NumberFormat.
372
+ *
373
+ * @example
374
+ * formatNumber(1234.5) // "1,234.5" (en)
375
+ * formatNumber(1234.5, { style: 'currency', currency: 'USD' }) // "$1,234.50"
376
+ * formatNumber(0.85, { style: 'percent' }, 'ko') // "85%"
377
+ */
378
+ declare function formatNumber(value: number, options?: Intl.NumberFormatOptions, locale?: Locale): string;
379
+ /**
380
+ * Format a date for the given locale using Intl.DateTimeFormat.
381
+ *
382
+ * @example
383
+ * formatDate(new Date()) // "3/30/2026" (en)
384
+ * formatDate(new Date(), { dateStyle: 'full' }, 'ja') // "2026年3月30日月曜日"
385
+ */
386
+ declare function formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions, locale?: Locale): string;
387
+ /**
388
+ * Format a list for the given locale using Intl.ListFormat.
389
+ *
390
+ * @example
391
+ * formatList(['A', 'B', 'C']) // "A, B, and C" (en)
392
+ * formatList(['A', 'B', 'C'], { type: 'disjunction' }) // "A, B, or C"
393
+ * formatList(['りんご', 'みかん'], {}, 'ja') // "りんごとみかん"
394
+ */
395
+ declare function formatList(values: string[], options?: Intl.ListFormatOptions, locale?: Locale): string;
396
+
370
397
  /**
371
398
  * Rich Text segment types
372
399
  */
@@ -395,4 +422,4 @@ interface RichTextSegment {
395
422
  */
396
423
  declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
397
424
 
398
- export { type Config, type CustomFormatter, type DebugModeOptions, type DetectLocaleOptions, type DetectSource, type Dictionaries, type Dictionary, type Locale, type PluralRules, type RichTextSegment, type TranslationVars, type TranslationWarning, type Translations, type WarningHandler, __i18n_lookup, clearDictionaries, clearFormatters, clearICUCache, clearLocaleListeners, clearMissingKeys, configure, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getConfig, getDictionary, getLoadedLocales, getLoadedNamespaces, getLocale, getLocaleDisplayName, getMissingKeys, getTranslationKeys, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, onLocaleChange, parseRichText, registerFormatter, resetConfig, restoreLocale, setLocale, t, trackMissingKeys, zh_es };
425
+ export { type Config, type CustomFormatter, type DebugModeOptions, type DetectLocaleOptions, type DetectSource, type Dictionaries, type Dictionary, type Locale, type PluralRules, type RichTextSegment, type TranslationVars, type TranslationWarning, type Translations, type WarningHandler, __i18n_lookup, clearDictionaries, clearFormatters, clearICUCache, clearLocaleListeners, clearMissingKeys, configure, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, formatDate, formatList, formatNumber, getConfig, getDictionary, getLoadedLocales, getLoadedNamespaces, getLocale, getLocaleDisplayName, getMissingKeys, getTranslationKeys, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, onLocaleChange, parseRichText, registerFormatter, resetConfig, restoreLocale, setLocale, t, trackMissingKeys, zh_es };
package/dist/index.js CHANGED
@@ -1157,6 +1157,17 @@ function createScope(namespace) {
1157
1157
  };
1158
1158
  }
1159
1159
 
1160
+ // src/format.ts
1161
+ function formatNumber(value, options, locale) {
1162
+ return new Intl.NumberFormat(locale ?? getLocale(), options).format(value);
1163
+ }
1164
+ function formatDate(value, options, locale) {
1165
+ return new Intl.DateTimeFormat(locale ?? getLocale(), options).format(value);
1166
+ }
1167
+ function formatList(values, options, locale) {
1168
+ return new Intl.ListFormat(locale ?? getLocale(), options).format(values);
1169
+ }
1170
+
1160
1171
  // src/richtext.ts
1161
1172
  function escapeRegExp(str) {
1162
1173
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -1207,6 +1218,9 @@ exports.en_es = en_es;
1207
1218
  exports.en_fr = en_fr;
1208
1219
  exports.en_ja = en_ja;
1209
1220
  exports.en_zh = en_zh;
1221
+ exports.formatDate = formatDate;
1222
+ exports.formatList = formatList;
1223
+ exports.formatNumber = formatNumber;
1210
1224
  exports.getConfig = getConfig;
1211
1225
  exports.getDictionary = getDictionary;
1212
1226
  exports.getLoadedLocales = getLoadedLocales;