@mmstack/translate 21.1.10 → 21.1.12

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
@@ -164,7 +164,8 @@ export default createQuoteTranslation('sl-SI', {
164
164
  errors: {
165
165
  minLength: 'Citat mora imeti vsaj {min} znakov.', // Variables must match original
166
166
  },
167
- stats: '{count, plural, =1 {# citat} =2 {# citata} few {# citati} other {# citatov}} na voljo',
167
+ stats:
168
+ '{count, plural, =1 {# citat} =2 {# citata} few {# citati} other {# citatov}} na voljo',
168
169
  });
169
170
  ```
170
171
 
@@ -223,7 +224,10 @@ export class QuoteTranslator extends Translator<QuoteLocale> {}
223
224
  @Directive({
224
225
  selector: '[translate]', // Input in Translate is named 'translate'
225
226
  })
226
- export class QuoteTranslate<TInput extends string> extends Translate<TInput, QuoteLocale> {}
227
+ export class QuoteTranslate<TInput extends string> extends Translate<
228
+ TInput,
229
+ QuoteLocale
230
+ > {}
227
231
  ```
228
232
 
229
233
  ### 3. Use Translations in Components
@@ -320,7 +324,8 @@ export const routes: Routes = [
320
324
  children: [
321
325
  {
322
326
  path: 'quotes',
323
- loadChildren: () => import('./quote/quote.routes').then((m) => m.QUOTE_ROUTES),
327
+ loadChildren: () =>
328
+ import('./quote/quote.routes').then((m) => m.QUOTE_ROUTES),
324
329
  },
325
330
  // ... other routes
326
331
  ],
@@ -402,6 +407,23 @@ Due to Angular's memoization, pure pipes don't automatically react to locale cha
402
407
  export class QuoteTranslator extends Translator<QuoteLocale> {}
403
408
  ```
404
409
 
410
+ **Persisting the selected locale:**
411
+
412
+ If you want the user's last selected locale to survive page reloads, pass a `localeStorage` adapter to `provideIntlConfig()`. The library calls `read()` once on init to restore the previous selection, and `write()` whenever the active locale changes — you decide where it lives (localStorage, cookies, IndexedDB-with-sync-wrapper, etc.).
413
+
414
+ ```typescript
415
+ provideIntlConfig({
416
+ defaultLocale: 'en-US',
417
+ supportedLocales: ['en-US', 'sl-SI', 'de-DE'],
418
+ localeStorage: {
419
+ read: () => localStorage.getItem('locale'),
420
+ write: (locale) => localStorage.setItem('locale', locale),
421
+ },
422
+ });
423
+ ```
424
+
425
+ Stored values are validated against `supportedLocales` before being applied — anything unrecognized is ignored and the default applies. Errors thrown from `read()` / `write()` are swallowed (and logged in dev mode) so a misbehaving storage backend can't break the app. `localeStorage` is mutually exclusive with `localeParamName` at the type level — when the URL is the source of truth, persisting separately would just fight it.
426
+
405
427
  ### 6. [OPTIONAL] Creating a Shared/Common Namespace
406
428
 
407
429
  A shared namespace allows you to define common translations (e.g., 'Save', 'Cancel', 'Yes', 'No') once and use them type-safely across all other namespaces.
@@ -434,9 +456,12 @@ export const createAppNamespace = ns.createMergedNamespace;
434
456
  // common.t.ts
435
457
  import { registerNamespace } from '@mmstack/translate';
436
458
 
437
- const r = registerNamespace(() => import('./common.namespace').then((m) => m.default), {
438
- 'sl-SI': () => import('./common-sl.translation').then((m) => m.default),
439
- });
459
+ const r = registerNamespace(
460
+ () => import('./common.namespace').then((m) => m.default),
461
+ {
462
+ 'sl-SI': () => import('./common-sl.translation').then((m) => m.default),
463
+ },
464
+ );
440
465
 
441
466
  export const injectCommonT = r.injectNamespaceT;
442
467
  export const resolveCommonTranslations = r.resolveNamespaceTranslation;
@@ -547,9 +572,13 @@ For cases where you need to load translations from a remote API (where keys aren
547
572
  import { registerRemoteNamespace } from '@mmstack/translate';
548
573
 
549
574
  // Returns an untyped t function: t('any.key')
550
- const { injectNamespaceT: injectRemoteT } = registerRemoteNamespace('remote', () => fetch('/api/en').then((r) => r.json()), {
551
- 'sl-SI': () => fetch('/api/sl').then((r) => r.json()),
552
- });
575
+ const { injectNamespaceT: injectRemoteT } = registerRemoteNamespace(
576
+ 'remote',
577
+ () => fetch('/api/en').then((r) => r.json()),
578
+ {
579
+ 'sl-SI': () => fetch('/api/sl').then((r) => r.json()),
580
+ },
581
+ );
553
582
 
554
583
  // usage
555
584
  const t = injectRemoteT();
@@ -626,7 +655,9 @@ describe('MyComponent', () => {
626
655
  fixture.detectChanges();
627
656
 
628
657
  // By default, it echoes back the flattened object key using dot notation
629
- expect(fixture.nativeElement.textContent).toContain('myNamespace.greeting.title');
658
+ expect(fixture.nativeElement.textContent).toContain(
659
+ 'myNamespace.greeting.title',
660
+ );
630
661
  });
631
662
 
632
663
  it('allows providing explicit mock overrides', () => {
@@ -687,6 +718,64 @@ If you're migrating from a runtime-only solution:
687
718
  4. Convert your translation JSON files to TypeScript using `createNamespace`
688
719
  5. Update component/template usage to use the type-safe APIs
689
720
 
721
+ ## Escape Hatches
722
+
723
+ Sometimes we all hit the limit of an api & need imperitive escape hatches for those edge cases. These are the ones mmstack/translate currently provides:
724
+
725
+ **`withParams()`**
726
+
727
+ Type-level parameter inference is one level deep — variables inside `plural` / `select` / `selectordinal` arms aren't picked up (e.g. the `{name}` inside `{count, plural, one {Hi {name}} ...}`). For those cases, wrap the message with `withParams<P>(...)` to declare the missing params explicitly:
728
+
729
+ ```typescript
730
+ import { createNamespace, withParams } from '@mmstack/translate';
731
+
732
+ const ns = createNamespace('quote', {
733
+ // auto-extracts `count`; `name` is declared because it lives inside the arms
734
+ stats: withParams<{ name: string }>(
735
+ '{count, plural, one {1 quote from {name}} other {# quotes from {name}}}',
736
+ ),
737
+ });
738
+
739
+ // t inferred as: ('quote.stats', { count: number; name: string }) => string
740
+ t('quote.stats', { count: 3, name: 'Alice' });
741
+ ```
742
+
743
+ Declared params are merged with auto-extracted ones; on key conflict, declared wins. Non-default locales for a wrapped key don't need to repeat the helper — they accept any string:
744
+
745
+ ```typescript
746
+ createQuoteTranslation('sl-SI', {
747
+ stats: '{count, plural, =1 {1 citat od {name}} other {# citatov od {name}}}',
748
+ });
749
+ ```
750
+
751
+ Trade-off: wrapping a key opts out of template-literal shape strictness for that key in non-default locales (the auto-validation that requires placeholders to appear in the right positions). The library still enforces top-level placeholders for non-wrapped keys.
752
+
753
+ **`injectAddTranslations()`**
754
+ Allows adding flat, per-locale translations to any namespace at runtime.
755
+
756
+ ```typescript
757
+ import { injectAddTranslations } from '@mmstack/translate';
758
+
759
+ const addTranslations = injectAddTranslations();
760
+ addTranslations('dynamicNs', {
761
+ 'en-US': { greeting: 'Hello {name}!' },
762
+ 'sl-SI': { greeting: 'Zdravo {name}!' },
763
+ });
764
+ ```
765
+
766
+ **`injectUnsafeT()`**
767
+ Returns a fully untyped translation function `t('anyNamespace.key')`. Ideal for reading dynamically added keys or cross-namespace lookups where the typed API would be impractical.
768
+
769
+ ```typescript
770
+ import { injectUnsafeT } from '@mmstack/translate';
771
+
772
+ const t = injectUnsafeT();
773
+ const greeting = t('dynamicNs.greeting', { name: 'Alice' });
774
+ const signalGreeting = t.asSignal('dynamicNs.greeting', () => ({
775
+ name: 'Alice',
776
+ }));
777
+ ```
778
+
690
779
  ## Contributing
691
780
 
692
781
  Contributions, issues, and feature requests are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { computed, inject, InjectionToken, LOCALE_ID, signal, resource, untracked, isDevMode, effect, Injectable, isSignal, input, Renderer2, ElementRef, afterRenderEffect, Directive, ChangeDetectorRef } from '@angular/core';
2
+ import { computed, inject, InjectionToken, LOCALE_ID, signal, isDevMode, effect, resource, untracked, Injectable, isSignal, input, Renderer2, ElementRef, afterRenderEffect, Directive, ChangeDetectorRef } from '@angular/core';
3
3
  import { createIntlCache, createIntl } from '@formatjs/intl';
4
4
  import { toSignal } from '@angular/core/rxjs-interop';
5
5
  import { Router, ActivatedRoute } from '@angular/router';
@@ -135,6 +135,40 @@ const STORE_LOCALE = signal('en-US', ...(ngDevMode ? [{ debugName: "STORE_LOCALE
135
135
  function injectLocaleInternal() {
136
136
  return STORE_LOCALE;
137
137
  }
138
+ function isDynamicConfig(cfg) {
139
+ return !!cfg && 'localeStorage' in cfg && !!cfg.localeStorage;
140
+ }
141
+ function initLocale(src) {
142
+ const config = injectIntlConfig();
143
+ const defaultValue = injectDefaultLocale();
144
+ if (!isDynamicConfig(config)) {
145
+ src.set(defaultValue);
146
+ return src;
147
+ }
148
+ let next = null;
149
+ try {
150
+ const stored = config.localeStorage.read();
151
+ if (stored !== null &&
152
+ (!config.supportedLocales || config.supportedLocales.includes(stored))) {
153
+ next = stored;
154
+ }
155
+ }
156
+ catch (e) {
157
+ if (isDevMode())
158
+ console.error('[Translate] Failed to read stored locale from localeStorage', e);
159
+ }
160
+ src.set(next ?? defaultValue);
161
+ effect(() => {
162
+ try {
163
+ config.localeStorage.write(src());
164
+ }
165
+ catch (e) {
166
+ if (isDevMode())
167
+ console.error('[Translate] Failed to write locale to localeStorage', e);
168
+ }
169
+ });
170
+ return src;
171
+ }
138
172
  class TranslationStore {
139
173
  simpleKeyMap = new Map();
140
174
  cache = createIntlCache();
@@ -196,8 +230,7 @@ class TranslationStore {
196
230
  messages: this.messages(),
197
231
  }, this.cache), ...(ngDevMode ? [{ debugName: "intl" }] : /* istanbul ignore next */ []));
198
232
  constructor() {
199
- this.locale = STORE_LOCALE;
200
- this.locale.set(injectDefaultLocale());
233
+ this.locale = initLocale(STORE_LOCALE);
201
234
  const paramName = this.config?.localeParamName;
202
235
  if (paramName) {
203
236
  const param = pathParam(paramName);
@@ -287,10 +320,10 @@ class TranslationStore {
287
320
  hasLocaleLoaders(locale) {
288
321
  return Array.from(this.onDemandLoaders.values()).some((loaders) => loaders[locale]);
289
322
  }
290
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TranslationStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
291
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TranslationStore, providedIn: 'root' });
323
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TranslationStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
324
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TranslationStore, providedIn: 'root' });
292
325
  }
293
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TranslationStore, decorators: [{
326
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TranslationStore, decorators: [{
294
327
  type: Injectable,
295
328
  args: [{
296
329
  providedIn: 'root',
@@ -347,6 +380,49 @@ function injectDynamicLocale() {
347
380
  source.isLoading = store.dynamicLocaleLoader.isLoading;
348
381
  return source;
349
382
  }
383
+ /**
384
+ * Power-user escape hatch for adding translations imperatively (e.g. content
385
+ * loaded from a remote API after bootstrap). Returns a function that registers
386
+ * a flat per-locale map of keys under a given namespace
387
+ *
388
+ * Pair with {@link injectUnsafeT} to read the added keys without compile-time
389
+ * constraints.
390
+ *
391
+ * @example
392
+ * ```ts
393
+ * const addTranslations = injectAddTranslations();
394
+ * addTranslations('remote', {
395
+ * 'en-US': { greeting: 'Hi {name}' },
396
+ * 'sl-SI': { greeting: 'Zdravo {name}' },
397
+ * });
398
+ * ```
399
+ */
400
+ function injectAddTranslations() {
401
+ const store = inject(TranslationStore);
402
+ const supportedLocales = injectIntlConfig()?.supportedLocales;
403
+ const supportedLocalesSet = supportedLocales
404
+ ? new Set(supportedLocales)
405
+ : null;
406
+ const validate = supportedLocalesSet
407
+ ? (translations) => {
408
+ const clean = {};
409
+ const invalidLocales = [];
410
+ for (const [locale, translation] of Object.entries(translations)) {
411
+ if (!supportedLocalesSet.has(locale)) {
412
+ invalidLocales.push(locale);
413
+ continue;
414
+ }
415
+ clean[locale] = translation;
416
+ }
417
+ if (isDevMode() && invalidLocales.length > 0)
418
+ console.warn(`[Translate] Attempted to add translations for unsupported locales: ${invalidLocales.join(', ')}. These translations were ignored. Supported locales are: ${(supportedLocales ?? []).join(', ')}.`);
419
+ return clean;
420
+ }
421
+ : (translations) => translations;
422
+ return (ns, translations) => {
423
+ store.register(ns, validate(translations));
424
+ };
425
+ }
350
426
 
351
427
  function unwrap(value) {
352
428
  return isSignal(value) ? value() : value;
@@ -774,6 +850,58 @@ function registerRemoteNamespace(ns, defaultTranslation, other) {
774
850
  resolveNamespaceTranslation: resolver,
775
851
  };
776
852
  }
853
+ class UnsafeTKeyMap {
854
+ map = new Map();
855
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: UnsafeTKeyMap, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
856
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: UnsafeTKeyMap, providedIn: 'root' });
857
+ }
858
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: UnsafeTKeyMap, decorators: [{
859
+ type: Injectable,
860
+ args: [{
861
+ providedIn: 'root',
862
+ }]
863
+ }] });
864
+ /**
865
+ * Power-user escape hatch that returns a fully untyped translation function.
866
+ * Intended for use alongside {@link injectAddTranslations} when translations
867
+ * are added imperatively (e.g. from a remote API), or for cross-namespace
868
+ * lookups where the typed API would be impractical.
869
+ *
870
+ * @example
871
+ * ```ts
872
+ * const t = injectUnsafeT();
873
+ * t('any.namespace.key', { name: 'Alice', count: 3 });
874
+ * const sig = t.asSignal('any.namespace.key', () => ({ name: name() }));
875
+ * ```
876
+ */
877
+ function injectUnsafeT() {
878
+ const store = inject(TranslationStore);
879
+ const map = inject(UnsafeTKeyMap).map;
880
+ const fn = (key, params) => {
881
+ let k = map.get(key);
882
+ if (k === undefined) {
883
+ k = replaceWithDelim(key);
884
+ map.set(key, k);
885
+ }
886
+ return store.formatMessage(k, params);
887
+ };
888
+ fn.asSignal = (key, params) => {
889
+ let k = map.get(key);
890
+ if (k === undefined) {
891
+ k = replaceWithDelim(key);
892
+ map.set(key, k);
893
+ }
894
+ if (!params)
895
+ return store.buildSimpleKeySignal(k);
896
+ const paramsSignal = isSignal(params)
897
+ ? params
898
+ : computed(() => params(), {
899
+ equal: createEqualsRecord(Object.keys(params())),
900
+ });
901
+ return computed(() => store.formatMessage(k, paramsSignal()));
902
+ };
903
+ return fn;
904
+ }
777
905
 
778
906
  /**
779
907
  * Guard that validates the locale parameter against supported locales.
@@ -804,6 +932,72 @@ function canMatchLocale(prefixSegments = []) {
804
932
  };
805
933
  }
806
934
 
935
+ /**
936
+ * Provides an isolated mock `TranslationStore` usable across testing modules that use components
937
+ * depending on `@mmstack/translate` APIs (like `Translate` directive, `Translator` pipe, or `injectNamespaceT`).
938
+ *
939
+ * This provider intercepts all translation logic, bypassing chunk loaders and Intl.
940
+ * When a custom configuration isn't provided, formatMessage simply echoes the translation key, using dots `.`.
941
+ *
942
+ * ### Usage
943
+ * ```typescript
944
+ * TestBed.configureTestingModule({
945
+ * providers: [provideMockTranslations()]
946
+ * });
947
+ * ```
948
+ */
949
+ function provideMockTranslations(options) {
950
+ // We compile the mock strings to flat delimiters just like the internal compile module.
951
+ const mappedMocks = {};
952
+ if (options?.translations) {
953
+ for (const [namespace, translationObj] of Object.entries(options.translations)) {
954
+ const compiled = compileTranslation(translationObj, namespace);
955
+ for (const [key, val] of Object.entries(compiled.flat)) {
956
+ // e.g. from 'home::MMT_DELIM::title'
957
+ const fullKey = `${namespace}::MMT_DELIM::${key}`;
958
+ mappedMocks[fullKey] = val;
959
+ }
960
+ }
961
+ }
962
+ const locale = options?.locale ?? 'en-US';
963
+ let intl;
964
+ if (options?.formatValues) {
965
+ intl = createIntl({ locale, messages: mappedMocks }, createIntlCache());
966
+ }
967
+ return [
968
+ {
969
+ provide: TranslationStore,
970
+ useValue: {
971
+ locale: signal(locale),
972
+ formatMessage: (key, values) => {
973
+ const message = mappedMocks[key];
974
+ if (!message) {
975
+ // Fallback to echoing the key back in dot notation (more readable for unit assertions).
976
+ return key.replaceAll('::MMT_DELIM::', '.');
977
+ }
978
+ if (intl) {
979
+ return intl.formatMessage({ id: key, defaultMessage: message }, values);
980
+ }
981
+ return message;
982
+ },
983
+ hasLocaleLoaders: () => false,
984
+ register: () => {
985
+ // noop
986
+ },
987
+ registerOnDemandLoaders: () => {
988
+ // noop
989
+ },
990
+ dynamicLocaleLoader: {
991
+ isLoading: signal(false),
992
+ value: signal(null),
993
+ error: signal(null),
994
+ },
995
+ loadQueue: signal([]),
996
+ },
997
+ },
998
+ ];
999
+ }
1000
+
807
1001
  function compareObjects(a, b) {
808
1002
  if (!a && !b)
809
1003
  return true;
@@ -842,10 +1036,10 @@ class Translate {
842
1036
  },
843
1037
  });
844
1038
  }
845
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Translate, deps: [], target: i0.ɵɵFactoryTarget.Directive });
846
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.8", type: Translate, isStandalone: true, inputs: { translate: { classPropertyName: "translate", publicName: "translate", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
1039
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: Translate, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1040
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.12", type: Translate, isStandalone: true, inputs: { translate: { classPropertyName: "translate", publicName: "translate", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
847
1041
  }
848
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Translate, decorators: [{
1042
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: Translate, decorators: [{
849
1043
  type: Directive
850
1044
  }], ctorParameters: () => [], propDecorators: { translate: [{ type: i0.Input, args: [{ isSignal: true, alias: "translate", required: true }] }] } });
851
1045
 
@@ -873,74 +1067,35 @@ class Translator {
873
1067
  }
874
1068
 
875
1069
  /**
876
- * Provides an isolated mock `TranslationStore` usable across testing modules that use components
877
- * depending on `@mmstack/translate` APIs (like `Translate` directive, `Translator` pipe, or `injectNamespaceT`).
1070
+ * Power-user escape hatch for ICU messages whose parameters can't be inferred
1071
+ * from the message string typically variables nested inside `plural` /
1072
+ * `select` / `selectordinal` arms, which the type-level extractor skips.
878
1073
  *
879
- * This provider intercepts all translation logic, bypassing chunk loaders and Intl.
880
- * When a custom configuration isn't provided, formatMessage simply echoes the translation key, using dots `.`.
1074
+ * Declared params are merged with auto-extracted ones; on key conflict, the
1075
+ * declared params win. Non-default locales for a key wrapped with `withParams`
1076
+ * may be plain strings — they don't need to repeat the wrapper.
881
1077
  *
882
- * ### Usage
883
- * ```typescript
884
- * TestBed.configureTestingModule({
885
- * providers: [provideMockTranslations()]
1078
+ * @example
1079
+ * ```ts
1080
+ * const ns = createNamespace('quote', {
1081
+ * // auto-extracts `count`; `name` is declared explicitly because it
1082
+ * // lives inside the plural arms and can't be inferred
1083
+ * stats: withParams<{ name: string }>(
1084
+ * '{count, plural, one {1 quote from {name}} other {# quotes from {name}}}',
1085
+ * ),
886
1086
  * });
1087
+ *
1088
+ * // t inferred as: (key, { count: number; name: string }) => string
1089
+ * t('quote.stats', { count: 3, name: 'Alice' });
887
1090
  * ```
888
1091
  */
889
- function provideMockTranslations(options) {
890
- // We compile the mock strings to flat delimiters just like the internal compile module.
891
- const mappedMocks = {};
892
- if (options?.translations) {
893
- for (const [namespace, translationObj] of Object.entries(options.translations)) {
894
- const compiled = compileTranslation(translationObj, namespace);
895
- for (const [key, val] of Object.entries(compiled.flat)) {
896
- // e.g. from 'home::MMT_DELIM::title'
897
- const fullKey = `${namespace}::MMT_DELIM::${key}`;
898
- mappedMocks[fullKey] = val;
899
- }
900
- }
901
- }
902
- const locale = options?.locale ?? 'en-US';
903
- let intl;
904
- if (options?.formatValues) {
905
- intl = createIntl({ locale, messages: mappedMocks }, createIntlCache());
906
- }
907
- return [
908
- {
909
- provide: TranslationStore,
910
- useValue: {
911
- locale: signal(locale),
912
- formatMessage: (key, values) => {
913
- const message = mappedMocks[key];
914
- if (!message) {
915
- // Fallback to echoing the key back in dot notation (more readable for unit assertions).
916
- return key.replaceAll('::MMT_DELIM::', '.');
917
- }
918
- if (intl) {
919
- return intl.formatMessage({ id: key, defaultMessage: message }, values);
920
- }
921
- return message;
922
- },
923
- hasLocaleLoaders: () => false,
924
- register: () => {
925
- // noop
926
- },
927
- registerOnDemandLoaders: () => {
928
- // noop
929
- },
930
- dynamicLocaleLoader: {
931
- isLoading: signal(false),
932
- value: signal(null),
933
- error: signal(null),
934
- },
935
- loadQueue: signal([]),
936
- },
937
- },
938
- ];
1092
+ function withParams(message) {
1093
+ return message;
939
1094
  }
940
1095
 
941
1096
  /**
942
1097
  * Generated bundle index. Do not edit.
943
1098
  */
944
1099
 
945
- export { Translate, Translator, canMatchLocale, compileTranslation, createNamespace, formatCurrency, formatDate, formatDisplayName, formatList, formatNumber, formatPercent, formatRelativeTime, injectDynamicLocale, injectIntl, injectResolveParamLocale, injectSupportedLocales, provideIntlConfig, provideMockTranslations, registerNamespace, registerRemoteNamespace };
1100
+ export { Translate, Translator, canMatchLocale, compileTranslation, createNamespace, formatCurrency, formatDate, formatDisplayName, formatList, formatNumber, formatPercent, formatRelativeTime, injectAddTranslations, injectDynamicLocale, injectIntl, injectResolveParamLocale, injectSupportedLocales, injectUnsafeT, provideIntlConfig, provideMockTranslations, registerNamespace, registerRemoteNamespace, withParams };
946
1101
  //# sourceMappingURL=mmstack-translate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mmstack-translate.mjs","sources":["../../../../packages/translate/src/lib/delim.ts","../../../../packages/translate/src/lib/compile.ts","../../../../packages/translate/src/lib/create-namespace.ts","../../../../packages/translate/src/lib/path-param.ts","../../../../packages/translate/src/lib/translation-store.ts","../../../../packages/translate/src/lib/format/unwrap.ts","../../../../packages/translate/src/lib/format/date.ts","../../../../packages/translate/src/lib/format/display-name.ts","../../../../packages/translate/src/lib/format/list.ts","../../../../packages/translate/src/lib/format/numeric.ts","../../../../packages/translate/src/lib/format/relative-time.ts","../../../../packages/translate/src/lib/resovler-locale.ts","../../../../packages/translate/src/lib/register-namespace.ts","../../../../packages/translate/src/lib/route-helpers.ts","../../../../packages/translate/src/lib/translate.ts","../../../../packages/translate/src/lib/translator.ts","../../../../packages/translate/src/lib/testing/provide-mock-translations.ts","../../../../packages/translate/src/mmstack-translate.ts"],"sourcesContent":["const KEY_DELIM = '::MMT_DELIM::';\n\nexport function prependDelim(prefix: string, key: string): string {\n return `${prefix}${KEY_DELIM}${key}`;\n}\n\nexport function replaceWithDelim(str: string, repl = '.'): string {\n return str.replaceAll(repl, KEY_DELIM);\n}\n","import { prependDelim } from './delim';\nimport type {\n inferTranslationParamMap,\n inferTranslationShape,\n} from './parameterize.type';\nimport type { UnknownStringKeyObject } from './string-key-object.type';\n\nconst INTERNAL_SYMBOL = Symbol.for('mmstack-translate-internal');\n\ntype InternalSymbol = typeof INTERNAL_SYMBOL;\n\nexport type CompiledTranslation<\n T extends UnknownStringKeyObject,\n TNS extends string,\n TLocale extends string = string,\n> = {\n flat: Record<string, string>;\n locale?: TLocale;\n namespace: TNS;\n [INTERNAL_SYMBOL]: {\n shape: inferTranslationShape<T>;\n map: inferTranslationParamMap<TNS, T>;\n };\n};\n\nexport type mergeTranslationMaps<\n TMain extends CompiledTranslation<UnknownStringKeyObject, string>,\n TOther extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = Omit<TMain, InternalSymbol> & {\n [INTERNAL_SYMBOL]: {\n shape: inferCompiledTranslationShape<TMain>;\n map: inferCompiledTranslationMap<TOther> &\n inferCompiledTranslationMap<TMain>;\n };\n};\n\nexport type inferCompiledTranslationNamespace<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = T['namespace'];\n\nexport type inferCompiledTranslationShape<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = T[InternalSymbol]['shape'];\n\nexport type inferCompiledTranslationMap<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = T[InternalSymbol]['map'];\n\nfunction isTranslationObject(t: unknown): t is UnknownStringKeyObject {\n return typeof t === 'object' && t !== null;\n}\n\nfunction flattenTranslation<T extends UnknownStringKeyObject>(obj: T) {\n return Object.entries(obj).reduce(\n (acc, [key, value]) => {\n if (typeof value === 'string') {\n acc[key] = value;\n } else if (isTranslationObject(value)) {\n Object.entries(flattenTranslation(value)).forEach(\n ([nestedKey, nestedValue]) => {\n acc[prependDelim(key, nestedKey)] = nestedValue;\n },\n );\n }\n\n return acc;\n },\n {} as Record<string, string>,\n );\n}\n\nexport function compileTranslation<\n T extends UnknownStringKeyObject,\n TNS extends string,\n TLocale extends string = string,\n>(\n translation: T,\n ns: TNS,\n locale?: TLocale,\n): CompiledTranslation<T, TNS, TLocale> {\n type $Shape = inferTranslationShape<T>;\n type $Map = inferTranslationParamMap<TNS, T>;\n\n return {\n locale,\n flat: flattenTranslation(translation),\n namespace: ns,\n [INTERNAL_SYMBOL]: {\n shape: {} as $Shape,\n map: {} as $Map,\n },\n };\n}\n","import {\n type CompiledTranslation,\n compileTranslation,\n type inferCompiledTranslationShape,\n type mergeTranslationMaps,\n} from './compile';\nimport { type UnknownStringKeyObject } from './string-key-object.type';\n\ntype TranslationNamespace<\n TNS extends string,\n T extends CompiledTranslation<UnknownStringKeyObject, TNS>,\n TShape extends UnknownStringKeyObject,\n> = {\n translation: T;\n createTranslation: <TLocale extends string>(\n locale: TLocale,\n translation: TShape,\n ) => CompiledTranslation<TShape, TNS, TLocale>;\n createMergedNamespace: <\n TOtherNS extends string,\n const TOther extends UnknownStringKeyObject,\n TOtherCompiled extends CompiledTranslation<TOther, TOtherNS>,\n >(\n ns: TOtherNS,\n translation: TOther,\n ) => TranslationNamespace<\n TOtherNS,\n mergeTranslationMaps<TOtherCompiled, T>,\n inferCompiledTranslationShape<TOtherCompiled>\n >;\n};\n\nexport function createNamespace<\n const T extends UnknownStringKeyObject,\n TNS extends string,\n>(ns: TNS, translation: T) {\n const compiled = compileTranslation<T, TNS>(translation, ns);\n\n type TCompiled = typeof compiled;\n type TShape = inferCompiledTranslationShape<typeof compiled>;\n\n const namespace: TranslationNamespace<TNS, TCompiled, TShape> = {\n translation: compiled,\n createTranslation: <TLocale extends string>(\n locale: TLocale,\n translation: TShape,\n ) => {\n return compileTranslation(translation, ns, locale);\n },\n createMergedNamespace: <\n TOther extends UnknownStringKeyObject,\n TOtherNS extends string,\n TOtherCompiled extends CompiledTranslation<TOther, TOtherNS> =\n CompiledTranslation<TOther, TOtherNS>,\n >(\n otherNs: TOtherNS,\n otherTranslation: TOther,\n ) => {\n return createNamespace(otherNs, otherTranslation) as TranslationNamespace<\n TOtherNS,\n mergeTranslationMaps<TOtherCompiled, TCompiled>,\n inferCompiledTranslationShape<TOtherCompiled>\n > as unknown as any;\n },\n };\n\n return namespace;\n}\n","import { computed, inject, type Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, type ParamMap, Router } from '@angular/router';\n\nexport function pathParam(\n key: string | (() => string),\n route = inject(ActivatedRoute),\n): Signal<string | null> {\n const keySignal =\n typeof key === 'string' ? computed(() => key) : computed(key);\n\n const routerOptions = inject(Router)['options'];\n\n if (\n routerOptions &&\n typeof routerOptions === 'object' &&\n routerOptions.paramsInheritanceStrategy === 'always'\n ) {\n const params = toSignal(route.paramMap, {\n initialValue: route.snapshot.paramMap,\n });\n\n return computed(() => params().get(keySignal()));\n }\n\n const paramMapSignals: Signal<ParamMap>[] = [];\n let currentRoute: ActivatedRoute | null = route;\n\n const isStatic = typeof key === 'string';\n\n while (currentRoute) {\n const initial = currentRoute.snapshot.paramMap;\n paramMapSignals.push(\n toSignal(currentRoute.paramMap, {\n initialValue: initial,\n }),\n );\n\n // For static keys, stop once we find the param, will find first in computed for loop already so basically noop for for loop\n if (isStatic && initial.has(key as string)) break;\n\n currentRoute = currentRoute.parent;\n }\n\n return computed(() => {\n const paramKey = keySignal();\n\n for (const map of paramMapSignals) {\n const v = map().get(paramKey);\n if (v) return v;\n }\n\n return null;\n });\n}\n","import {\n computed,\n effect,\n inject,\n Injectable,\n InjectionToken,\n isDevMode,\n LOCALE_ID,\n type Provider,\n resource,\n type Signal,\n signal,\n untracked,\n type WritableSignal,\n} from '@angular/core';\nimport { createIntl, createIntlCache, type IntlConfig } from '@formatjs/intl';\nimport { type CompiledTranslation } from './compile';\nimport { prependDelim } from './delim';\nimport { pathParam } from './path-param';\nimport { type UnknownStringKeyObject } from './string-key-object.type';\n\nconst CONFIG_TOKEN = new InjectionToken<\n Omit<IntlConfig, 'locale' | 'messages'> & {\n supportedLocales?: string[];\n preloadDefaultLocale?: boolean;\n localeParamName?: string;\n }\n>('mmstack-intl-config');\n\nexport function provideIntlConfig(\n config: Omit<IntlConfig, 'locale' | 'messages'> & {\n /** Checks next locale is in provided array before switching locales */\n supportedLocales?: string[];\n /** Preloads the default locale ensuring sync fallback, not necessary for most cases as it will lazily load automatically when needed */\n preloadDefaultLocale?: boolean;\n /** Auto-resolution when using a locale parameter via angular router */\n localeParamName?: string;\n },\n): Provider[] {\n const providers: Provider[] = [\n {\n useFactory: (localeId: string) => {\n const next = {\n ...config,\n };\n\n const defaultLocale =\n config.defaultLocale ?? config.supportedLocales?.at(0) ?? localeId;\n\n if (\n next.supportedLocales &&\n !next.supportedLocales.includes(defaultLocale)\n ) {\n next.supportedLocales = [...next.supportedLocales, defaultLocale];\n }\n\n return next;\n },\n deps: [LOCALE_ID],\n provide: CONFIG_TOKEN,\n },\n ];\n\n const defaultLocale = config.defaultLocale ?? config.supportedLocales?.at(0);\n\n if (!defaultLocale) return providers;\n\n providers.push({\n provide: LOCALE_ID,\n useValue: defaultLocale,\n });\n\n return providers;\n}\n\nexport function injectIntlConfig() {\n return inject(CONFIG_TOKEN, { optional: true }) ?? undefined;\n}\n\nexport function injectDefaultLocale() {\n return injectIntlConfig()?.defaultLocale ?? inject(LOCALE_ID) ?? 'en-US';\n}\n\nexport function injectSupportedLocales() {\n return injectIntlConfig()?.supportedLocales ?? [injectDefaultLocale()];\n}\n\n/**\n * @internal\n * the actual locale signal used to store the current locale string\n */\nconst STORE_LOCALE = signal('en-US');\n\nexport function injectLocaleInternal() {\n return STORE_LOCALE;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TranslationStore {\n private readonly simpleKeyMap = new Map<string, Signal<string>>();\n private readonly cache = createIntlCache();\n private readonly config = injectIntlConfig();\n readonly loadQueue = signal<string[]>([]);\n readonly locale: WritableSignal<string>;\n private readonly defaultLocale = injectDefaultLocale();\n private readonly translations = signal<\n Record<string, Record<string, string>>\n >({\n [this.defaultLocale]: {},\n });\n private attemptedFallbackLoad = false;\n\n private readonly onDemandLoaders = new Map<\n string,\n Record<\n string,\n () => Promise<CompiledTranslation<UnknownStringKeyObject, string>>\n >\n >();\n\n private readonly nonMessageConfig = computed(() => ({\n ...this.config,\n locale: this.locale(),\n }));\n\n private readonly messages = computed(\n () =>\n this.translations()[this.locale()] ??\n this.translations()[this.defaultLocale] ??\n {},\n );\n\n readonly dynamicLocaleLoader = resource({\n params: computed(() => this.loadQueue().at(0) ?? null),\n loader: async ({ params: newLocale, abortSignal }) => {\n if (!newLocale) return;\n\n const currentTranslations = untracked(this.translations);\n\n const loadPromises: Promise<{\n namespace: string;\n flat: Record<string, string>;\n } | null>[] = [];\n\n for (const [namespace, loaders] of this.onDemandLoaders.entries()) {\n const loader = loaders[newLocale];\n if (loader) {\n const hasNamespaceForLocale =\n currentTranslations[newLocale] &&\n Object.keys(currentTranslations[newLocale]).some((key) =>\n key.startsWith(`${prependDelim(namespace, '').slice(0, -1)}`),\n );\n\n if (!hasNamespaceForLocale) {\n loadPromises.push(\n loader()\n .then((translation) => {\n if (abortSignal.aborted) return null;\n return {\n namespace: translation.namespace,\n flat: translation.flat,\n };\n })\n .catch((err) => {\n if (isDevMode()) {\n console.error(\n '[Translate] Failed to load',\n namespace,\n newLocale,\n err,\n );\n }\n\n return null;\n }),\n );\n }\n }\n }\n\n return Promise.all(loadPromises)\n .then((res) => res.filter((r) => r !== null))\n .then((res) => ({\n locales: res,\n locale: newLocale,\n }));\n },\n });\n\n readonly intl = computed(() =>\n createIntl(\n {\n ...this.nonMessageConfig(),\n messages: this.messages(),\n },\n this.cache,\n ),\n );\n\n constructor() {\n this.locale = STORE_LOCALE;\n this.locale.set(injectDefaultLocale());\n const paramName = this.config?.localeParamName;\n if (paramName) {\n const param = pathParam(paramName);\n\n effect(() => {\n const loc = param();\n if (\n !loc ||\n loc === untracked(this.locale) ||\n untracked(this.loadQueue).includes(loc)\n )\n return;\n if (this.hasLocaleLoaders(loc)) this.locale.set(loc);\n else this.loadQueue.update((q) => [...q, loc]);\n });\n }\n\n effect(() => {\n if (\n // should never be in error state, but best to check in case something throws\n this.dynamicLocaleLoader.error() ||\n this.dynamicLocaleLoader.isLoading()\n )\n return;\n const dynamicLocales = this.dynamicLocaleLoader.value();\n\n if (!dynamicLocales) return;\n\n // Register loaded translations\n for (const locale of dynamicLocales.locales) {\n this.register(locale.namespace, {\n [dynamicLocales.locale]: locale.flat,\n });\n }\n\n const hasTranslations =\n dynamicLocales.locales.length > 0 ||\n this.translations()[dynamicLocales.locale];\n\n if (hasTranslations) {\n this.loadQueue.update((q) =>\n q.filter((l) => l !== dynamicLocales.locale),\n );\n this.locale.set(dynamicLocales.locale);\n }\n });\n }\n\n buildSimpleKeySignal(key: string) {\n const found = this.simpleKeyMap.get(key);\n if (found) return found;\n\n const sig = computed(() => this.formatMessageInternal(key));\n this.simpleKeyMap.set(key, sig);\n return sig;\n }\n\n formatMessage(key: string, values?: Record<string, string | number>) {\n if (values === undefined) return this.buildSimpleKeySignal(key)();\n\n return this.formatMessageInternal(key, values);\n }\n\n private formatMessageInternal(\n key: string,\n values?: Record<string, string | number>,\n ) {\n const message =\n this.translations()[this.locale()]?.[key] ??\n this.translations()[this.defaultLocale]?.[key] ??\n '';\n\n if (!message) {\n if (this.attemptedFallbackLoad) return '';\n\n this.attemptedFallbackLoad = true;\n untracked(() => {\n if (!this.loadQueue().includes(this.defaultLocale))\n this.loadQueue.update((q) => [...q, this.defaultLocale]);\n });\n return '';\n }\n\n return this.intl().formatMessage(\n { id: key, defaultMessage: message },\n values,\n );\n }\n\n register(\n namespace: string,\n flat: Partial<Record<string, Record<string, string>>>,\n ) {\n this.translations.update((cur) => {\n return Object.entries(flat).reduce(\n (acc, [locale, translation]) => {\n const localeTranslation = acc[locale] ?? {};\n\n const withNS = Object.entries(translation ?? {}).reduce(\n (acc, [key, value]) => {\n acc[prependDelim(namespace, key)] = value;\n return acc;\n },\n {} as Record<string, string>,\n );\n\n acc[locale] = {\n ...localeTranslation,\n ...withNS,\n };\n\n return acc;\n },\n { ...cur },\n );\n });\n }\n\n registerOnDemandLoaders(\n namespace: string,\n loaders: Record<string, () => Promise<any>>,\n ) {\n this.onDemandLoaders.set(namespace, loaders);\n }\n\n hasLocaleLoaders(locale: string): boolean {\n return Array.from(this.onDemandLoaders.values()).some(\n (loaders) => loaders[locale],\n );\n }\n}\n\nexport function injectIntl() {\n return inject(TranslationStore).intl;\n}\n\n/**\n * Inject a dynamic locale signal that supports runtime language switching.\n *\n * @returns A writable signal with the current locale and loading state.\n * Only allows switching to locales that have registered loaders.\n *\n * @example\n * ```typescript\n * const locale = injectDynamicLocale();\n *\n * // Switch language (triggers automatic translation loading)\n * locale.set('sl-SI');\n *\n * // Check loading state\n * if (locale.isLoading()) {\n * // Show spinner\n * }\n * ```\n */\nexport function injectDynamicLocale(): WritableSignal<string> & {\n isLoading: Signal<boolean>;\n} {\n const store = inject(TranslationStore);\n const supportedLocales = injectIntlConfig()?.supportedLocales;\n\n const source = computed(() => store.locale()) as WritableSignal<string> & {\n isLoading: Signal<boolean>;\n };\n\n const inSupportedLocales =\n supportedLocales === undefined\n ? () => true\n : (locale: string) => supportedLocales.includes(locale);\n\n const set = (value: string) => {\n if (\n value === untracked(source) ||\n untracked(store.loadQueue).includes(value)\n )\n return;\n\n if (!inSupportedLocales(value)) {\n if (isDevMode())\n console.warn(\n `[Translate] Locale \"${value}\" is not in supportedLocales, switch prevented. Available options are:`,\n supportedLocales,\n );\n\n return;\n }\n\n if (isDevMode() && !store.hasLocaleLoaders(value))\n console.warn(\n `[Translate] No loaders registered for locale \"${value}\". Switching to this locale will have no effect.`,\n );\n\n store.loadQueue.update((q) => [...q, value]);\n };\n\n source.set = set;\n source.update = (updater: (value: string) => string) => {\n const next = updater(untracked(source));\n source.set(next);\n };\n source.asReadonly = () => source;\n\n source.isLoading = store.dynamicLocaleLoader.isLoading;\n\n return source;\n}\n","import { isSignal, type Signal } from '@angular/core';\n\nexport function unwrap<T>(value: T | Signal<T>): T {\n return isSignal(value) ? value() : value;\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\nconst FORMAT_PRESETS: Record<string, Intl.DateTimeFormatOptions> = {\n short: { dateStyle: 'short', timeStyle: 'short' },\n medium: { dateStyle: 'medium', timeStyle: 'medium' },\n long: { dateStyle: 'long', timeStyle: 'long' },\n full: { dateStyle: 'full', timeStyle: 'full' },\n\n shortDate: { dateStyle: 'short' },\n mediumDate: { dateStyle: 'medium' },\n longDate: { dateStyle: 'long' },\n fullDate: { dateStyle: 'full' },\n\n shortTime: { timeStyle: 'short' },\n mediumTime: { timeStyle: 'medium' },\n longTime: { timeStyle: 'long' },\n fullTime: { timeStyle: 'full' },\n};\n\ntype DateFormat = keyof typeof FORMAT_PRESETS;\n\n/**\n * Supported date inputs\n */\nexport type SupportedDateInput = Date | string | number | null | undefined;\n\n/**\n * Options for formatting a date\n */\nexport type FormatDateOptions = {\n /**\n * Timezone to use for formatting\n */\n tz?: string;\n /**\n * Format to use for formatting\n * @default 'medium'\n */\n format?: DateFormat;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nfunction validDateOrNull(\n date: Date | string | number | null | undefined,\n): Date | null {\n if (date == null) return null;\n\n const d = date instanceof Date ? date : new Date(date);\n return isNaN(d.getTime()) ? null : d;\n}\n\nconst cache = new Map<string, Intl.DateTimeFormat>();\n\nfunction getFormatter(\n locale: string,\n format: DateFormat,\n timeZone?: string,\n): Intl.DateTimeFormat {\n const cacheKey = `${locale}|${format}|${timeZone ?? ''}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, {\n ...FORMAT_PRESETS[format],\n timeZone,\n });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\n/**\n * Format a date using the current or provided locale & timezone\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param date - Date to format\n * @param opt - Options for formatting\n * @returns Formatted date string\n */\nexport function formatDate(\n date: SupportedDateInput | Signal<SupportedDateInput>,\n opt?: FormatDateOptions | Signal<FormatDateOptions>,\n): string {\n const validDate = validDateOrNull(unwrap(date));\n if (validDate === null) return '';\n\n const unwrappedOpt = unwrap(opt);\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.format ?? 'medium',\n unwrappedOpt?.tz,\n ).format(validDate);\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\nconst cache = new Map<string, Intl.DisplayNames>();\n\n/**\n * Options for formatting a display name\n */\nexport type FormatDisplayNameOptions = {\n /**\n * The display style for the result set\n */\n style: Intl.RelativeTimeFormatStyle;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nfunction getFormatter(\n locale: string,\n type: Intl.DisplayNamesType,\n style: Intl.RelativeTimeFormatStyle,\n): Intl.DisplayNames {\n const cacheKey = `${locale}|${type}|${style}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.DisplayNames(locale, {\n type,\n style,\n });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\ntype SupportedCode = string | null | undefined;\n\n/**\n * Format a display name using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param value - The code to format\n * @param type - The type of display name to format\n * @param opt - Options for formatting\n * @returns Formatted display name string\n */\nexport function formatDisplayName(\n value: SupportedCode | Signal<SupportedCode>,\n type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>,\n opt?: FormatDisplayNameOptions | Signal<FormatDisplayNameOptions>,\n): string {\n const unwrapped = unwrap(value);\n if (!unwrapped?.trim()) return '';\n\n const unwrappedType = unwrap(type);\n const unwrappedOpt = unwrap(opt);\n\n const locale = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return (\n getFormatter(locale, unwrappedType, unwrappedOpt?.style ?? 'long').of(\n unwrapped,\n ) ?? ''\n );\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\ntype ListType = 'conjunction' | 'disjunction' | 'unit';\ntype ListStyle = 'long' | 'short' | 'narrow';\n\nexport type SupportedListInput = string[] | null | undefined;\n\nconst cache = new Map<string, Intl.ListFormat>();\n\n/**\n * Options for formatting a list\n */\nexport type FormatListOptions = {\n /**\n * The type of list to format\n */\n type?: ListType;\n /**\n * The style of list to format\n */\n style?: ListStyle;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nconst EMPTY_ARRAY: string[] = [];\n\nfunction unwrapList(\n value: SupportedListInput | Signal<SupportedListInput>,\n): string[] {\n const unwrapped = unwrap(value);\n return Array.isArray(unwrapped) ? unwrapped : EMPTY_ARRAY;\n}\n\nfunction getFormatter(\n locale: string,\n type: ListType,\n style: ListStyle,\n): Intl.ListFormat {\n const cacheKey = `${locale}|${type}|${style}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.ListFormat(locale, { type, style });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\n/**\n * Format a list using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param value - The list to format\n * @param opt - Options for formatting\n * @returns Formatted list string\n */\nexport function formatList(\n value: SupportedListInput | Signal<SupportedListInput>,\n opt?: FormatListOptions | Signal<FormatListOptions>,\n): string {\n const unwrapped = unwrapList(value);\n if (unwrapped.length === 0) return '';\n\n const unwrappedOpt = unwrap(opt);\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.type ?? 'conjunction',\n unwrappedOpt?.style ?? 'long',\n ).format(unwrapped);\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\ntype NumberNotation = 'standard' | 'scientific' | 'engineering' | 'compact';\n\ntype SupportedNumberValue = number | null | undefined;\n\nconst cache = new Map<string, Intl.NumberFormat>();\n\nfunction unwrapValue(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n fallbackToZero = false,\n): number | null {\n const unwrapped = unwrap(value);\n\n if (unwrapped === null || unwrapped === undefined || isNaN(unwrapped))\n return fallbackToZero ? 0 : null;\n\n return unwrapped;\n}\n\n/**\n * Options for formatting a number\n */\nexport type FormatNumberOptions = {\n /**\n * The notation to use for formatting\n */\n notation?: NumberNotation;\n /**\n * Minimum number of fraction digits to use\n */\n minFractionDigits?: number;\n /**\n * Maximum number of fraction digits to use\n */\n maxFractionDigits?: number;\n /**\n * Whether to use grouping\n */\n useGrouping?: boolean;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n /**\n * If the number is not a valid number, return formatted 0. By default formatter returns an empty string\n * @default false\n */\n fallbackToZero?: boolean;\n};\n\nfunction getFormatter(\n locale: string,\n minFractionDigits: number | undefined,\n maxFractionDigits: number | undefined,\n useGrouping?: boolean,\n notation?: NumberNotation,\n currency?: string,\n display?: CurrencyDisplay,\n style?: 'currency' | 'percent',\n): Intl.NumberFormat {\n const cacheKey = `${locale}|${notation ?? 'standard'}|${minFractionDigits}|${maxFractionDigits}|${useGrouping ?? true}|${currency ?? 'none'}|${display ?? 'none'}|${style ?? 'decimal'}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.NumberFormat(locale, {\n style,\n notation,\n minimumFractionDigits: minFractionDigits,\n maximumFractionDigits: maxFractionDigits,\n useGrouping,\n currency,\n currencyDisplay: display,\n });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\n/**\n * Format a number using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param number - Number to format\n * @param opt - Options for formatting\n * @returns Formatted number string\n */\nexport function formatNumber(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n opt?: FormatNumberOptions | Signal<FormatNumberOptions>,\n): string {\n const unwrappedOpt = unwrap(opt);\n const unwrappedNumber = unwrapValue(value, unwrappedOpt?.fallbackToZero);\n\n if (unwrappedNumber === null) return '';\n\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.minFractionDigits,\n unwrappedOpt?.maxFractionDigits,\n unwrappedOpt?.useGrouping ?? true,\n unwrappedOpt?.notation ?? 'standard',\n ).format(unwrappedNumber);\n}\n\n/**\n * Options for formatting a percentage value\n */\nexport type FormatPercentOptions = {\n /**\n * Minimum number of fraction digits to use\n */\n minFractionDigits?: number;\n /**\n * Maximum number of fraction digits to use\n */\n maxFractionDigits?: number;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n /**\n * If the number is not a valid number, return formatted 0. By default formatter returns an empty string\n * @default false\n */\n fallbackToZero?: boolean;\n};\n\n/**\n * Format a percentage using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param number - Number to format\n * @param opt - Options for formatting\n * @returns Formatted percentage string\n */\nexport function formatPercent(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n opt?: FormatPercentOptions | Signal<FormatPercentOptions>,\n): string {\n const unwrappedOpt = unwrap(opt);\n\n const unwrappedNumber = unwrapValue(value, unwrappedOpt?.fallbackToZero);\n\n if (unwrappedNumber === null) return '';\n\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.minFractionDigits,\n unwrappedOpt?.maxFractionDigits,\n undefined,\n undefined,\n undefined,\n undefined,\n 'percent',\n ).format(unwrappedNumber);\n}\n\ntype CurrencyDisplay = 'symbol' | 'narrowSymbol' | 'code' | 'name';\n\n/**\n * Options for formatting a currency\n */\nexport type FormatCurrencyOptions = {\n /*\n * The display type for the currency format\n */\n display?: CurrencyDisplay;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n /**\n * If the number is not a valid number, return formatted 0. By default formatter returns an empty string\n * @default false\n */\n fallbackToZero?: boolean;\n};\n\nexport function formatCurrency(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n currency: string | Signal<string>,\n opt?: FormatCurrencyOptions | Signal<FormatCurrencyOptions>,\n): string {\n const unwrappedOpt = unwrap(opt);\n const unwrappedValue = unwrapValue(value, unwrappedOpt?.fallbackToZero);\n\n if (unwrappedValue === null) return '';\n\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n undefined,\n undefined,\n undefined,\n undefined,\n unwrap(currency),\n unwrappedOpt?.display ?? 'symbol',\n 'currency',\n ).format(unwrappedValue);\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\nconst cache = new Map<string, Intl.RelativeTimeFormat>();\n\n/**\n * Options for formatting a relative time value\n */\nexport type FormatRelativeTimeOptions = {\n /**\n * The length of the internationalized message.\n * @default 'long'\n */\n style?: Intl.RelativeTimeFormatStyle;\n /**\n * Controls whether to use numeric values in the output.\n * @default 'always'\n */\n numeric?: Intl.RelativeTimeFormatNumeric;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nfunction getFormatter(\n locale: string,\n style: Intl.RelativeTimeFormatStyle,\n numeric: Intl.RelativeTimeFormatNumeric,\n): Intl.RelativeTimeFormat {\n const cacheKey = `${locale}|${style}|${numeric}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.RelativeTimeFormat(locale, { style, numeric });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\nexport type RelativeTimeUnit = Intl.RelativeTimeFormatUnit;\n\ntype SupportedRelativeTimeInput = number | null | undefined;\n\n/**\n * Format a relative time using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param value - The numeric value to use in the relative time internationalization message\n * @param unit - The unit to use in the relative time internationalization message\n * @param opt - Options for formatting\n * @returns Formatted relative time string\n */\nexport function formatRelativeTime(\n value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>,\n unit: RelativeTimeUnit | Signal<RelativeTimeUnit>,\n opt?: FormatRelativeTimeOptions | Signal<FormatRelativeTimeOptions>,\n): string {\n const unwrappedValue = unwrap(value);\n if (\n unwrappedValue === null ||\n unwrappedValue === undefined ||\n isNaN(unwrappedValue)\n )\n return '';\n\n const unwrappedUnit = unwrap(unit);\n if (!unwrappedUnit) return '';\n\n const unwrappedOpt = unwrap(opt);\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.style ?? 'long',\n unwrappedOpt?.numeric ?? 'always',\n ).format(unwrappedValue, unwrappedUnit);\n}\n","import { inject, untracked } from '@angular/core';\nimport { type ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { injectIntlConfig, TranslationStore } from './translation-store';\n\nexport function injectResolveParamLocale(snapshot: ActivatedRouteSnapshot) {\n let locale: string | null = null;\n\n const paramName = injectIntlConfig()?.localeParamName;\n\n const routerConfig = inject(Router)['options'];\n\n const alwaysInheritParams =\n typeof routerConfig === 'object' &&\n !!routerConfig &&\n routerConfig.paramsInheritanceStrategy === 'always';\n\n if (paramName) {\n locale = snapshot.paramMap.get(paramName);\n\n if (!locale && !alwaysInheritParams) {\n let currentRoute: ActivatedRouteSnapshot | null = snapshot;\n while (currentRoute && !locale) {\n locale = currentRoute.paramMap.get('locale');\n currentRoute = currentRoute.parent;\n }\n }\n }\n\n if (!locale) {\n locale = untracked(inject(TranslationStore).locale);\n }\n\n return locale;\n}\n","import {\n computed,\n inject,\n isDevMode,\n isSignal,\n untracked,\n type Signal,\n} from '@angular/core';\nimport { type ResolveFn } from '@angular/router';\nimport {\n compileTranslation,\n type CompiledTranslation,\n type inferCompiledTranslationMap,\n type inferCompiledTranslationNamespace,\n} from './compile';\nimport { replaceWithDelim } from './delim';\nimport { injectResolveParamLocale } from './resovler-locale';\nimport {\n type AnyStringRecord,\n type UnknownStringKeyObject,\n} from './string-key-object.type';\nimport {\n injectDefaultLocale,\n injectIntlConfig,\n TranslationStore,\n} from './translation-store';\n\nfunction createEqualsRecord<T extends AnyStringRecord>(keys: (keyof T)[] = []) {\n let keyMatcher: (a: T, b: T) => boolean;\n\n if (keys.length === 0) {\n keyMatcher = () => true;\n } else if (keys.length === 1) {\n const key = keys[0];\n keyMatcher = (a, b) => a[key] === b[key];\n } else {\n keyMatcher = (a, b) => {\n return keys.every((k) => a[k] === b[k]);\n };\n }\n\n return (a?: T, b?: T): boolean => {\n if (!a && !b) return true;\n if (!a || !b) return false;\n return keyMatcher(a, b);\n };\n}\n\ntype TFunction<TMap extends AnyStringRecord> = <\n TKey extends keyof TMap & string,\n>(\n key: TKey,\n ...args: TMap[TKey] extends void ? [] : [TMap[TKey]]\n) => string;\n\ntype SignalTFunction<TMap extends AnyStringRecord> = <\n TKey extends keyof TMap & string,\n>(\n key: TKey,\n ...args: TMap[TKey] extends void ? [] : [() => TMap[TKey]]\n) => Signal<string>;\n\ntype TFunctionWithSignalConstructor<\n TMap extends AnyStringRecord,\n TFN extends TFunction<TMap>,\n> = TFN & {\n asSignal: SignalTFunction<TMap>;\n};\n\nexport function addSignalFn<\n TMap extends AnyStringRecord,\n TFn extends TFunction<TMap>,\n>(\n fn: TFn,\n store: TranslationStore,\n keyMap: Map<string, string>,\n): TFunctionWithSignalConstructor<TMap, TFn> {\n const withSig = fn as TFunctionWithSignalConstructor<TMap, TFn>;\n\n const asSignal = <TKey extends keyof TMap & string>(\n key: TKey,\n variables?: () => AnyStringRecord,\n ): Signal<string> => {\n const stringKey = key as string;\n\n let flatPath = keyMap.get(stringKey);\n\n if (flatPath === undefined) {\n flatPath = replaceWithDelim(stringKey);\n keyMap.set(stringKey, flatPath);\n }\n\n if (variables === undefined) return store.buildSimpleKeySignal(flatPath);\n\n const varsFn = variables;\n const varsSignal = isSignal(varsFn)\n ? varsFn\n : computed(() => varsFn(), {\n equal: createEqualsRecord(Object.keys(varsFn())),\n });\n\n return computed(() => store.formatMessage(flatPath, varsSignal()));\n };\n\n withSig.asSignal = asSignal as unknown as TFunctionWithSignalConstructor<\n TMap,\n TFn\n >['asSignal'];\n\n return withSig;\n}\n\nexport function createT<TMap extends AnyStringRecord>(\n store: TranslationStore,\n keyMap = new Map<string, string>(),\n): TFunction<TMap> {\n const fn = <TKey extends keyof TMap & string>(\n key: TKey,\n variables?: AnyStringRecord,\n ): string => {\n const stringKey = key as string;\n\n let k = keyMap.get(stringKey);\n\n if (k === undefined) {\n k = replaceWithDelim(stringKey);\n keyMap.set(stringKey, k);\n }\n\n return store.formatMessage(k, variables);\n };\n\n return fn as unknown as TFunction<TMap>;\n}\n\nexport function registerNamespace<\n TDefault extends CompiledTranslation<UnknownStringKeyObject, string>,\n>(\n defaultTranslation: () => Promise<TDefault>,\n other: Record<\n string,\n () => Promise<\n CompiledTranslation<\n UnknownStringKeyObject,\n inferCompiledTranslationNamespace<TDefault>,\n string\n >\n >\n >,\n) {\n type $Map = inferCompiledTranslationMap<TDefault>;\n type $BaseTFN = TFunction<$Map>;\n type $TFN = TFunctionWithSignalConstructor<$Map, $BaseTFN>;\n\n const keyMap = new Map<string, string>();\n\n const injectT = (): $TFN => {\n const store = inject(TranslationStore);\n\n return addSignalFn(createT(store, keyMap), store, keyMap);\n };\n\n let defaultTranslationLoaded = false;\n const resolver: ResolveFn<void> = async (snapshot) => {\n const store = inject(TranslationStore);\n\n const locale = injectResolveParamLocale(snapshot);\n\n const defaultLocale = injectDefaultLocale();\n const shouldPreloadDefault =\n injectIntlConfig()?.preloadDefaultLocale ?? false;\n\n const tPromise = other[locale] as (typeof other)[string] | undefined;\n\n const promise = tPromise ?? defaultTranslation;\n if (!promise && isDevMode()) {\n return console.warn(`No translation found for locale: ${locale}`);\n }\n\n if (promise === defaultTranslation && defaultTranslationLoaded) return;\n\n try {\n const promises = [promise()];\n\n if (\n shouldPreloadDefault &&\n !defaultTranslationLoaded &&\n promise !== defaultTranslation\n )\n promises.push(defaultTranslation());\n\n const translations = await Promise.allSettled(promises);\n\n const fullfilled = translations.map((t) =>\n t.status === 'fulfilled' ? t.value : null,\n );\n\n if (fullfilled.at(0) === null && fullfilled.at(1) === null)\n throw new Error('Failed to load translations');\n\n const [t, defaultT] = fullfilled;\n\n const ns = t?.namespace ?? defaultT?.namespace;\n if (!ns) throw new Error('No namespace found in translation');\n\n if (isDevMode() && t && t.locale !== locale && t.locale)\n console.warn(`Expected locale to be ${locale} but got ${t.locale}`);\n\n store.registerOnDemandLoaders(ns, {\n ...other,\n [defaultLocale]: defaultTranslation,\n });\n\n const toRegister: Record<string, Record<string, string>> = {};\n if (t) toRegister[locale] = t.flat;\n if (defaultT) toRegister[defaultLocale] = defaultT.flat;\n\n store.register(ns, toRegister);\n\n if (promise === defaultTranslation || defaultT)\n defaultTranslationLoaded = true;\n } catch {\n if (isDevMode()) {\n console.warn(`Failed to load translation for locale: ${locale}`);\n }\n } finally {\n if (locale !== untracked(store.locale)) store.locale.set(locale);\n }\n };\n\n return {\n injectNamespaceT: injectT,\n resolveNamespaceTranslation: resolver,\n };\n}\n\ntype UntypedTFunction<TNS extends string> = {\n (key: `${TNS}.${string}`, args?: Record<string, string>): string;\n asSignal: (\n key: `${TNS}.${string}`,\n args?: () => Record<string, string>,\n ) => Signal<string>;\n};\n\n/**\n * Registers a type-unsafe namespace, meant for remote loading of unknown key-value pairs using mmstack/translate infrastructure\n * The resolver & t function work the same as they would with typed namespaces, but without type safety\n */\nexport function registerRemoteNamespace<TNS extends string>(\n ns: TNS,\n defaultTranslation: () => Promise<Record<string, string>>,\n other: Record<string, () => Promise<Record<string, string>>>,\n) {\n const keyMap = new Map<string, string>();\n\n const injectT = (): UntypedTFunction<TNS> => {\n const store = inject(TranslationStore);\n\n return addSignalFn(\n createT(store, keyMap),\n store,\n keyMap,\n ) as UntypedTFunction<TNS>;\n };\n\n let defaultTranslationLoaded = false;\n const resolver: ResolveFn<void> = async (snapshot) => {\n const store = inject(TranslationStore);\n\n const locale = injectResolveParamLocale(snapshot);\n\n const defaultLocale = injectDefaultLocale();\n const shouldPreloadDefault =\n injectIntlConfig()?.preloadDefaultLocale ?? false;\n\n const tPromise = other[locale] as (typeof other)[string] | undefined;\n\n const promise = tPromise ?? defaultTranslation;\n\n if (!promise && isDevMode()) {\n return console.warn(`No translation found for locale: ${locale}`);\n }\n\n if (promise === defaultTranslation && defaultTranslationLoaded) return;\n\n try {\n const promises = [promise()];\n\n if (\n shouldPreloadDefault &&\n !defaultTranslationLoaded &&\n promise !== defaultTranslation\n )\n promises.push(defaultTranslation());\n\n const translations = await Promise.allSettled(promises);\n\n const fullfilled = translations.map((t) =>\n t.status === 'fulfilled' ? t.value : null,\n );\n\n if (fullfilled.at(0) === null && fullfilled.at(1) === null)\n throw new Error('Failed to load translations');\n\n const [baseT, baseDefaultT] = fullfilled;\n\n const t = baseT ? compileTranslation(baseT, ns, locale) : null;\n const defaultT = baseDefaultT\n ? compileTranslation(baseDefaultT, ns, defaultLocale)\n : null;\n\n if (isDevMode() && t && t.locale !== locale && t.locale)\n console.warn(`Expected locale to be ${locale} but got ${t.locale}`);\n\n store.registerOnDemandLoaders(ns, {\n ...other,\n [defaultLocale]: defaultTranslation,\n });\n\n const toRegister: Record<string, Record<string, string>> = {};\n if (t) toRegister[locale] = t.flat;\n if (defaultT) toRegister[defaultLocale] = defaultT.flat;\n\n store.register(ns, toRegister);\n\n if (promise === defaultTranslation || defaultT)\n defaultTranslationLoaded = true;\n } catch {\n if (isDevMode()) {\n console.warn(`Failed to load translation for locale: ${locale}`);\n }\n } finally {\n if (locale !== untracked(store.locale)) store.locale.set(locale);\n }\n };\n\n return {\n injectNamespaceT: injectT,\n resolveNamespaceTranslation: resolver,\n };\n}\n","import { inject } from '@angular/core';\nimport {\n Router,\n type CanMatchFn,\n type Route,\n type UrlSegment,\n} from '@angular/router';\nimport {\n injectDefaultLocale,\n injectSupportedLocales,\n} from './translation-store';\n\n/**\n * Guard that validates the locale parameter against supported locales.\n * Redirects to default locale if the locale is invalid.\n *\n * @param prefixSegments Optional array of path segments preceding the locale segment.\n * if (you wanted to match /app/:locale/... you would pass ['app'] here) & the function would match the second parameter + redirect accordingly\n *\n * @example\n * ```typescript\n * {\n * path: ':locale',\n * canMatch: [canMatchLocale()],\n * children: [...]\n * }\n * ```\n */\nexport function canMatchLocale(prefixSegments: string[] = []): CanMatchFn {\n return (_route: Route, segments: UrlSegment[]) => {\n const supportedLocales = injectSupportedLocales();\n\n const locale = segments.at(prefixSegments.length)?.path;\n\n if (!locale || !supportedLocales.includes(locale))\n return inject(Router).createUrlTree([\n ...prefixSegments,\n injectDefaultLocale(),\n ]);\n\n return true;\n };\n}\n","import {\n afterRenderEffect,\n computed,\n Directive,\n ElementRef,\n inject,\n input,\n Renderer2,\n} from '@angular/core';\nimport {\n type CompiledTranslation,\n type inferCompiledTranslationMap,\n} from './compile';\nimport { createT } from './register-namespace';\nimport { type UnknownStringKeyObject } from './string-key-object.type';\nimport { TranslationStore } from './translation-store';\n\nfunction compareObjects(\n a?: Record<string, string>,\n b?: Record<string, string>,\n): boolean {\n if (!a && !b) return true;\n if (!a || !b) return false;\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n\n if (aKeys.length !== bKeys.length) return false;\n\n return aKeys.every((key) => a[key] === b[key]);\n}\n\n@Directive()\nexport abstract class Translate<\n TInput extends string,\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>,\n TKey extends TInput & keyof TMap & string = TInput & keyof TMap & string,\n> {\n private readonly t = createT(inject(TranslationStore));\n\n readonly translate =\n input.required<\n TMap[TKey] extends void\n ? TKey | [key: TKey]\n : [key: TKey, vars: TMap[TKey]]\n >();\n\n constructor() {\n const inputs = computed(() => this.translate(), {\n equal: (a, b) => {\n if (a === b) return true;\n if (typeof a === 'string' || typeof b === 'string') return false;\n if (a[0] !== b[0]) return false;\n return compareObjects(\n a[1] as Record<string, string>,\n b[1] as Record<string, string>,\n );\n },\n });\n\n const translation = computed(() => {\n const inp = inputs();\n return typeof inp === 'string'\n ? this.t(inp)\n : this.t(inp[0], inp[1] as Record<string, string>);\n });\n\n const renderer = inject(Renderer2);\n const el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n afterRenderEffect({\n write: () => {\n renderer.setProperty(el.nativeElement, 'textContent', translation());\n },\n });\n }\n}\n","import { ChangeDetectorRef, effect, inject } from '@angular/core';\nimport {\n type CompiledTranslation,\n type inferCompiledTranslationMap,\n} from './compile';\nimport { createT } from './register-namespace';\nimport {\n type AnyStringRecord,\n type UnknownStringKeyObject,\n} from './string-key-object.type';\nimport { TranslationStore } from './translation-store';\n\ntype TransformTFn<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T>,\n> = <TKey extends keyof TMap & string>(\n key: TKey,\n ...args: TMap[TKey] extends void\n ? [locale?: string]\n : [TMap[TKey], locale?: string]\n) => string;\n\nfunction createTransformFn<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T>,\n>(): TransformTFn<T, TMap> {\n const store = inject(TranslationStore);\n const t = createT<TMap>(store);\n\n const fn = <TKey extends keyof TMap & string>(\n key: TKey,\n variablesOrLocale?: string | AnyStringRecord,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _?: string, // maybeLocale\n ): string => {\n const vars =\n typeof variablesOrLocale === 'string' ? undefined : variablesOrLocale;\n\n return (t as (key: TKey, vars?: AnyStringRecord) => string)(key, vars);\n };\n\n return fn as unknown as TransformTFn<T, TMap>;\n}\n\nexport abstract class Translator<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>,\n> {\n constructor() {\n const cdr = inject(ChangeDetectorRef);\n const locale = inject(TranslationStore).locale;\n\n effect(() => {\n locale();\n cdr.markForCheck();\n });\n }\n\n transform = createTransformFn<T, TMap>();\n}\n","import { type Provider, signal } from '@angular/core';\nimport { createIntl, createIntlCache, type IntlShape } from '@formatjs/intl';\nimport { compileTranslation } from '../compile';\nimport { type UnknownStringKeyObject } from '../string-key-object.type';\nimport { TranslationStore } from '../translation-store';\n\n/**\n * Options designed to feed into the mock translations function.\n */\nexport interface MockTranslationOptions {\n /**\n * If provided, allows overriding the default behavior of simply echoing translation keys back.\n * Format: Record of namespace -> (Translation shape similar to what you pass to `createNamespace`)\n *\n * Example:\n * ```ts\n * {\n * home: { title: 'Mocked Title' },\n * auth: { error: 'Mocked Error' }\n * }\n * ```\n */\n translations?: Record<string, UnknownStringKeyObject>;\n\n /**\n * When true, uses `@formatjs/intl` to process ICU message syntax (e.g. `{name}`, plurals, selects).\n * This gives you real variable interpolation in your test assertions.\n *\n * @default false — values are ignored and the raw message string is returned.\n *\n * @example\n * ```ts\n * provideMockTranslations({\n * translations: { home: { greet: 'Hello {name}' } },\n * formatValues: true,\n * })\n * // t('home.greet', { name: 'Alice' }) → 'Hello Alice'\n * ```\n */\n formatValues?: boolean;\n\n /**\n * The locale to use when `formatValues` is true.\n * @default 'en-US'\n */\n locale?: string;\n}\n\n/**\n * Provides an isolated mock `TranslationStore` usable across testing modules that use components\n * depending on `@mmstack/translate` APIs (like `Translate` directive, `Translator` pipe, or `injectNamespaceT`).\n *\n * This provider intercepts all translation logic, bypassing chunk loaders and Intl.\n * When a custom configuration isn't provided, formatMessage simply echoes the translation key, using dots `.`.\n *\n * ### Usage\n * ```typescript\n * TestBed.configureTestingModule({\n * providers: [provideMockTranslations()]\n * });\n * ```\n */\nexport function provideMockTranslations(\n options?: MockTranslationOptions,\n): Provider[] {\n // We compile the mock strings to flat delimiters just like the internal compile module.\n const mappedMocks: Record<string, string> = {};\n\n if (options?.translations) {\n for (const [namespace, translationObj] of Object.entries(\n options.translations,\n )) {\n const compiled = compileTranslation(translationObj, namespace);\n\n for (const [key, val] of Object.entries(compiled.flat)) {\n // e.g. from 'home::MMT_DELIM::title'\n const fullKey = `${namespace}::MMT_DELIM::${key}`;\n mappedMocks[fullKey] = val;\n }\n }\n }\n\n const locale = options?.locale ?? 'en-US';\n\n let intl: IntlShape | undefined;\n\n if (options?.formatValues) {\n intl = createIntl({ locale, messages: mappedMocks }, createIntlCache());\n }\n\n return [\n {\n provide: TranslationStore,\n useValue: {\n locale: signal(locale),\n formatMessage: (\n key: string,\n values?: Record<string, string | number>,\n ) => {\n const message = mappedMocks[key];\n\n if (!message) {\n // Fallback to echoing the key back in dot notation (more readable for unit assertions).\n return key.replaceAll('::MMT_DELIM::', '.');\n }\n\n if (intl) {\n return intl.formatMessage(\n { id: key, defaultMessage: message },\n values,\n );\n }\n\n return message;\n },\n hasLocaleLoaders: () => false,\n register: () => {\n // noop\n },\n registerOnDemandLoaders: () => {\n // noop\n },\n dynamicLocaleLoader: {\n isLoading: signal(false),\n value: signal(null),\n error: signal(null),\n },\n loadQueue: signal([]),\n },\n },\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["cache","getFormatter"],"mappings":";;;;;;AAAA,MAAM,SAAS,GAAG,eAAe;AAE3B,SAAU,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Y,EAAE;AACzB,QAAA,IAAI,GAAG,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,eAAe,EAAE,CAAC;IACzE;IAEA,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,gBAAgB;AACzB,YAAA,QAAQ,EAAE;AACR,gBAAA,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;AACtB,gBAAA,aAAa,EAAE,CACb,GAAW,EACX,MAAwC,KACtC;AACF,oBAAA,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC;oBAEhC,IAAI,CAAC,OAAO,EAAE;;wBAEZ,OAAO,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,CAAC;oBAC7C;oBAEA,IAAI,IAAI,EAAE;AACR,wBAAA,OAAO,IAAI,CAAC,aAAa,CACvB,EAAE,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,EACpC,MAAM,CACP;oBACH;AAEA,oBAAA,OAAO,OAAO;gBAChB,CAAC;AACD,gBAAA,gBAAgB,EAAE,MAAM,KAAK;gBAC7B,QAAQ,EAAE,MAAK;;gBAEf,CAAC;gBACD,uBAAuB,EAAE,MAAK;;gBAE9B,CAAC;AACD,gBAAA,mBAAmB,EAAE;AACnB,oBAAA,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC;AACxB,oBAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC;AACnB,oBAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC;AACpB,iBAAA;AACD,gBAAA,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC;AACtB,aAAA;AACF,SAAA;KACF;AACH;;ACnIA;;AAEG;;;;"}
1
+ {"version":3,"file":"mmstack-translate.mjs","sources":["../../../../packages/translate/src/lib/delim.ts","../../../../packages/translate/src/lib/compile.ts","../../../../packages/translate/src/lib/create-namespace.ts","../../../../packages/translate/src/lib/path-param.ts","../../../../packages/translate/src/lib/translation-store.ts","../../../../packages/translate/src/lib/format/unwrap.ts","../../../../packages/translate/src/lib/format/date.ts","../../../../packages/translate/src/lib/format/display-name.ts","../../../../packages/translate/src/lib/format/list.ts","../../../../packages/translate/src/lib/format/numeric.ts","../../../../packages/translate/src/lib/format/relative-time.ts","../../../../packages/translate/src/lib/resovler-locale.ts","../../../../packages/translate/src/lib/register-namespace.ts","../../../../packages/translate/src/lib/route-helpers.ts","../../../../packages/translate/src/lib/testing/provide-mock-translations.ts","../../../../packages/translate/src/lib/translate.ts","../../../../packages/translate/src/lib/translator.ts","../../../../packages/translate/src/lib/with-params.ts","../../../../packages/translate/src/mmstack-translate.ts"],"sourcesContent":["const KEY_DELIM = '::MMT_DELIM::';\n\nexport function prependDelim(prefix: string, key: string): string {\n return `${prefix}${KEY_DELIM}${key}`;\n}\n\nexport function replaceWithDelim(str: string, repl = '.'): string {\n return str.replaceAll(repl, KEY_DELIM);\n}\n","import { prependDelim } from './delim';\nimport type {\n inferTranslationParamMap,\n inferTranslationShape,\n} from './parameterize.type';\nimport type { UnknownStringKeyObject } from './string-key-object.type';\n\nconst INTERNAL_SYMBOL = Symbol.for('mmstack-translate-internal');\n\ntype InternalSymbol = typeof INTERNAL_SYMBOL;\n\nexport type CompiledTranslation<\n T extends UnknownStringKeyObject,\n TNS extends string,\n TLocale extends string = string,\n> = {\n flat: Record<string, string>;\n locale?: TLocale;\n namespace: TNS;\n [INTERNAL_SYMBOL]: {\n shape: inferTranslationShape<T>;\n map: inferTranslationParamMap<TNS, T>;\n };\n};\n\nexport type mergeTranslationMaps<\n TMain extends CompiledTranslation<UnknownStringKeyObject, string>,\n TOther extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = Omit<TMain, InternalSymbol> & {\n [INTERNAL_SYMBOL]: {\n shape: inferCompiledTranslationShape<TMain>;\n map: inferCompiledTranslationMap<TOther> &\n inferCompiledTranslationMap<TMain>;\n };\n};\n\nexport type inferCompiledTranslationNamespace<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = T['namespace'];\n\nexport type inferCompiledTranslationShape<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = T[InternalSymbol]['shape'];\n\nexport type inferCompiledTranslationMap<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n> = T[InternalSymbol]['map'];\n\nfunction isTranslationObject(t: unknown): t is UnknownStringKeyObject {\n return typeof t === 'object' && t !== null;\n}\n\nfunction flattenTranslation<T extends UnknownStringKeyObject>(obj: T) {\n return Object.entries(obj).reduce(\n (acc, [key, value]) => {\n if (typeof value === 'string') {\n acc[key] = value;\n } else if (isTranslationObject(value)) {\n Object.entries(flattenTranslation(value)).forEach(\n ([nestedKey, nestedValue]) => {\n acc[prependDelim(key, nestedKey)] = nestedValue;\n },\n );\n }\n\n return acc;\n },\n {} as Record<string, string>,\n );\n}\n\nexport function compileTranslation<\n T extends UnknownStringKeyObject,\n TNS extends string,\n TLocale extends string = string,\n>(\n translation: T,\n ns: TNS,\n locale?: TLocale,\n): CompiledTranslation<T, TNS, TLocale> {\n type $Shape = inferTranslationShape<T>;\n type $Map = inferTranslationParamMap<TNS, T>;\n\n return {\n locale,\n flat: flattenTranslation(translation),\n namespace: ns,\n [INTERNAL_SYMBOL]: {\n shape: {} as $Shape,\n map: {} as $Map,\n },\n };\n}\n","import {\n type CompiledTranslation,\n compileTranslation,\n type inferCompiledTranslationShape,\n type mergeTranslationMaps,\n} from './compile';\nimport { type UnknownStringKeyObject } from './string-key-object.type';\n\ntype TranslationNamespace<\n TNS extends string,\n T extends CompiledTranslation<UnknownStringKeyObject, TNS>,\n TShape extends UnknownStringKeyObject,\n> = {\n translation: T;\n createTranslation: <TLocale extends string>(\n locale: TLocale,\n translation: TShape,\n ) => CompiledTranslation<TShape, TNS, TLocale>;\n createMergedNamespace: <\n TOtherNS extends string,\n const TOther extends UnknownStringKeyObject,\n TOtherCompiled extends CompiledTranslation<TOther, TOtherNS>,\n >(\n ns: TOtherNS,\n translation: TOther,\n ) => TranslationNamespace<\n TOtherNS,\n mergeTranslationMaps<TOtherCompiled, T>,\n inferCompiledTranslationShape<TOtherCompiled>\n >;\n};\n\nexport function createNamespace<\n const T extends UnknownStringKeyObject,\n TNS extends string,\n>(ns: TNS, translation: T) {\n const compiled = compileTranslation<T, TNS>(translation, ns);\n\n type TCompiled = typeof compiled;\n type TShape = inferCompiledTranslationShape<typeof compiled>;\n\n const namespace: TranslationNamespace<TNS, TCompiled, TShape> = {\n translation: compiled,\n createTranslation: <TLocale extends string>(\n locale: TLocale,\n translation: TShape,\n ) => {\n return compileTranslation(translation, ns, locale);\n },\n createMergedNamespace: <\n TOther extends UnknownStringKeyObject,\n TOtherNS extends string,\n TOtherCompiled extends CompiledTranslation<TOther, TOtherNS> =\n CompiledTranslation<TOther, TOtherNS>,\n >(\n otherNs: TOtherNS,\n otherTranslation: TOther,\n ) => {\n return createNamespace(otherNs, otherTranslation) as TranslationNamespace<\n TOtherNS,\n mergeTranslationMaps<TOtherCompiled, TCompiled>,\n inferCompiledTranslationShape<TOtherCompiled>\n > as unknown as any;\n },\n };\n\n return namespace;\n}\n","import { computed, inject, type Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, type ParamMap, Router } from '@angular/router';\n\nexport function pathParam(\n key: string | (() => string),\n route = inject(ActivatedRoute),\n): Signal<string | null> {\n const keySignal =\n typeof key === 'string' ? computed(() => key) : computed(key);\n\n const routerOptions = inject(Router)['options'];\n\n if (\n routerOptions &&\n typeof routerOptions === 'object' &&\n routerOptions.paramsInheritanceStrategy === 'always'\n ) {\n const params = toSignal(route.paramMap, {\n initialValue: route.snapshot.paramMap,\n });\n\n return computed(() => params().get(keySignal()));\n }\n\n const paramMapSignals: Signal<ParamMap>[] = [];\n let currentRoute: ActivatedRoute | null = route;\n\n const isStatic = typeof key === 'string';\n\n while (currentRoute) {\n const initial = currentRoute.snapshot.paramMap;\n paramMapSignals.push(\n toSignal(currentRoute.paramMap, {\n initialValue: initial,\n }),\n );\n\n // For static keys, stop once we find the param, will find first in computed for loop already so basically noop for for loop\n if (isStatic && initial.has(key as string)) break;\n\n currentRoute = currentRoute.parent;\n }\n\n return computed(() => {\n const paramKey = keySignal();\n\n for (const map of paramMapSignals) {\n const v = map().get(paramKey);\n if (v) return v;\n }\n\n return null;\n });\n}\n","import {\n computed,\n effect,\n inject,\n Injectable,\n InjectionToken,\n isDevMode,\n LOCALE_ID,\n type Provider,\n resource,\n type Signal,\n signal,\n untracked,\n type WritableSignal,\n} from '@angular/core';\nimport { createIntl, createIntlCache, type IntlConfig } from '@formatjs/intl';\nimport { type CompiledTranslation } from './compile';\nimport { prependDelim } from './delim';\nimport { pathParam } from './path-param';\nimport { type UnknownStringKeyObject } from './string-key-object.type';\n\ntype BaseConfig = Omit<IntlConfig, 'locale' | 'messages'> & {\n /** Checks next locale is in provided array before switching locales */\n supportedLocales?: string[];\n /** Preloads the default locale ensuring sync fallback, not necessary for most cases as it will lazily load automatically when needed */\n preloadDefaultLocale?: boolean;\n};\n\ntype RouteBasedConfig = BaseConfig & {\n /** Auto-resolution when using a locale parameter via angular router */\n localeParamName?: string;\n localeStorage?: never;\n};\n\ntype LocaleStorage = {\n /** Called once on init to restore the last selected locale. Return `null` if nothing is stored. Values not in `supportedLocales` are ignored. */\n read: () => string | null;\n /** Called whenever the active locale changes. Fires once on init with the resolved initial value. */\n write: (locale: string) => void;\n};\n\ntype DynamicConfig = BaseConfig & {\n /** Custom storage mechanism for last set locale, it will be read on init & set the locale to the last value if it is still valid */\n localeStorage?: LocaleStorage;\n localeParamName?: never;\n};\n\ntype Config = RouteBasedConfig | DynamicConfig;\n\nconst CONFIG_TOKEN = new InjectionToken<Config>('mmstack-intl-config');\n\nexport function provideIntlConfig(config: Config): Provider[] {\n const providers: Provider[] = [\n {\n useFactory: (localeId: string) => {\n const next = {\n ...config,\n };\n\n const defaultLocale =\n config.defaultLocale ?? config.supportedLocales?.at(0) ?? localeId;\n\n if (\n next.supportedLocales &&\n !next.supportedLocales.includes(defaultLocale)\n ) {\n next.supportedLocales = [...next.supportedLocales, defaultLocale];\n }\n\n return next;\n },\n deps: [LOCALE_ID],\n provide: CONFIG_TOKEN,\n },\n ];\n\n const defaultLocale = config.defaultLocale ?? config.supportedLocales?.at(0);\n\n if (!defaultLocale) return providers;\n\n providers.push({\n provide: LOCALE_ID,\n useValue: defaultLocale,\n });\n\n return providers;\n}\n\nexport function injectIntlConfig() {\n return inject(CONFIG_TOKEN, { optional: true }) ?? undefined;\n}\n\nexport function injectDefaultLocale() {\n return injectIntlConfig()?.defaultLocale ?? inject(LOCALE_ID) ?? 'en-US';\n}\n\nexport function injectSupportedLocales() {\n return injectIntlConfig()?.supportedLocales ?? [injectDefaultLocale()];\n}\n\n/**\n * @internal\n * the actual locale signal used to store the current locale string\n */\nconst STORE_LOCALE = signal('en-US');\n\nexport function injectLocaleInternal() {\n return STORE_LOCALE;\n}\n\nfunction isDynamicConfig(\n cfg?: Config,\n): cfg is DynamicConfig & { localeStorage: LocaleStorage } {\n return !!cfg && 'localeStorage' in cfg && !!cfg.localeStorage;\n}\n\nfunction initLocale(src: WritableSignal<string>) {\n const config = injectIntlConfig();\n const defaultValue = injectDefaultLocale();\n\n if (!isDynamicConfig(config)) {\n src.set(defaultValue);\n return src;\n }\n\n let next: string | null = null;\n try {\n const stored = config.localeStorage.read();\n\n if (\n stored !== null &&\n (!config.supportedLocales || config.supportedLocales.includes(stored))\n ) {\n next = stored;\n }\n } catch (e) {\n if (isDevMode())\n console.error(\n '[Translate] Failed to read stored locale from localeStorage',\n e,\n );\n }\n\n src.set(next ?? defaultValue);\n effect(() => {\n try {\n config.localeStorage.write(src());\n } catch (e) {\n if (isDevMode())\n console.error('[Translate] Failed to write locale to localeStorage', e);\n }\n });\n\n return src;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TranslationStore {\n private readonly simpleKeyMap = new Map<string, Signal<string>>();\n private readonly cache = createIntlCache();\n private readonly config = injectIntlConfig();\n readonly loadQueue = signal<string[]>([]);\n readonly locale: WritableSignal<string>;\n private readonly defaultLocale = injectDefaultLocale();\n private readonly translations = signal<\n Record<string, Record<string, string>>\n >({\n [this.defaultLocale]: {},\n });\n private attemptedFallbackLoad = false;\n\n private readonly onDemandLoaders = new Map<\n string,\n Record<\n string,\n () => Promise<CompiledTranslation<UnknownStringKeyObject, string>>\n >\n >();\n\n private readonly nonMessageConfig = computed(() => ({\n ...this.config,\n locale: this.locale(),\n }));\n\n private readonly messages = computed(\n () =>\n this.translations()[this.locale()] ??\n this.translations()[this.defaultLocale] ??\n {},\n );\n\n readonly dynamicLocaleLoader = resource({\n params: computed(() => this.loadQueue().at(0) ?? null),\n loader: async ({ params: newLocale, abortSignal }) => {\n if (!newLocale) return;\n\n const currentTranslations = untracked(this.translations);\n\n const loadPromises: Promise<{\n namespace: string;\n flat: Record<string, string>;\n } | null>[] = [];\n\n for (const [namespace, loaders] of this.onDemandLoaders.entries()) {\n const loader = loaders[newLocale];\n if (loader) {\n const hasNamespaceForLocale =\n currentTranslations[newLocale] &&\n Object.keys(currentTranslations[newLocale]).some((key) =>\n key.startsWith(`${prependDelim(namespace, '').slice(0, -1)}`),\n );\n\n if (!hasNamespaceForLocale) {\n loadPromises.push(\n loader()\n .then((translation) => {\n if (abortSignal.aborted) return null;\n return {\n namespace: translation.namespace,\n flat: translation.flat,\n };\n })\n .catch((err) => {\n if (isDevMode()) {\n console.error(\n '[Translate] Failed to load',\n namespace,\n newLocale,\n err,\n );\n }\n\n return null;\n }),\n );\n }\n }\n }\n\n return Promise.all(loadPromises)\n .then((res) => res.filter((r) => r !== null))\n .then((res) => ({\n locales: res,\n locale: newLocale,\n }));\n },\n });\n\n readonly intl = computed(() =>\n createIntl(\n {\n ...this.nonMessageConfig(),\n messages: this.messages(),\n },\n this.cache,\n ),\n );\n\n constructor() {\n this.locale = initLocale(STORE_LOCALE);\n const paramName = this.config?.localeParamName;\n if (paramName) {\n const param = pathParam(paramName);\n\n effect(() => {\n const loc = param();\n if (\n !loc ||\n loc === untracked(this.locale) ||\n untracked(this.loadQueue).includes(loc)\n )\n return;\n if (this.hasLocaleLoaders(loc)) this.locale.set(loc);\n else this.loadQueue.update((q) => [...q, loc]);\n });\n }\n\n effect(() => {\n if (\n // should never be in error state, but best to check in case something throws\n this.dynamicLocaleLoader.error() ||\n this.dynamicLocaleLoader.isLoading()\n )\n return;\n const dynamicLocales = this.dynamicLocaleLoader.value();\n\n if (!dynamicLocales) return;\n\n // Register loaded translations\n for (const locale of dynamicLocales.locales) {\n this.register(locale.namespace, {\n [dynamicLocales.locale]: locale.flat,\n });\n }\n\n const hasTranslations =\n dynamicLocales.locales.length > 0 ||\n this.translations()[dynamicLocales.locale];\n\n if (hasTranslations) {\n this.loadQueue.update((q) =>\n q.filter((l) => l !== dynamicLocales.locale),\n );\n this.locale.set(dynamicLocales.locale);\n }\n });\n }\n\n buildSimpleKeySignal(key: string) {\n const found = this.simpleKeyMap.get(key);\n if (found) return found;\n\n const sig = computed(() => this.formatMessageInternal(key));\n this.simpleKeyMap.set(key, sig);\n return sig;\n }\n\n formatMessage(key: string, values?: Record<string, string | number>) {\n if (values === undefined) return this.buildSimpleKeySignal(key)();\n\n return this.formatMessageInternal(key, values);\n }\n\n private formatMessageInternal(\n key: string,\n values?: Record<string, string | number>,\n ) {\n const message =\n this.translations()[this.locale()]?.[key] ??\n this.translations()[this.defaultLocale]?.[key] ??\n '';\n\n if (!message) {\n if (this.attemptedFallbackLoad) return '';\n\n this.attemptedFallbackLoad = true;\n untracked(() => {\n if (!this.loadQueue().includes(this.defaultLocale))\n this.loadQueue.update((q) => [...q, this.defaultLocale]);\n });\n return '';\n }\n\n return this.intl().formatMessage(\n { id: key, defaultMessage: message },\n values,\n );\n }\n\n register(\n namespace: string,\n flat: Partial<Record<string, Record<string, string>>>,\n ) {\n this.translations.update((cur) => {\n return Object.entries(flat).reduce(\n (acc, [locale, translation]) => {\n const localeTranslation = acc[locale] ?? {};\n\n const withNS = Object.entries(translation ?? {}).reduce(\n (acc, [key, value]) => {\n acc[prependDelim(namespace, key)] = value;\n return acc;\n },\n {} as Record<string, string>,\n );\n\n acc[locale] = {\n ...localeTranslation,\n ...withNS,\n };\n\n return acc;\n },\n { ...cur },\n );\n });\n }\n\n registerOnDemandLoaders(\n namespace: string,\n loaders: Record<string, () => Promise<any>>,\n ) {\n this.onDemandLoaders.set(namespace, loaders);\n }\n\n hasLocaleLoaders(locale: string): boolean {\n return Array.from(this.onDemandLoaders.values()).some(\n (loaders) => loaders[locale],\n );\n }\n}\n\nexport function injectIntl() {\n return inject(TranslationStore).intl;\n}\n\n/**\n * Inject a dynamic locale signal that supports runtime language switching.\n *\n * @returns A writable signal with the current locale and loading state.\n * Only allows switching to locales that have registered loaders.\n *\n * @example\n * ```typescript\n * const locale = injectDynamicLocale();\n *\n * // Switch language (triggers automatic translation loading)\n * locale.set('sl-SI');\n *\n * // Check loading state\n * if (locale.isLoading()) {\n * // Show spinner\n * }\n * ```\n */\nexport function injectDynamicLocale(): WritableSignal<string> & {\n isLoading: Signal<boolean>;\n} {\n const store = inject(TranslationStore);\n const supportedLocales = injectIntlConfig()?.supportedLocales;\n\n const source = computed(() => store.locale()) as WritableSignal<string> & {\n isLoading: Signal<boolean>;\n };\n\n const inSupportedLocales =\n supportedLocales === undefined\n ? () => true\n : (locale: string) => supportedLocales.includes(locale);\n\n const set = (value: string) => {\n if (\n value === untracked(source) ||\n untracked(store.loadQueue).includes(value)\n )\n return;\n\n if (!inSupportedLocales(value)) {\n if (isDevMode())\n console.warn(\n `[Translate] Locale \"${value}\" is not in supportedLocales, switch prevented. Available options are:`,\n supportedLocales,\n );\n\n return;\n }\n\n if (isDevMode() && !store.hasLocaleLoaders(value))\n console.warn(\n `[Translate] No loaders registered for locale \"${value}\". Switching to this locale will have no effect.`,\n );\n\n store.loadQueue.update((q) => [...q, value]);\n };\n\n source.set = set;\n source.update = (updater: (value: string) => string) => {\n const next = updater(untracked(source));\n source.set(next);\n };\n source.asReadonly = () => source;\n\n source.isLoading = store.dynamicLocaleLoader.isLoading;\n\n return source;\n}\n\n/**\n * Power-user escape hatch for adding translations imperatively (e.g. content\n * loaded from a remote API after bootstrap). Returns a function that registers\n * a flat per-locale map of keys under a given namespace\n *\n * Pair with {@link injectUnsafeT} to read the added keys without compile-time\n * constraints.\n *\n * @example\n * ```ts\n * const addTranslations = injectAddTranslations();\n * addTranslations('remote', {\n * 'en-US': { greeting: 'Hi {name}' },\n * 'sl-SI': { greeting: 'Zdravo {name}' },\n * });\n * ```\n */\nexport function injectAddTranslations() {\n const store = inject(TranslationStore);\n const supportedLocales = injectIntlConfig()?.supportedLocales;\n const supportedLocalesSet = supportedLocales\n ? new Set(supportedLocales)\n : null;\n\n const validate = supportedLocalesSet\n ? (translations: Record<string, Record<string, string>>) => {\n const clean: Record<string, Record<string, string>> = {};\n const invalidLocales: string[] = [];\n\n for (const [locale, translation] of Object.entries(translations)) {\n if (!supportedLocalesSet.has(locale)) {\n invalidLocales.push(locale);\n continue;\n }\n clean[locale] = translation;\n }\n\n if (isDevMode() && invalidLocales.length > 0)\n console.warn(\n `[Translate] Attempted to add translations for unsupported locales: ${invalidLocales.join(', ')}. These translations were ignored. Supported locales are: ${(supportedLocales ?? []).join(', ')}.`,\n );\n\n return clean;\n }\n : (translations: Record<string, Record<string, string>>) => translations;\n\n return (ns: string, translations: Record<string, Record<string, string>>) => {\n store.register(ns, validate(translations));\n };\n}\n","import { isSignal, type Signal } from '@angular/core';\n\nexport function unwrap<T>(value: T | Signal<T>): T {\n return isSignal(value) ? value() : value;\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\nconst FORMAT_PRESETS: Record<string, Intl.DateTimeFormatOptions> = {\n short: { dateStyle: 'short', timeStyle: 'short' },\n medium: { dateStyle: 'medium', timeStyle: 'medium' },\n long: { dateStyle: 'long', timeStyle: 'long' },\n full: { dateStyle: 'full', timeStyle: 'full' },\n\n shortDate: { dateStyle: 'short' },\n mediumDate: { dateStyle: 'medium' },\n longDate: { dateStyle: 'long' },\n fullDate: { dateStyle: 'full' },\n\n shortTime: { timeStyle: 'short' },\n mediumTime: { timeStyle: 'medium' },\n longTime: { timeStyle: 'long' },\n fullTime: { timeStyle: 'full' },\n};\n\ntype DateFormat = keyof typeof FORMAT_PRESETS;\n\n/**\n * Supported date inputs\n */\nexport type SupportedDateInput = Date | string | number | null | undefined;\n\n/**\n * Options for formatting a date\n */\nexport type FormatDateOptions = {\n /**\n * Timezone to use for formatting\n */\n tz?: string;\n /**\n * Format to use for formatting\n * @default 'medium'\n */\n format?: DateFormat;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nfunction validDateOrNull(\n date: Date | string | number | null | undefined,\n): Date | null {\n if (date == null) return null;\n\n const d = date instanceof Date ? date : new Date(date);\n return isNaN(d.getTime()) ? null : d;\n}\n\nconst cache = new Map<string, Intl.DateTimeFormat>();\n\nfunction getFormatter(\n locale: string,\n format: DateFormat,\n timeZone?: string,\n): Intl.DateTimeFormat {\n const cacheKey = `${locale}|${format}|${timeZone ?? ''}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, {\n ...FORMAT_PRESETS[format],\n timeZone,\n });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\n/**\n * Format a date using the current or provided locale & timezone\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param date - Date to format\n * @param opt - Options for formatting\n * @returns Formatted date string\n */\nexport function formatDate(\n date: SupportedDateInput | Signal<SupportedDateInput>,\n opt?: FormatDateOptions | Signal<FormatDateOptions>,\n): string {\n const validDate = validDateOrNull(unwrap(date));\n if (validDate === null) return '';\n\n const unwrappedOpt = unwrap(opt);\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.format ?? 'medium',\n unwrappedOpt?.tz,\n ).format(validDate);\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\nconst cache = new Map<string, Intl.DisplayNames>();\n\n/**\n * Options for formatting a display name\n */\nexport type FormatDisplayNameOptions = {\n /**\n * The display style for the result set\n */\n style: Intl.RelativeTimeFormatStyle;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nfunction getFormatter(\n locale: string,\n type: Intl.DisplayNamesType,\n style: Intl.RelativeTimeFormatStyle,\n): Intl.DisplayNames {\n const cacheKey = `${locale}|${type}|${style}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.DisplayNames(locale, {\n type,\n style,\n });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\ntype SupportedCode = string | null | undefined;\n\n/**\n * Format a display name using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param value - The code to format\n * @param type - The type of display name to format\n * @param opt - Options for formatting\n * @returns Formatted display name string\n */\nexport function formatDisplayName(\n value: SupportedCode | Signal<SupportedCode>,\n type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>,\n opt?: FormatDisplayNameOptions | Signal<FormatDisplayNameOptions>,\n): string {\n const unwrapped = unwrap(value);\n if (!unwrapped?.trim()) return '';\n\n const unwrappedType = unwrap(type);\n const unwrappedOpt = unwrap(opt);\n\n const locale = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return (\n getFormatter(locale, unwrappedType, unwrappedOpt?.style ?? 'long').of(\n unwrapped,\n ) ?? ''\n );\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\ntype ListType = 'conjunction' | 'disjunction' | 'unit';\ntype ListStyle = 'long' | 'short' | 'narrow';\n\nexport type SupportedListInput = string[] | null | undefined;\n\nconst cache = new Map<string, Intl.ListFormat>();\n\n/**\n * Options for formatting a list\n */\nexport type FormatListOptions = {\n /**\n * The type of list to format\n */\n type?: ListType;\n /**\n * The style of list to format\n */\n style?: ListStyle;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nconst EMPTY_ARRAY: string[] = [];\n\nfunction unwrapList(\n value: SupportedListInput | Signal<SupportedListInput>,\n): string[] {\n const unwrapped = unwrap(value);\n return Array.isArray(unwrapped) ? unwrapped : EMPTY_ARRAY;\n}\n\nfunction getFormatter(\n locale: string,\n type: ListType,\n style: ListStyle,\n): Intl.ListFormat {\n const cacheKey = `${locale}|${type}|${style}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.ListFormat(locale, { type, style });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\n/**\n * Format a list using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param value - The list to format\n * @param opt - Options for formatting\n * @returns Formatted list string\n */\nexport function formatList(\n value: SupportedListInput | Signal<SupportedListInput>,\n opt?: FormatListOptions | Signal<FormatListOptions>,\n): string {\n const unwrapped = unwrapList(value);\n if (unwrapped.length === 0) return '';\n\n const unwrappedOpt = unwrap(opt);\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.type ?? 'conjunction',\n unwrappedOpt?.style ?? 'long',\n ).format(unwrapped);\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\ntype NumberNotation = 'standard' | 'scientific' | 'engineering' | 'compact';\n\ntype SupportedNumberValue = number | null | undefined;\n\nconst cache = new Map<string, Intl.NumberFormat>();\n\nfunction unwrapValue(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n fallbackToZero = false,\n): number | null {\n const unwrapped = unwrap(value);\n\n if (unwrapped === null || unwrapped === undefined || isNaN(unwrapped))\n return fallbackToZero ? 0 : null;\n\n return unwrapped;\n}\n\n/**\n * Options for formatting a number\n */\nexport type FormatNumberOptions = {\n /**\n * The notation to use for formatting\n */\n notation?: NumberNotation;\n /**\n * Minimum number of fraction digits to use\n */\n minFractionDigits?: number;\n /**\n * Maximum number of fraction digits to use\n */\n maxFractionDigits?: number;\n /**\n * Whether to use grouping\n */\n useGrouping?: boolean;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n /**\n * If the number is not a valid number, return formatted 0. By default formatter returns an empty string\n * @default false\n */\n fallbackToZero?: boolean;\n};\n\nfunction getFormatter(\n locale: string,\n minFractionDigits: number | undefined,\n maxFractionDigits: number | undefined,\n useGrouping?: boolean,\n notation?: NumberNotation,\n currency?: string,\n display?: CurrencyDisplay,\n style?: 'currency' | 'percent',\n): Intl.NumberFormat {\n const cacheKey = `${locale}|${notation ?? 'standard'}|${minFractionDigits}|${maxFractionDigits}|${useGrouping ?? true}|${currency ?? 'none'}|${display ?? 'none'}|${style ?? 'decimal'}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.NumberFormat(locale, {\n style,\n notation,\n minimumFractionDigits: minFractionDigits,\n maximumFractionDigits: maxFractionDigits,\n useGrouping,\n currency,\n currencyDisplay: display,\n });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\n/**\n * Format a number using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param number - Number to format\n * @param opt - Options for formatting\n * @returns Formatted number string\n */\nexport function formatNumber(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n opt?: FormatNumberOptions | Signal<FormatNumberOptions>,\n): string {\n const unwrappedOpt = unwrap(opt);\n const unwrappedNumber = unwrapValue(value, unwrappedOpt?.fallbackToZero);\n\n if (unwrappedNumber === null) return '';\n\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.minFractionDigits,\n unwrappedOpt?.maxFractionDigits,\n unwrappedOpt?.useGrouping ?? true,\n unwrappedOpt?.notation ?? 'standard',\n ).format(unwrappedNumber);\n}\n\n/**\n * Options for formatting a percentage value\n */\nexport type FormatPercentOptions = {\n /**\n * Minimum number of fraction digits to use\n */\n minFractionDigits?: number;\n /**\n * Maximum number of fraction digits to use\n */\n maxFractionDigits?: number;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n /**\n * If the number is not a valid number, return formatted 0. By default formatter returns an empty string\n * @default false\n */\n fallbackToZero?: boolean;\n};\n\n/**\n * Format a percentage using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param number - Number to format\n * @param opt - Options for formatting\n * @returns Formatted percentage string\n */\nexport function formatPercent(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n opt?: FormatPercentOptions | Signal<FormatPercentOptions>,\n): string {\n const unwrappedOpt = unwrap(opt);\n\n const unwrappedNumber = unwrapValue(value, unwrappedOpt?.fallbackToZero);\n\n if (unwrappedNumber === null) return '';\n\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.minFractionDigits,\n unwrappedOpt?.maxFractionDigits,\n undefined,\n undefined,\n undefined,\n undefined,\n 'percent',\n ).format(unwrappedNumber);\n}\n\ntype CurrencyDisplay = 'symbol' | 'narrowSymbol' | 'code' | 'name';\n\n/**\n * Options for formatting a currency\n */\nexport type FormatCurrencyOptions = {\n /*\n * The display type for the currency format\n */\n display?: CurrencyDisplay;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n /**\n * If the number is not a valid number, return formatted 0. By default formatter returns an empty string\n * @default false\n */\n fallbackToZero?: boolean;\n};\n\nexport function formatCurrency(\n value: SupportedNumberValue | Signal<SupportedNumberValue>,\n currency: string | Signal<string>,\n opt?: FormatCurrencyOptions | Signal<FormatCurrencyOptions>,\n): string {\n const unwrappedOpt = unwrap(opt);\n const unwrappedValue = unwrapValue(value, unwrappedOpt?.fallbackToZero);\n\n if (unwrappedValue === null) return '';\n\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n undefined,\n undefined,\n undefined,\n undefined,\n unwrap(currency),\n unwrappedOpt?.display ?? 'symbol',\n 'currency',\n ).format(unwrappedValue);\n}\n","import { type Signal } from '@angular/core';\nimport { injectLocaleInternal } from '../translation-store';\nimport { unwrap } from './unwrap';\n\nconst cache = new Map<string, Intl.RelativeTimeFormat>();\n\n/**\n * Options for formatting a relative time value\n */\nexport type FormatRelativeTimeOptions = {\n /**\n * The length of the internationalized message.\n * @default 'long'\n */\n style?: Intl.RelativeTimeFormatStyle;\n /**\n * Controls whether to use numeric values in the output.\n * @default 'always'\n */\n numeric?: Intl.RelativeTimeFormatNumeric;\n /**\n * Locale to use for formatting, opts out to dynamic locale changes\n */\n locale?: string;\n};\n\nfunction getFormatter(\n locale: string,\n style: Intl.RelativeTimeFormatStyle,\n numeric: Intl.RelativeTimeFormatNumeric,\n): Intl.RelativeTimeFormat {\n const cacheKey = `${locale}|${style}|${numeric}`;\n let formatter = cache.get(cacheKey);\n\n if (!formatter) {\n formatter = new Intl.RelativeTimeFormat(locale, { style, numeric });\n cache.set(cacheKey, formatter);\n }\n\n return formatter;\n}\n\nexport type RelativeTimeUnit = Intl.RelativeTimeFormatUnit;\n\ntype SupportedRelativeTimeInput = number | null | undefined;\n\n/**\n * Format a relative time using the current or provided locale\n * By default it is reactive to the global dynamic locale, works best when wrapped in a computed() if you need to react to locale changes\n *\n * @param value - The numeric value to use in the relative time internationalization message\n * @param unit - The unit to use in the relative time internationalization message\n * @param opt - Options for formatting\n * @returns Formatted relative time string\n */\nexport function formatRelativeTime(\n value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>,\n unit: RelativeTimeUnit | Signal<RelativeTimeUnit>,\n opt?: FormatRelativeTimeOptions | Signal<FormatRelativeTimeOptions>,\n): string {\n const unwrappedValue = unwrap(value);\n if (\n unwrappedValue === null ||\n unwrappedValue === undefined ||\n isNaN(unwrappedValue)\n )\n return '';\n\n const unwrappedUnit = unwrap(unit);\n if (!unwrappedUnit) return '';\n\n const unwrappedOpt = unwrap(opt);\n const loc = unwrappedOpt?.locale ?? injectLocaleInternal()();\n\n return getFormatter(\n loc,\n unwrappedOpt?.style ?? 'long',\n unwrappedOpt?.numeric ?? 'always',\n ).format(unwrappedValue, unwrappedUnit);\n}\n","import { inject, untracked } from '@angular/core';\nimport { type ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { injectIntlConfig, TranslationStore } from './translation-store';\n\nexport function injectResolveParamLocale(snapshot: ActivatedRouteSnapshot) {\n let locale: string | null = null;\n\n const paramName = injectIntlConfig()?.localeParamName;\n\n const routerConfig = inject(Router)['options'];\n\n const alwaysInheritParams =\n typeof routerConfig === 'object' &&\n !!routerConfig &&\n routerConfig.paramsInheritanceStrategy === 'always';\n\n if (paramName) {\n locale = snapshot.paramMap.get(paramName);\n\n if (!locale && !alwaysInheritParams) {\n let currentRoute: ActivatedRouteSnapshot | null = snapshot;\n while (currentRoute && !locale) {\n locale = currentRoute.paramMap.get('locale');\n currentRoute = currentRoute.parent;\n }\n }\n }\n\n if (!locale) {\n locale = untracked(inject(TranslationStore).locale);\n }\n\n return locale;\n}\n","import {\n computed,\n inject,\n Injectable,\n isDevMode,\n isSignal,\n untracked,\n type Signal,\n} from '@angular/core';\nimport { type ResolveFn } from '@angular/router';\nimport {\n compileTranslation,\n type CompiledTranslation,\n type inferCompiledTranslationMap,\n type inferCompiledTranslationNamespace,\n} from './compile';\nimport { replaceWithDelim } from './delim';\nimport { injectResolveParamLocale } from './resovler-locale';\nimport {\n type AnyStringRecord,\n type UnknownStringKeyObject,\n} from './string-key-object.type';\nimport {\n injectDefaultLocale,\n injectIntlConfig,\n TranslationStore,\n} from './translation-store';\n\nfunction createEqualsRecord<T extends AnyStringRecord>(keys: (keyof T)[] = []) {\n let keyMatcher: (a: T, b: T) => boolean;\n\n if (keys.length === 0) {\n keyMatcher = () => true;\n } else if (keys.length === 1) {\n const key = keys[0];\n keyMatcher = (a, b) => a[key] === b[key];\n } else {\n keyMatcher = (a, b) => {\n return keys.every((k) => a[k] === b[k]);\n };\n }\n\n return (a?: T, b?: T): boolean => {\n if (!a && !b) return true;\n if (!a || !b) return false;\n return keyMatcher(a, b);\n };\n}\n\ntype TFunction<TMap extends AnyStringRecord> = <\n TKey extends keyof TMap & string,\n>(\n key: TKey,\n ...args: TMap[TKey] extends void ? [] : [TMap[TKey]]\n) => string;\n\ntype SignalTFunction<TMap extends AnyStringRecord> = <\n TKey extends keyof TMap & string,\n>(\n key: TKey,\n ...args: TMap[TKey] extends void ? [] : [() => TMap[TKey]]\n) => Signal<string>;\n\ntype TFunctionWithSignalConstructor<\n TMap extends AnyStringRecord,\n TFN extends TFunction<TMap>,\n> = TFN & {\n asSignal: SignalTFunction<TMap>;\n};\n\nexport function addSignalFn<\n TMap extends AnyStringRecord,\n TFn extends TFunction<TMap>,\n>(\n fn: TFn,\n store: TranslationStore,\n keyMap: Map<string, string>,\n): TFunctionWithSignalConstructor<TMap, TFn> {\n const withSig = fn as TFunctionWithSignalConstructor<TMap, TFn>;\n\n const asSignal = <TKey extends keyof TMap & string>(\n key: TKey,\n variables?: () => AnyStringRecord,\n ): Signal<string> => {\n const stringKey = key as string;\n\n let flatPath = keyMap.get(stringKey);\n\n if (flatPath === undefined) {\n flatPath = replaceWithDelim(stringKey);\n keyMap.set(stringKey, flatPath);\n }\n\n if (variables === undefined) return store.buildSimpleKeySignal(flatPath);\n\n const varsFn = variables;\n const varsSignal = isSignal(varsFn)\n ? varsFn\n : computed(() => varsFn(), {\n equal: createEqualsRecord(Object.keys(varsFn())),\n });\n\n return computed(() => store.formatMessage(flatPath, varsSignal()));\n };\n\n withSig.asSignal = asSignal as unknown as TFunctionWithSignalConstructor<\n TMap,\n TFn\n >['asSignal'];\n\n return withSig;\n}\n\nexport function createT<TMap extends AnyStringRecord>(\n store: TranslationStore,\n keyMap = new Map<string, string>(),\n): TFunction<TMap> {\n const fn = <TKey extends keyof TMap & string>(\n key: TKey,\n variables?: AnyStringRecord,\n ): string => {\n const stringKey = key as string;\n\n let k = keyMap.get(stringKey);\n\n if (k === undefined) {\n k = replaceWithDelim(stringKey);\n keyMap.set(stringKey, k);\n }\n\n return store.formatMessage(k, variables);\n };\n\n return fn as unknown as TFunction<TMap>;\n}\n\nexport function registerNamespace<\n TDefault extends CompiledTranslation<UnknownStringKeyObject, string>,\n>(\n defaultTranslation: () => Promise<TDefault>,\n other: Record<\n string,\n () => Promise<\n CompiledTranslation<\n UnknownStringKeyObject,\n inferCompiledTranslationNamespace<TDefault>,\n string\n >\n >\n >,\n) {\n type $Map = inferCompiledTranslationMap<TDefault>;\n type $BaseTFN = TFunction<$Map>;\n type $TFN = TFunctionWithSignalConstructor<$Map, $BaseTFN>;\n\n const keyMap = new Map<string, string>();\n\n const injectT = (): $TFN => {\n const store = inject(TranslationStore);\n\n return addSignalFn(createT(store, keyMap), store, keyMap);\n };\n\n let defaultTranslationLoaded = false;\n const resolver: ResolveFn<void> = async (snapshot) => {\n const store = inject(TranslationStore);\n\n const locale = injectResolveParamLocale(snapshot);\n\n const defaultLocale = injectDefaultLocale();\n const shouldPreloadDefault =\n injectIntlConfig()?.preloadDefaultLocale ?? false;\n\n const tPromise = other[locale] as (typeof other)[string] | undefined;\n\n const promise = tPromise ?? defaultTranslation;\n if (!promise && isDevMode()) {\n return console.warn(`No translation found for locale: ${locale}`);\n }\n\n if (promise === defaultTranslation && defaultTranslationLoaded) return;\n\n try {\n const promises = [promise()];\n\n if (\n shouldPreloadDefault &&\n !defaultTranslationLoaded &&\n promise !== defaultTranslation\n )\n promises.push(defaultTranslation());\n\n const translations = await Promise.allSettled(promises);\n\n const fullfilled = translations.map((t) =>\n t.status === 'fulfilled' ? t.value : null,\n );\n\n if (fullfilled.at(0) === null && fullfilled.at(1) === null)\n throw new Error('Failed to load translations');\n\n const [t, defaultT] = fullfilled;\n\n const ns = t?.namespace ?? defaultT?.namespace;\n if (!ns) throw new Error('No namespace found in translation');\n\n if (isDevMode() && t && t.locale !== locale && t.locale)\n console.warn(`Expected locale to be ${locale} but got ${t.locale}`);\n\n store.registerOnDemandLoaders(ns, {\n ...other,\n [defaultLocale]: defaultTranslation,\n });\n\n const toRegister: Record<string, Record<string, string>> = {};\n if (t) toRegister[locale] = t.flat;\n if (defaultT) toRegister[defaultLocale] = defaultT.flat;\n\n store.register(ns, toRegister);\n\n if (promise === defaultTranslation || defaultT)\n defaultTranslationLoaded = true;\n } catch {\n if (isDevMode()) {\n console.warn(`Failed to load translation for locale: ${locale}`);\n }\n } finally {\n if (locale !== untracked(store.locale)) store.locale.set(locale);\n }\n };\n\n return {\n injectNamespaceT: injectT,\n resolveNamespaceTranslation: resolver,\n };\n}\n\ntype UntypedTFunction<TNS extends string> = {\n (key: `${TNS}.${string}`, args?: Record<string, string>): string;\n asSignal: (\n key: `${TNS}.${string}`,\n args?: () => Record<string, string>,\n ) => Signal<string>;\n};\n\n/**\n * Registers a type-unsafe namespace, meant for remote loading of unknown key-value pairs using mmstack/translate infrastructure\n * The resolver & t function work the same as they would with typed namespaces, but without type safety\n */\nexport function registerRemoteNamespace<TNS extends string>(\n ns: TNS,\n defaultTranslation: () => Promise<Record<string, string>>,\n other: Record<string, () => Promise<Record<string, string>>>,\n) {\n const keyMap = new Map<string, string>();\n\n const injectT = (): UntypedTFunction<TNS> => {\n const store = inject(TranslationStore);\n\n return addSignalFn(\n createT(store, keyMap),\n store,\n keyMap,\n ) as UntypedTFunction<TNS>;\n };\n\n let defaultTranslationLoaded = false;\n const resolver: ResolveFn<void> = async (snapshot) => {\n const store = inject(TranslationStore);\n\n const locale = injectResolveParamLocale(snapshot);\n\n const defaultLocale = injectDefaultLocale();\n const shouldPreloadDefault =\n injectIntlConfig()?.preloadDefaultLocale ?? false;\n\n const tPromise = other[locale] as (typeof other)[string] | undefined;\n\n const promise = tPromise ?? defaultTranslation;\n\n if (!promise && isDevMode()) {\n return console.warn(`No translation found for locale: ${locale}`);\n }\n\n if (promise === defaultTranslation && defaultTranslationLoaded) return;\n\n try {\n const promises = [promise()];\n\n if (\n shouldPreloadDefault &&\n !defaultTranslationLoaded &&\n promise !== defaultTranslation\n )\n promises.push(defaultTranslation());\n\n const translations = await Promise.allSettled(promises);\n\n const fullfilled = translations.map((t) =>\n t.status === 'fulfilled' ? t.value : null,\n );\n\n if (fullfilled.at(0) === null && fullfilled.at(1) === null)\n throw new Error('Failed to load translations');\n\n const [baseT, baseDefaultT] = fullfilled;\n\n const t = baseT ? compileTranslation(baseT, ns, locale) : null;\n const defaultT = baseDefaultT\n ? compileTranslation(baseDefaultT, ns, defaultLocale)\n : null;\n\n if (isDevMode() && t && t.locale !== locale && t.locale)\n console.warn(`Expected locale to be ${locale} but got ${t.locale}`);\n\n store.registerOnDemandLoaders(ns, {\n ...other,\n [defaultLocale]: defaultTranslation,\n });\n\n const toRegister: Record<string, Record<string, string>> = {};\n if (t) toRegister[locale] = t.flat;\n if (defaultT) toRegister[defaultLocale] = defaultT.flat;\n\n store.register(ns, toRegister);\n\n if (promise === defaultTranslation || defaultT)\n defaultTranslationLoaded = true;\n } catch {\n if (isDevMode()) {\n console.warn(`Failed to load translation for locale: ${locale}`);\n }\n } finally {\n if (locale !== untracked(store.locale)) store.locale.set(locale);\n }\n };\n\n return {\n injectNamespaceT: injectT,\n resolveNamespaceTranslation: resolver,\n };\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class UnsafeTKeyMap {\n readonly map = new Map<string, string>();\n}\n\n/**\n * Power-user escape hatch that returns a fully untyped translation function.\n * Intended for use alongside {@link injectAddTranslations} when translations\n * are added imperatively (e.g. from a remote API), or for cross-namespace\n * lookups where the typed API would be impractical.\n *\n * @example\n * ```ts\n * const t = injectUnsafeT();\n * t('any.namespace.key', { name: 'Alice', count: 3 });\n * const sig = t.asSignal('any.namespace.key', () => ({ name: name() }));\n * ```\n */\nexport function injectUnsafeT() {\n const store = inject(TranslationStore);\n const map = inject(UnsafeTKeyMap).map;\n\n const fn = (\n key: string,\n params?: Record<string, string | number>,\n ): string => {\n let k = map.get(key);\n\n if (k === undefined) {\n k = replaceWithDelim(key);\n map.set(key, k);\n }\n\n return store.formatMessage(k, params);\n };\n\n fn.asSignal = (\n key: string,\n params?: () => Record<string, string | number>,\n ): Signal<string> => {\n let k = map.get(key);\n\n if (k === undefined) {\n k = replaceWithDelim(key);\n map.set(key, k);\n }\n\n if (!params) return store.buildSimpleKeySignal(k);\n\n const paramsSignal = isSignal(params)\n ? params\n : computed(() => params(), {\n equal: createEqualsRecord(Object.keys(params())),\n });\n\n return computed(() => store.formatMessage(k, paramsSignal()));\n };\n\n return fn;\n}\n","import { inject } from '@angular/core';\nimport {\n Router,\n type CanMatchFn,\n type Route,\n type UrlSegment,\n} from '@angular/router';\nimport {\n injectDefaultLocale,\n injectSupportedLocales,\n} from './translation-store';\n\n/**\n * Guard that validates the locale parameter against supported locales.\n * Redirects to default locale if the locale is invalid.\n *\n * @param prefixSegments Optional array of path segments preceding the locale segment.\n * if (you wanted to match /app/:locale/... you would pass ['app'] here) & the function would match the second parameter + redirect accordingly\n *\n * @example\n * ```typescript\n * {\n * path: ':locale',\n * canMatch: [canMatchLocale()],\n * children: [...]\n * }\n * ```\n */\nexport function canMatchLocale(prefixSegments: string[] = []): CanMatchFn {\n return (_route: Route, segments: UrlSegment[]) => {\n const supportedLocales = injectSupportedLocales();\n\n const locale = segments.at(prefixSegments.length)?.path;\n\n if (!locale || !supportedLocales.includes(locale))\n return inject(Router).createUrlTree([\n ...prefixSegments,\n injectDefaultLocale(),\n ]);\n\n return true;\n };\n}\n","import { type Provider, signal } from '@angular/core';\nimport { createIntl, createIntlCache, type IntlShape } from '@formatjs/intl';\nimport { compileTranslation } from '../compile';\nimport { type UnknownStringKeyObject } from '../string-key-object.type';\nimport { TranslationStore } from '../translation-store';\n\n/**\n * Options designed to feed into the mock translations function.\n */\nexport interface MockTranslationOptions {\n /**\n * If provided, allows overriding the default behavior of simply echoing translation keys back.\n * Format: Record of namespace -> (Translation shape similar to what you pass to `createNamespace`)\n *\n * Example:\n * ```ts\n * {\n * home: { title: 'Mocked Title' },\n * auth: { error: 'Mocked Error' }\n * }\n * ```\n */\n translations?: Record<string, UnknownStringKeyObject>;\n\n /**\n * When true, uses `@formatjs/intl` to process ICU message syntax (e.g. `{name}`, plurals, selects).\n * This gives you real variable interpolation in your test assertions.\n *\n * @default false — values are ignored and the raw message string is returned.\n *\n * @example\n * ```ts\n * provideMockTranslations({\n * translations: { home: { greet: 'Hello {name}' } },\n * formatValues: true,\n * })\n * // t('home.greet', { name: 'Alice' }) → 'Hello Alice'\n * ```\n */\n formatValues?: boolean;\n\n /**\n * The locale to use when `formatValues` is true.\n * @default 'en-US'\n */\n locale?: string;\n}\n\n/**\n * Provides an isolated mock `TranslationStore` usable across testing modules that use components\n * depending on `@mmstack/translate` APIs (like `Translate` directive, `Translator` pipe, or `injectNamespaceT`).\n *\n * This provider intercepts all translation logic, bypassing chunk loaders and Intl.\n * When a custom configuration isn't provided, formatMessage simply echoes the translation key, using dots `.`.\n *\n * ### Usage\n * ```typescript\n * TestBed.configureTestingModule({\n * providers: [provideMockTranslations()]\n * });\n * ```\n */\nexport function provideMockTranslations(\n options?: MockTranslationOptions,\n): Provider[] {\n // We compile the mock strings to flat delimiters just like the internal compile module.\n const mappedMocks: Record<string, string> = {};\n\n if (options?.translations) {\n for (const [namespace, translationObj] of Object.entries(\n options.translations,\n )) {\n const compiled = compileTranslation(translationObj, namespace);\n\n for (const [key, val] of Object.entries(compiled.flat)) {\n // e.g. from 'home::MMT_DELIM::title'\n const fullKey = `${namespace}::MMT_DELIM::${key}`;\n mappedMocks[fullKey] = val;\n }\n }\n }\n\n const locale = options?.locale ?? 'en-US';\n\n let intl: IntlShape | undefined;\n\n if (options?.formatValues) {\n intl = createIntl({ locale, messages: mappedMocks }, createIntlCache());\n }\n\n return [\n {\n provide: TranslationStore,\n useValue: {\n locale: signal(locale),\n formatMessage: (\n key: string,\n values?: Record<string, string | number>,\n ) => {\n const message = mappedMocks[key];\n\n if (!message) {\n // Fallback to echoing the key back in dot notation (more readable for unit assertions).\n return key.replaceAll('::MMT_DELIM::', '.');\n }\n\n if (intl) {\n return intl.formatMessage(\n { id: key, defaultMessage: message },\n values,\n );\n }\n\n return message;\n },\n hasLocaleLoaders: () => false,\n register: () => {\n // noop\n },\n registerOnDemandLoaders: () => {\n // noop\n },\n dynamicLocaleLoader: {\n isLoading: signal(false),\n value: signal(null),\n error: signal(null),\n },\n loadQueue: signal([]),\n },\n },\n ];\n}\n","import {\n afterRenderEffect,\n computed,\n Directive,\n ElementRef,\n inject,\n input,\n Renderer2,\n} from '@angular/core';\nimport {\n type CompiledTranslation,\n type inferCompiledTranslationMap,\n} from './compile';\nimport { createT } from './register-namespace';\nimport { type UnknownStringKeyObject } from './string-key-object.type';\nimport { TranslationStore } from './translation-store';\n\nfunction compareObjects(\n a?: Record<string, string>,\n b?: Record<string, string>,\n): boolean {\n if (!a && !b) return true;\n if (!a || !b) return false;\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n\n if (aKeys.length !== bKeys.length) return false;\n\n return aKeys.every((key) => a[key] === b[key]);\n}\n\n@Directive()\nexport abstract class Translate<\n TInput extends string,\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>,\n TKey extends TInput & keyof TMap & string = TInput & keyof TMap & string,\n> {\n private readonly t = createT(inject(TranslationStore));\n\n readonly translate =\n input.required<\n TMap[TKey] extends void\n ? TKey | [key: TKey]\n : [key: TKey, vars: TMap[TKey]]\n >();\n\n constructor() {\n const inputs = computed(() => this.translate(), {\n equal: (a, b) => {\n if (a === b) return true;\n if (typeof a === 'string' || typeof b === 'string') return false;\n if (a[0] !== b[0]) return false;\n return compareObjects(\n a[1] as Record<string, string>,\n b[1] as Record<string, string>,\n );\n },\n });\n\n const translation = computed(() => {\n const inp = inputs();\n return typeof inp === 'string'\n ? this.t(inp)\n : this.t(inp[0], inp[1] as Record<string, string>);\n });\n\n const renderer = inject(Renderer2);\n const el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n afterRenderEffect({\n write: () => {\n renderer.setProperty(el.nativeElement, 'textContent', translation());\n },\n });\n }\n}\n","import { ChangeDetectorRef, effect, inject } from '@angular/core';\nimport {\n type CompiledTranslation,\n type inferCompiledTranslationMap,\n} from './compile';\nimport { createT } from './register-namespace';\nimport {\n type AnyStringRecord,\n type UnknownStringKeyObject,\n} from './string-key-object.type';\nimport { TranslationStore } from './translation-store';\n\ntype TransformTFn<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T>,\n> = <TKey extends keyof TMap & string>(\n key: TKey,\n ...args: TMap[TKey] extends void\n ? [locale?: string]\n : [TMap[TKey], locale?: string]\n) => string;\n\nfunction createTransformFn<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T>,\n>(): TransformTFn<T, TMap> {\n const store = inject(TranslationStore);\n const t = createT<TMap>(store);\n\n const fn = <TKey extends keyof TMap & string>(\n key: TKey,\n variablesOrLocale?: string | AnyStringRecord,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _?: string, // maybeLocale\n ): string => {\n const vars =\n typeof variablesOrLocale === 'string' ? undefined : variablesOrLocale;\n\n return (t as (key: TKey, vars?: AnyStringRecord) => string)(key, vars);\n };\n\n return fn as unknown as TransformTFn<T, TMap>;\n}\n\nexport abstract class Translator<\n T extends CompiledTranslation<UnknownStringKeyObject, string>,\n TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>,\n> {\n constructor() {\n const cdr = inject(ChangeDetectorRef);\n const locale = inject(TranslationStore).locale;\n\n effect(() => {\n locale();\n cdr.markForCheck();\n });\n }\n\n transform = createTransformFn<T, TMap>();\n}\n","import type { WithParams } from './parameterize.type';\n\n/**\n * Power-user escape hatch for ICU messages whose parameters can't be inferred\n * from the message string — typically variables nested inside `plural` /\n * `select` / `selectordinal` arms, which the type-level extractor skips.\n *\n * Declared params are merged with auto-extracted ones; on key conflict, the\n * declared params win. Non-default locales for a key wrapped with `withParams`\n * may be plain strings — they don't need to repeat the wrapper.\n *\n * @example\n * ```ts\n * const ns = createNamespace('quote', {\n * // auto-extracts `count`; `name` is declared explicitly because it\n * // lives inside the plural arms and can't be inferred\n * stats: withParams<{ name: string }>(\n * '{count, plural, one {1 quote from {name}} other {# quotes from {name}}}',\n * ),\n * });\n *\n * // t inferred as: (key, { count: number; name: string }) => string\n * t('quote.stats', { count: 3, name: 'Alice' });\n * ```\n */\nexport function withParams<\n const P extends Record<string, unknown>,\n const S extends string = string,\n>(message: S): WithParams<P, S> {\n return message as unknown as WithParams<P, S>;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["cache","getFormatter"],"mappings":";;;;;;AAAA,MAAM,SAAS,GAAG,eAAe;AAE3B,SAAU,YAAY,CAAC,MAAc,EAAE,GAAW,EAAA;AACtD,IAAA,OAAO,GAAG,MAAM,CAAA,EAAG,SAAS,CAAA,EAAG,GAAG,EAAE;AACtC;SAEgB,gBAAgB,CAAC,GAAW,EAAE,IAAI,GAAG,GAAG,EAAA;IACtD,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC;AACxC;;ACDA,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC;AAyChE,SAAS,mBAAmB,CAAC,CAAU,EAAA;IACrC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;AAC5C;AAEA,SAAS,kBAAkB,CAAmC,GAAM,EAAA;AAClE,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAC/B,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AACpB,QAAA,IAAI,OAAO,KAAK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BAAgB,CAAC;AACtC,IAAA,MAAM,CAAC,GAAG,OAAO,CAAO,KAAK,CAAC;AAE9B,IAAA,MAAM,EAAE,GAAG,CACT,GAAS,EACT,iBAA4C;;AAE5C,IAAA,CAAU,KACA;AACV,QAAA,MAAM,IAAI,GACR,OAAO,iBAAiB,KAAK,QAAQ,GAAG,SAAS,GAAG,iBAAiB;AAEvE,QAAA,OAAQ,CAAmD,CAAC,GAAG,EAAE,IAAI,CAAC;AACxE,IAAA,CAAC;AAED,IAAA,OAAO,EAAsC;AAC/C;MAEsB,UAAU,CAAA;AAI9B,IAAA,WAAA,GAAA;AACE,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,MAAM;QAE9C,MAAM,CAAC,MAAK;AACV,YAAA,MAAM,EAAE;YACR,GAAG,CAAC,YAAY,EAAE;AACpB,QAAA,CAAC,CAAC;IACJ;IAEA,SAAS,GAAG,iBAAiB,EAAW;AACzC;;ACzDD;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,UAAU,CAGxB,OAAU,EAAA;AACV,IAAA,OAAO,OAAsC;AAC/C;;AC9BA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/translate",
3
- "version": "21.1.10",
3
+ "version": "21.1.12",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "localize",
@@ -18,11 +18,33 @@ type extractSelectParam<TName extends string, TOpt extends string> = [
18
18
  Autocomplete<Exclude<Trimmed<extractSelectOptions<TOpt>>, 'other'>>
19
19
  ];
20
20
  type extractComplexParam<T extends string> = T extends `{${infer VarName}, plural, ${infer _}}}${infer REST}` | `{${infer VarName}, selectordinal, ${infer _}}}${infer REST}` ? [VarName, number] | extractParams<REST> : T extends `{${infer VarName}, select, ${infer SelectOptions}}}${infer REST}` ? extractSelectParam<VarName, `${SelectOptions}}`> | extractParams<REST> : never;
21
- type extractParams<T extends string> = T extends `${infer _Start}{${infer Var}}${infer End}` ? Var extends `${infer _}, ${infer __}` ? extractComplexParam<`{${Var}}${End}`> : [Var, string] | extractParams<End> : never;
21
+ type IsSimpleIdent<T extends string> = T extends '' ? false : T extends `${string} ${string}` | `${string},${string}` | `${string}{${string}` | `${string}#${string}` ? false : true;
22
+ type extractParams<T extends string> = T extends `${infer _Start}{${infer Var}}${infer End}` ? Var extends `${infer _}, ${infer __}` ? extractComplexParam<`{${Var}}${End}`> : IsSimpleIdent<Var> extends true ? [Var, string] | extractParams<End> : extractParams<End> : never;
22
23
  type mergeParams<TExtracted extends [string, any]> = {
23
24
  [K in TExtracted as K[0]]: K[1];
24
25
  };
25
- type flattenParams<TKey extends string, TVal> = TVal extends UnknownStringKeyObject ? inferParamTupples<TVal, `${TKey}.`> : TVal extends string ? extractParams<TVal> extends never ? [TKey] : [TKey, mergeParams<extractParams<TVal>>] : never;
26
+ declare const PARAM_BRAND: unique symbol;
27
+ /**
28
+ * Branded string type produced by `withParams<P>(message)`. The brand carries
29
+ * both the declared parameter shape `P` and the original literal message `S` —
30
+ * the literal lives inside the brand (not just on the intersection) so the
31
+ * inference machinery can recover it without going through template-literal
32
+ * pattern matching on a branded intersection (which widens `infer` slots to
33
+ * `string` and breaks auto-extraction). Module-local `unique symbol`, so the
34
+ * brand is not constructible outside this package.
35
+ */
36
+ type WithParams<P extends Record<string, unknown>, S extends string = string> = S & {
37
+ readonly [PARAM_BRAND]: {
38
+ params: P;
39
+ literal: S;
40
+ };
41
+ };
42
+ type flattenParams<TKey extends string, TVal> = TVal extends {
43
+ readonly [PARAM_BRAND]: {
44
+ params: infer P;
45
+ literal: infer S extends string;
46
+ };
47
+ } ? P extends Record<string, unknown> ? extractParams<S> extends never ? [TKey, P] : [TKey, Omit<mergeParams<extractParams<S>>, keyof P> & P] : [TKey] : TVal extends UnknownStringKeyObject ? inferParamTupples<TVal, `${TKey}.`> : TVal extends string ? extractParams<TVal> extends never ? [TKey] : [TKey, mergeParams<extractParams<TVal>>] : never;
26
48
  type inferParamTupples<T extends UnknownStringKeyObject, TPrefix extends string = ''> = Simplify<{
27
49
  [K in keyof T]: K extends string ? flattenParams<`${TPrefix}${K}`, T[K]> : never;
28
50
  }[keyof T]>;
@@ -34,7 +56,9 @@ type TypeEnsuringAllPlaceholders<PlaceholdersUnion extends string> = StringConta
34
56
  type extractParamString<T extends string> = T extends `${infer _Start}{${infer Var}}${infer End}` ? Var extends `${infer VarName},${string}` ? `{${VarName}, ${string}}` | extractParamString<End> : `{${Var}}` | extractParamString<End> : never;
35
57
  type inferParamsFromValue<V extends string> = extractParamString<V> extends never ? string : TypeEnsuringAllPlaceholders<extractParamString<V>>;
36
58
  type inferTranslationShape<T extends UnknownStringKeyObject> = {
37
- [K in keyof T]: T[K] extends UnknownStringKeyObject ? inferTranslationShape<T[K]> : T[K] extends string ? inferParamsFromValue<T[K]> : never;
59
+ [K in keyof T]: T[K] extends {
60
+ readonly [PARAM_BRAND]: any;
61
+ } ? string : T[K] extends UnknownStringKeyObject ? inferTranslationShape<T[K]> : T[K] extends string ? inferParamsFromValue<T[K]> : never;
38
62
  };
39
63
 
40
64
  declare const INTERNAL_SYMBOL: unique symbol;
@@ -277,14 +301,30 @@ type SupportedRelativeTimeInput = number | null | undefined;
277
301
  */
278
302
  declare function formatRelativeTime(value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>, unit: RelativeTimeUnit | Signal<RelativeTimeUnit>, opt?: FormatRelativeTimeOptions | Signal<FormatRelativeTimeOptions>): string;
279
303
 
280
- declare function provideIntlConfig(config: Omit<IntlConfig, 'locale' | 'messages'> & {
304
+ type BaseConfig = Omit<IntlConfig, 'locale' | 'messages'> & {
281
305
  /** Checks next locale is in provided array before switching locales */
282
306
  supportedLocales?: string[];
283
307
  /** Preloads the default locale ensuring sync fallback, not necessary for most cases as it will lazily load automatically when needed */
284
308
  preloadDefaultLocale?: boolean;
309
+ };
310
+ type RouteBasedConfig = BaseConfig & {
285
311
  /** Auto-resolution when using a locale parameter via angular router */
286
312
  localeParamName?: string;
287
- }): Provider[];
313
+ localeStorage?: never;
314
+ };
315
+ type LocaleStorage = {
316
+ /** Called once on init to restore the last selected locale. Return `null` if nothing is stored. Values not in `supportedLocales` are ignored. */
317
+ read: () => string | null;
318
+ /** Called whenever the active locale changes. Fires once on init with the resolved initial value. */
319
+ write: (locale: string) => void;
320
+ };
321
+ type DynamicConfig = BaseConfig & {
322
+ /** Custom storage mechanism for last set locale, it will be read on init & set the locale to the last value if it is still valid */
323
+ localeStorage?: LocaleStorage;
324
+ localeParamName?: never;
325
+ };
326
+ type Config = RouteBasedConfig | DynamicConfig;
327
+ declare function provideIntlConfig(config: Config): Provider[];
288
328
  declare function injectSupportedLocales(): string[];
289
329
  declare function injectIntl(): Signal<_formatjs_intl.IntlShape<string>>;
290
330
  /**
@@ -309,6 +349,24 @@ declare function injectIntl(): Signal<_formatjs_intl.IntlShape<string>>;
309
349
  declare function injectDynamicLocale(): WritableSignal<string> & {
310
350
  isLoading: Signal<boolean>;
311
351
  };
352
+ /**
353
+ * Power-user escape hatch for adding translations imperatively (e.g. content
354
+ * loaded from a remote API after bootstrap). Returns a function that registers
355
+ * a flat per-locale map of keys under a given namespace
356
+ *
357
+ * Pair with {@link injectUnsafeT} to read the added keys without compile-time
358
+ * constraints.
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * const addTranslations = injectAddTranslations();
363
+ * addTranslations('remote', {
364
+ * 'en-US': { greeting: 'Hi {name}' },
365
+ * 'sl-SI': { greeting: 'Zdravo {name}' },
366
+ * });
367
+ * ```
368
+ */
369
+ declare function injectAddTranslations(): (ns: string, translations: Record<string, Record<string, string>>) => void;
312
370
 
313
371
  type TFunction<TMap extends AnyStringRecord> = <TKey extends keyof TMap & string>(key: TKey, ...args: TMap[TKey] extends void ? [] : [TMap[TKey]]) => string;
314
372
  type SignalTFunction<TMap extends AnyStringRecord> = <TKey extends keyof TMap & string>(key: TKey, ...args: TMap[TKey] extends void ? [] : [() => TMap[TKey]]) => Signal<string>;
@@ -331,6 +389,23 @@ declare function registerRemoteNamespace<TNS extends string>(ns: TNS, defaultTra
331
389
  injectNamespaceT: () => UntypedTFunction<TNS>;
332
390
  resolveNamespaceTranslation: ResolveFn<void>;
333
391
  };
392
+ /**
393
+ * Power-user escape hatch that returns a fully untyped translation function.
394
+ * Intended for use alongside {@link injectAddTranslations} when translations
395
+ * are added imperatively (e.g. from a remote API), or for cross-namespace
396
+ * lookups where the typed API would be impractical.
397
+ *
398
+ * @example
399
+ * ```ts
400
+ * const t = injectUnsafeT();
401
+ * t('any.namespace.key', { name: 'Alice', count: 3 });
402
+ * const sig = t.asSignal('any.namespace.key', () => ({ name: name() }));
403
+ * ```
404
+ */
405
+ declare function injectUnsafeT(): {
406
+ (key: string, params?: Record<string, string | number>): string;
407
+ asSignal(key: string, params?: () => Record<string, string | number>): Signal<string>;
408
+ };
334
409
 
335
410
  declare function injectResolveParamLocale(snapshot: ActivatedRouteSnapshot): string;
336
411
 
@@ -352,20 +427,6 @@ declare function injectResolveParamLocale(snapshot: ActivatedRouteSnapshot): str
352
427
  */
353
428
  declare function canMatchLocale(prefixSegments?: string[]): CanMatchFn;
354
429
 
355
- declare abstract class Translate<TInput extends string, T extends CompiledTranslation<UnknownStringKeyObject, string>, TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>, TKey extends TInput & keyof TMap & string = TInput & keyof TMap & string> {
356
- private readonly t;
357
- readonly translate: i0.InputSignal<TMap[TKey] extends void ? TKey | [key: TKey] : [key: TKey, vars: TMap[TKey]]>;
358
- constructor();
359
- static ɵfac: i0.ɵɵFactoryDeclaration<Translate<any, any, any, any>, never>;
360
- static ɵdir: i0.ɵɵDirectiveDeclaration<Translate<any, any, any, any>, never, never, { "translate": { "alias": "translate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
361
- }
362
-
363
- type TransformTFn<T extends CompiledTranslation<UnknownStringKeyObject, string>, TMap extends inferCompiledTranslationMap<T>> = <TKey extends keyof TMap & string>(key: TKey, ...args: TMap[TKey] extends void ? [locale?: string] : [TMap[TKey], locale?: string]) => string;
364
- declare abstract class Translator<T extends CompiledTranslation<UnknownStringKeyObject, string>, TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>> {
365
- constructor();
366
- transform: TransformTFn<T, TMap>;
367
- }
368
-
369
430
  /**
370
431
  * Options designed to feed into the mock translations function.
371
432
  */
@@ -421,5 +482,44 @@ interface MockTranslationOptions {
421
482
  */
422
483
  declare function provideMockTranslations(options?: MockTranslationOptions): Provider[];
423
484
 
424
- export { Translate, Translator, canMatchLocale, compileTranslation, createNamespace, formatCurrency, formatDate, formatDisplayName, formatList, formatNumber, formatPercent, formatRelativeTime, injectDynamicLocale, injectIntl, injectResolveParamLocale, injectSupportedLocales, provideIntlConfig, provideMockTranslations, registerNamespace, registerRemoteNamespace };
485
+ declare abstract class Translate<TInput extends string, T extends CompiledTranslation<UnknownStringKeyObject, string>, TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>, TKey extends TInput & keyof TMap & string = TInput & keyof TMap & string> {
486
+ private readonly t;
487
+ readonly translate: i0.InputSignal<TMap[TKey] extends void ? TKey | [key: TKey] : [key: TKey, vars: TMap[TKey]]>;
488
+ constructor();
489
+ static ɵfac: i0.ɵɵFactoryDeclaration<Translate<any, any, any, any>, never>;
490
+ static ɵdir: i0.ɵɵDirectiveDeclaration<Translate<any, any, any, any>, never, never, { "translate": { "alias": "translate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
491
+ }
492
+
493
+ type TransformTFn<T extends CompiledTranslation<UnknownStringKeyObject, string>, TMap extends inferCompiledTranslationMap<T>> = <TKey extends keyof TMap & string>(key: TKey, ...args: TMap[TKey] extends void ? [locale?: string] : [TMap[TKey], locale?: string]) => string;
494
+ declare abstract class Translator<T extends CompiledTranslation<UnknownStringKeyObject, string>, TMap extends inferCompiledTranslationMap<T> = inferCompiledTranslationMap<T>> {
495
+ constructor();
496
+ transform: TransformTFn<T, TMap>;
497
+ }
498
+
499
+ /**
500
+ * Power-user escape hatch for ICU messages whose parameters can't be inferred
501
+ * from the message string — typically variables nested inside `plural` /
502
+ * `select` / `selectordinal` arms, which the type-level extractor skips.
503
+ *
504
+ * Declared params are merged with auto-extracted ones; on key conflict, the
505
+ * declared params win. Non-default locales for a key wrapped with `withParams`
506
+ * may be plain strings — they don't need to repeat the wrapper.
507
+ *
508
+ * @example
509
+ * ```ts
510
+ * const ns = createNamespace('quote', {
511
+ * // auto-extracts `count`; `name` is declared explicitly because it
512
+ * // lives inside the plural arms and can't be inferred
513
+ * stats: withParams<{ name: string }>(
514
+ * '{count, plural, one {1 quote from {name}} other {# quotes from {name}}}',
515
+ * ),
516
+ * });
517
+ *
518
+ * // t inferred as: (key, { count: number; name: string }) => string
519
+ * t('quote.stats', { count: 3, name: 'Alice' });
520
+ * ```
521
+ */
522
+ declare function withParams<const P extends Record<string, unknown>, const S extends string = string>(message: S): WithParams<P, S>;
523
+
524
+ export { Translate, Translator, canMatchLocale, compileTranslation, createNamespace, formatCurrency, formatDate, formatDisplayName, formatList, formatNumber, formatPercent, formatRelativeTime, injectAddTranslations, injectDynamicLocale, injectIntl, injectResolveParamLocale, injectSupportedLocales, injectUnsafeT, provideIntlConfig, provideMockTranslations, registerNamespace, registerRemoteNamespace, withParams };
425
525
  export type { CompiledTranslation, FormatCurrencyOptions, FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions, FormatPercentOptions, FormatRelativeTimeOptions, RelativeTimeUnit, SupportedDateInput, SupportedListInput, inferCompiledTranslationMap, inferCompiledTranslationNamespace, inferCompiledTranslationShape, mergeTranslationMaps };