inline-i18n-multi 0.17.0 → 0.18.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/dist/index.mjs CHANGED
@@ -936,7 +936,7 @@ function t(key, vars, locale) {
936
936
  }
937
937
  }
938
938
  if (!template) {
939
- recordMissingKey(key);
939
+ recordMissingKey(key, currentLocale2);
940
940
  emitWarning({
941
941
  type: "missing_translation",
942
942
  key,
@@ -1087,6 +1087,16 @@ function getTranslationKeys(locale, namespace) {
1087
1087
  }
1088
1088
  var missingKeys = /* @__PURE__ */ new Set();
1089
1089
  var trackMissing = false;
1090
+ var missingKeyListeners = /* @__PURE__ */ new Set();
1091
+ function onMissingKey(callback) {
1092
+ missingKeyListeners.add(callback);
1093
+ return () => {
1094
+ missingKeyListeners.delete(callback);
1095
+ };
1096
+ }
1097
+ function clearMissingKeyListeners() {
1098
+ missingKeyListeners.clear();
1099
+ }
1090
1100
  function trackMissingKeys(enabled) {
1091
1101
  trackMissing = enabled;
1092
1102
  if (!enabled) {
@@ -1099,10 +1109,16 @@ function getMissingKeys() {
1099
1109
  function clearMissingKeys() {
1100
1110
  missingKeys = /* @__PURE__ */ new Set();
1101
1111
  }
1102
- function recordMissingKey(key) {
1112
+ function recordMissingKey(key, locale) {
1103
1113
  if (trackMissing) {
1104
1114
  missingKeys.add(key);
1105
1115
  }
1116
+ if (missingKeyListeners.size > 0) {
1117
+ const loc = locale ?? getLocale();
1118
+ for (const cb of missingKeyListeners) {
1119
+ cb(key, loc);
1120
+ }
1121
+ }
1106
1122
  }
1107
1123
 
1108
1124
  // src/detect.ts
@@ -1246,6 +1262,6 @@ function parseRichText(template, componentNames) {
1246
1262
  return segments;
1247
1263
  }
1248
1264
 
1249
- export { __i18n_lookup, clearDictionaries, clearFormatters, clearICUCache, clearLocaleListeners, clearMissingKeys, configure, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, formatDate, formatList, formatNumber, getCompletenessRatio, 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 };
1265
+ export { __i18n_lookup, clearDictionaries, clearFormatters, clearICUCache, clearLocaleListeners, clearMissingKeyListeners, clearMissingKeys, configure, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, formatDate, formatList, formatNumber, getCompletenessRatio, 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, onMissingKey, parseRichText, registerFormatter, resetConfig, restoreLocale, setLocale, t, tBatch, tRaw, trackMissingKeys, zh_es };
1250
1266
  //# sourceMappingURL=index.mjs.map
1251
1267
  //# sourceMappingURL=index.mjs.map