inline-i18n-multi 0.13.0 → 0.14.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 +2 -0
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,6 +84,7 @@ See "Hello" in your app? Just search for "Hello" in your codebase. **Done.**
|
|
|
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
86
|
- **Formatting Utilities** — Locale-aware `formatNumber`, `formatDate`, `formatList` powered by `Intl` APIs (v0.13.0)
|
|
87
|
+
- **Raw Template Access** -- `tRaw(key, locale?)` returns raw template string without interpolation (v0.14.0)
|
|
87
88
|
|
|
88
89
|
---
|
|
89
90
|
|
|
@@ -1021,6 +1022,7 @@ Available helpers:
|
|
|
1021
1022
|
| `formatNumber(value, options?, locale?)` | Format numbers (currency, percent, etc.) |
|
|
1022
1023
|
| `formatDate(value, options?, locale?)` | Format dates and times |
|
|
1023
1024
|
| `formatList(values, options?, locale?)` | Format lists (conjunction, disjunction) |
|
|
1025
|
+
| `tRaw(key, locale?)` | Get raw template string without interpolation |
|
|
1024
1026
|
|
|
1025
1027
|
### Custom Formatters
|
|
1026
1028
|
|
package/dist/index.d.mts
CHANGED
|
@@ -219,6 +219,18 @@ declare function isLoaded(locale: Locale, namespace?: string): boolean;
|
|
|
219
219
|
* t('items.count', { count: 5 }) // "5 items"
|
|
220
220
|
*/
|
|
221
221
|
declare function t(key: string, vars?: TranslationVars, locale?: Locale): string;
|
|
222
|
+
/**
|
|
223
|
+
* Get the raw template string for a translation key without interpolation (v0.14.0)
|
|
224
|
+
* Returns undefined if the key is not found.
|
|
225
|
+
*
|
|
226
|
+
* @param key - Dot-separated translation key, optionally prefixed with namespace
|
|
227
|
+
* @param locale - Override locale (optional)
|
|
228
|
+
* @example
|
|
229
|
+
* tRaw('welcome') // → "Welcome, {name}!"
|
|
230
|
+
* tRaw('items.count', 'ko') // → "{count}개 항목"
|
|
231
|
+
* tRaw('common:greeting') // → "Hello"
|
|
232
|
+
*/
|
|
233
|
+
declare function tRaw(key: string, locale?: Locale): string | undefined;
|
|
222
234
|
/**
|
|
223
235
|
* Check if a translation key exists
|
|
224
236
|
* @param key - Translation key (may include namespace prefix)
|
|
@@ -422,4 +434,4 @@ interface RichTextSegment {
|
|
|
422
434
|
*/
|
|
423
435
|
declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
|
|
424
436
|
|
|
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -219,6 +219,18 @@ declare function isLoaded(locale: Locale, namespace?: string): boolean;
|
|
|
219
219
|
* t('items.count', { count: 5 }) // "5 items"
|
|
220
220
|
*/
|
|
221
221
|
declare function t(key: string, vars?: TranslationVars, locale?: Locale): string;
|
|
222
|
+
/**
|
|
223
|
+
* Get the raw template string for a translation key without interpolation (v0.14.0)
|
|
224
|
+
* Returns undefined if the key is not found.
|
|
225
|
+
*
|
|
226
|
+
* @param key - Dot-separated translation key, optionally prefixed with namespace
|
|
227
|
+
* @param locale - Override locale (optional)
|
|
228
|
+
* @example
|
|
229
|
+
* tRaw('welcome') // → "Welcome, {name}!"
|
|
230
|
+
* tRaw('items.count', 'ko') // → "{count}개 항목"
|
|
231
|
+
* tRaw('common:greeting') // → "Hello"
|
|
232
|
+
*/
|
|
233
|
+
declare function tRaw(key: string, locale?: Locale): string | undefined;
|
|
222
234
|
/**
|
|
223
235
|
* Check if a translation key exists
|
|
224
236
|
* @param key - Translation key (may include namespace prefix)
|
|
@@ -422,4 +434,4 @@ interface RichTextSegment {
|
|
|
422
434
|
*/
|
|
423
435
|
declare function parseRichText(template: string, componentNames: string[]): RichTextSegment[];
|
|
424
436
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -976,6 +976,19 @@ function t(key, vars, locale) {
|
|
|
976
976
|
};
|
|
977
977
|
return applyDebugFormat(result, debugInfo);
|
|
978
978
|
}
|
|
979
|
+
function tRaw(key, locale) {
|
|
980
|
+
const { namespace, key: actualKey } = parseKey(key);
|
|
981
|
+
const currentLocale2 = locale ?? getLocale();
|
|
982
|
+
const fallbackChain = buildFallbackChain(currentLocale2);
|
|
983
|
+
const nsDictionaries = namespacedDictionaries[namespace] || {};
|
|
984
|
+
for (const tryLocale of fallbackChain) {
|
|
985
|
+
const dict = nsDictionaries[tryLocale];
|
|
986
|
+
if (!dict) continue;
|
|
987
|
+
const found = getNestedValue(dict, actualKey);
|
|
988
|
+
if (found !== void 0) return found;
|
|
989
|
+
}
|
|
990
|
+
return void 0;
|
|
991
|
+
}
|
|
979
992
|
function hasTranslation(key, locale, context) {
|
|
980
993
|
const { namespace, key: actualKey } = parseKey(key);
|
|
981
994
|
const currentLocale2 = locale ?? getLocale();
|
|
@@ -1249,6 +1262,7 @@ exports.resetConfig = resetConfig;
|
|
|
1249
1262
|
exports.restoreLocale = restoreLocale;
|
|
1250
1263
|
exports.setLocale = setLocale;
|
|
1251
1264
|
exports.t = t;
|
|
1265
|
+
exports.tRaw = tRaw;
|
|
1252
1266
|
exports.trackMissingKeys = trackMissingKeys;
|
|
1253
1267
|
exports.zh_es = zh_es;
|
|
1254
1268
|
//# sourceMappingURL=index.js.map
|