inline-i18n-multi 0.14.0 → 0.15.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
@@ -85,6 +85,7 @@ See "Hello" in your app? Just search for "Hello" in your codebase. **Done.**
85
85
  - **Locale Change Event** — Subscribe to locale changes with `onLocaleChange()` (v0.12.0)
86
86
  - **Formatting Utilities** — Locale-aware `formatNumber`, `formatDate`, `formatList` powered by `Intl` APIs (v0.13.0)
87
87
  - **Raw Template Access** -- `tRaw(key, locale?)` returns raw template string without interpolation (v0.14.0)
88
+ - **Batch Translation** -- `tBatch(keys, vars?, locale?)` translates multiple keys at once (v0.15.0)
88
89
 
89
90
  ---
90
91
 
@@ -1023,6 +1024,7 @@ Available helpers:
1023
1024
  | `formatDate(value, options?, locale?)` | Format dates and times |
1024
1025
  | `formatList(values, options?, locale?)` | Format lists (conjunction, disjunction) |
1025
1026
  | `tRaw(key, locale?)` | Get raw template string without interpolation |
1027
+ | `tBatch(keys, vars?, locale?)` | Translate multiple keys at once |
1026
1028
 
1027
1029
  ### Custom Formatters
1028
1030
 
package/dist/index.d.mts CHANGED
@@ -231,6 +231,18 @@ declare function t(key: string, vars?: TranslationVars, locale?: Locale): string
231
231
  * tRaw('common:greeting') // → "Hello"
232
232
  */
233
233
  declare function tRaw(key: string, locale?: Locale): string | undefined;
234
+ /**
235
+ * Translate multiple keys at once (v0.15.0)
236
+ * @param keys - Array of translation keys
237
+ * @param vars - Optional variables applied to all translations
238
+ * @param locale - Override locale (optional)
239
+ * @returns Object mapping each key to its translated string
240
+ *
241
+ * @example
242
+ * tBatch(['greeting', 'farewell'])
243
+ * // → { greeting: 'Hello', farewell: 'Goodbye' }
244
+ */
245
+ declare function tBatch(keys: string[], vars?: TranslationVars, locale?: Locale): Record<string, string>;
234
246
  /**
235
247
  * Check if a translation key exists
236
248
  * @param key - Translation key (may include namespace prefix)
@@ -434,4 +446,4 @@ interface RichTextSegment {
434
446
  */
435
447
  declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
436
448
 
437
- 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, tRaw, trackMissingKeys, zh_es };
449
+ 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, tBatch, tRaw, trackMissingKeys, zh_es };
package/dist/index.d.ts CHANGED
@@ -231,6 +231,18 @@ declare function t(key: string, vars?: TranslationVars, locale?: Locale): string
231
231
  * tRaw('common:greeting') // → "Hello"
232
232
  */
233
233
  declare function tRaw(key: string, locale?: Locale): string | undefined;
234
+ /**
235
+ * Translate multiple keys at once (v0.15.0)
236
+ * @param keys - Array of translation keys
237
+ * @param vars - Optional variables applied to all translations
238
+ * @param locale - Override locale (optional)
239
+ * @returns Object mapping each key to its translated string
240
+ *
241
+ * @example
242
+ * tBatch(['greeting', 'farewell'])
243
+ * // → { greeting: 'Hello', farewell: 'Goodbye' }
244
+ */
245
+ declare function tBatch(keys: string[], vars?: TranslationVars, locale?: Locale): Record<string, string>;
234
246
  /**
235
247
  * Check if a translation key exists
236
248
  * @param key - Translation key (may include namespace prefix)
@@ -434,4 +446,4 @@ interface RichTextSegment {
434
446
  */
435
447
  declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
436
448
 
437
- 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, tRaw, trackMissingKeys, zh_es };
449
+ 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, tBatch, tRaw, trackMissingKeys, zh_es };
package/dist/index.js CHANGED
@@ -989,6 +989,13 @@ function tRaw(key, locale) {
989
989
  }
990
990
  return void 0;
991
991
  }
992
+ function tBatch(keys, vars, locale) {
993
+ const result = {};
994
+ for (const key of keys) {
995
+ result[key] = t(key, vars, locale);
996
+ }
997
+ return result;
998
+ }
992
999
  function hasTranslation(key, locale, context) {
993
1000
  const { namespace, key: actualKey } = parseKey(key);
994
1001
  const currentLocale2 = locale ?? getLocale();
@@ -1262,6 +1269,7 @@ exports.resetConfig = resetConfig;
1262
1269
  exports.restoreLocale = restoreLocale;
1263
1270
  exports.setLocale = setLocale;
1264
1271
  exports.t = t;
1272
+ exports.tBatch = tBatch;
1265
1273
  exports.tRaw = tRaw;
1266
1274
  exports.trackMissingKeys = trackMissingKeys;
1267
1275
  exports.zh_es = zh_es;