inline-i18n-multi 0.15.0 → 0.16.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
@@ -86,6 +86,7 @@ See "Hello" in your app? Just search for "Hello" in your codebase. **Done.**
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
88
  - **Batch Translation** -- `tBatch(keys, vars?, locale?)` translates multiple keys at once (v0.15.0)
89
+ - **Missing Locales Detection** -- `getMissingLocales(key)` returns locales where a key is absent (v0.16.0)
89
90
 
90
91
  ---
91
92
 
@@ -1025,6 +1026,7 @@ Available helpers:
1025
1026
  | `formatList(values, options?, locale?)` | Format lists (conjunction, disjunction) |
1026
1027
  | `tRaw(key, locale?)` | Get raw template string without interpolation |
1027
1028
  | `tBatch(keys, vars?, locale?)` | Translate multiple keys at once |
1029
+ | `getMissingLocales(key)` | List locales missing a translation key |
1028
1030
 
1029
1031
  ### Custom Formatters
1030
1032
 
package/dist/index.d.mts CHANGED
@@ -250,6 +250,20 @@ declare function tBatch(keys: string[], vars?: TranslationVars, locale?: Locale)
250
250
  * @param context - Optional context for contextual translations (v0.9.0)
251
251
  */
252
252
  declare function hasTranslation(key: string, locale?: Locale, context?: string): boolean;
253
+ /**
254
+ * Get all locales where a translation key is missing (v0.16.0)
255
+ * Inverse of `hasTranslation` — checks every loaded locale in the key's namespace
256
+ * and returns those that do not contain the key.
257
+ *
258
+ * @param key - Translation key (may include namespace prefix)
259
+ * @returns Array of locale codes missing the key
260
+ *
261
+ * @example
262
+ * loadDictionaries({ en: { hello: 'Hi' }, ko: { hello: '안녕' }, ja: {} })
263
+ * getMissingLocales('hello') // → ['ja']
264
+ * getMissingLocales('common:greeting') // → ['en', 'ko', 'ja'] (key missing in all)
265
+ */
266
+ declare function getMissingLocales(key: string): Locale[];
253
267
  /**
254
268
  * Get all loaded locales
255
269
  * @param namespace - Optional namespace (returns from all if not specified)
@@ -446,4 +460,4 @@ interface RichTextSegment {
446
460
  */
447
461
  declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
448
462
 
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 };
463
+ 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, getMissingLocales, 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
@@ -250,6 +250,20 @@ declare function tBatch(keys: string[], vars?: TranslationVars, locale?: Locale)
250
250
  * @param context - Optional context for contextual translations (v0.9.0)
251
251
  */
252
252
  declare function hasTranslation(key: string, locale?: Locale, context?: string): boolean;
253
+ /**
254
+ * Get all locales where a translation key is missing (v0.16.0)
255
+ * Inverse of `hasTranslation` — checks every loaded locale in the key's namespace
256
+ * and returns those that do not contain the key.
257
+ *
258
+ * @param key - Translation key (may include namespace prefix)
259
+ * @returns Array of locale codes missing the key
260
+ *
261
+ * @example
262
+ * loadDictionaries({ en: { hello: 'Hi' }, ko: { hello: '안녕' }, ja: {} })
263
+ * getMissingLocales('hello') // → ['ja']
264
+ * getMissingLocales('common:greeting') // → ['en', 'ko', 'ja'] (key missing in all)
265
+ */
266
+ declare function getMissingLocales(key: string): Locale[];
253
267
  /**
254
268
  * Get all loaded locales
255
269
  * @param namespace - Optional namespace (returns from all if not specified)
@@ -446,4 +460,4 @@ interface RichTextSegment {
446
460
  */
447
461
  declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
448
462
 
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 };
463
+ 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, getMissingLocales, 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
@@ -1008,6 +1008,18 @@ function hasTranslation(key, locale, context) {
1008
1008
  }
1009
1009
  return getNestedValue(dict, actualKey) !== void 0;
1010
1010
  }
1011
+ function getMissingLocales(key) {
1012
+ const { namespace, key: actualKey } = parseKey(key);
1013
+ const nsDictionaries = namespacedDictionaries[namespace] || {};
1014
+ const missing = [];
1015
+ for (const locale of Object.keys(nsDictionaries)) {
1016
+ const dict = nsDictionaries[locale];
1017
+ if (!dict || getNestedValue(dict, actualKey) === void 0) {
1018
+ missing.push(locale);
1019
+ }
1020
+ }
1021
+ return missing;
1022
+ }
1011
1023
  function getLoadedLocales(namespace) {
1012
1024
  if (namespace) {
1013
1025
  return Object.keys(namespacedDictionaries[namespace] || {});
@@ -1248,6 +1260,7 @@ exports.getLoadedNamespaces = getLoadedNamespaces;
1248
1260
  exports.getLocale = getLocale;
1249
1261
  exports.getLocaleDisplayName = getLocaleDisplayName;
1250
1262
  exports.getMissingKeys = getMissingKeys;
1263
+ exports.getMissingLocales = getMissingLocales;
1251
1264
  exports.getTranslationKeys = getTranslationKeys;
1252
1265
  exports.hasTranslation = hasTranslation;
1253
1266
  exports.isLoaded = isLoaded;