@mmstack/translate 21.1.12 → 21.1.13

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.
@@ -1,5 +1,6 @@
1
- import * as i0 from '@angular/core';
2
- import { Signal, WritableSignal, Provider } from '@angular/core';
1
+ import * as _angular_core from '@angular/core';
2
+ import { Signal, Provider, WritableSignal } from '@angular/core';
3
+ import * as _mmstack_translate from '@mmstack/translate';
3
4
  import { ResolveFn, ActivatedRouteSnapshot, CanMatchFn } from '@angular/router';
4
5
  import * as _formatjs_intl from '@formatjs/intl';
5
6
  import { IntlConfig } from '@formatjs/intl';
@@ -90,7 +91,48 @@ type TranslationNamespace<TNS extends string, T extends CompiledTranslation<Unkn
90
91
  };
91
92
  declare function createNamespace<const T extends UnknownStringKeyObject, TNS extends string>(ns: TNS, translation: T): TranslationNamespace<TNS, CompiledTranslation<T, TNS, string>, inferTranslationShape<T>>;
92
93
 
93
- declare const FORMAT_PRESETS: Record<string, Intl.DateTimeFormatOptions>;
94
+ declare const FORMAT_PRESETS: {
95
+ short: {
96
+ dateStyle: "short";
97
+ timeStyle: "short";
98
+ };
99
+ medium: {
100
+ dateStyle: "medium";
101
+ timeStyle: "medium";
102
+ };
103
+ long: {
104
+ dateStyle: "long";
105
+ timeStyle: "long";
106
+ };
107
+ full: {
108
+ dateStyle: "full";
109
+ timeStyle: "full";
110
+ };
111
+ shortDate: {
112
+ dateStyle: "short";
113
+ };
114
+ mediumDate: {
115
+ dateStyle: "medium";
116
+ };
117
+ longDate: {
118
+ dateStyle: "long";
119
+ };
120
+ fullDate: {
121
+ dateStyle: "full";
122
+ };
123
+ shortTime: {
124
+ timeStyle: "short";
125
+ };
126
+ mediumTime: {
127
+ timeStyle: "medium";
128
+ };
129
+ longTime: {
130
+ timeStyle: "long";
131
+ };
132
+ fullTime: {
133
+ timeStyle: "full";
134
+ };
135
+ };
94
136
  type DateFormat = keyof typeof FORMAT_PRESETS;
95
137
  /**
96
138
  * Supported date inputs
@@ -108,21 +150,43 @@ type FormatDateOptions = {
108
150
  * Format to use for formatting
109
151
  * @default 'medium'
110
152
  */
111
- format?: DateFormat;
153
+ format?: DateFormat | Intl.DateTimeFormatOptions;
112
154
  /**
113
- * Locale to use for formatting, opts out to dynamic locale changes
155
+ * Locale to use for formatting
114
156
  */
157
+ locale: string;
158
+ };
159
+ /**
160
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
161
+ */
162
+ type UnsafeFormatDateOptions = Omit<FormatDateOptions, 'locale'> & {
163
+ /** Optional locale string falling back to the legacy global signal */
115
164
  locale?: string;
116
165
  };
117
166
  /**
118
- * Format a date using the current or provided locale & timezone
119
- * 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
120
- *
121
- * @param date - Date to format
122
- * @param opt - Options for formatting
123
- * @returns Formatted date string
167
+ * @example formatDate(this.date, this.locale)
168
+ */
169
+ declare function formatDate(date: SupportedDateInput | Signal<SupportedDateInput>, locale: string | Signal<string>): string;
170
+ /**
171
+ * @example formatDate(this.date, { locale: 'sl-SI', format: 'shortDate' })
172
+ */
173
+ declare function formatDate(date: SupportedDateInput | Signal<SupportedDateInput>, opt: FormatDateOptions | Signal<FormatDateOptions>): string;
174
+ /**
175
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
176
+ * Use `injectFormatDate()` instead, or pass locale explicitly.
177
+ * @example formatDate(this.date)
124
178
  */
125
- declare function formatDate(date: SupportedDateInput | Signal<SupportedDateInput>, opt?: FormatDateOptions | Signal<FormatDateOptions>): string;
179
+ declare function formatDate(date: SupportedDateInput | Signal<SupportedDateInput>, opt?: UnsafeFormatDateOptions | Signal<UnsafeFormatDateOptions>): string;
180
+ declare const provideFormatDateDefaults: (valueOrFn: Omit<Partial<FormatDateOptions>, "locale"> | (() => Omit<Partial<FormatDateOptions>, "locale"> | Signal<Omit<Partial<FormatDateOptions>, "locale">>)) => _angular_core.Provider;
181
+
182
+ /**
183
+ * Inject a context-safe date formatting function tied to the current injector.
184
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
185
+ * @example
186
+ * const formatDate = injectFormatDate();
187
+ * readonly displayDate = computed(() => formatDate(this.date()));
188
+ */
189
+ declare function injectFormatDate(): (date: SupportedDateInput | Signal<SupportedDateInput>, optOrLocale?: Partial<FormatDateOptions> | Signal<Partial<FormatDateOptions>> | string | Signal<string>) => string;
126
190
 
127
191
  /**
128
192
  * Options for formatting a display name
@@ -130,24 +194,46 @@ declare function formatDate(date: SupportedDateInput | Signal<SupportedDateInput
130
194
  type FormatDisplayNameOptions = {
131
195
  /**
132
196
  * The display style for the result set
197
+ * @default 'long'
133
198
  */
134
- style: Intl.RelativeTimeFormatStyle;
199
+ style?: Intl.RelativeTimeFormatStyle;
135
200
  /**
136
- * Locale to use for formatting, opts out to dynamic locale changes
201
+ * Locale to use for formatting
137
202
  */
203
+ locale: string;
204
+ };
205
+ /**
206
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
207
+ */
208
+ type UnsafeFormatDisplayNameOptions = Omit<FormatDisplayNameOptions, 'locale'> & {
209
+ /** Optional locale string falling back to the legacy global signal */
138
210
  locale?: string;
139
211
  };
140
212
  type SupportedCode = string | null | undefined;
141
213
  /**
142
- * Format a display name using the current or provided locale
143
- * 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
144
- *
145
- * @param value - The code to format
146
- * @param type - The type of display name to format
147
- * @param opt - Options for formatting
148
- * @returns Formatted display name string
214
+ * @example formatDisplayName(this.value, 'region', this.locale)
149
215
  */
150
- declare function formatDisplayName(value: SupportedCode | Signal<SupportedCode>, type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>, opt?: FormatDisplayNameOptions | Signal<FormatDisplayNameOptions>): string;
216
+ declare function formatDisplayName(value: SupportedCode | Signal<SupportedCode>, type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>, locale: string | Signal<string>): string;
217
+ /**
218
+ * @example formatDisplayName(this.value, 'region', {locale: 'en-US', style: 'long'})
219
+ */
220
+ declare function formatDisplayName(value: SupportedCode | Signal<SupportedCode>, type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>, opt: FormatDisplayNameOptions | Signal<FormatDisplayNameOptions>): string;
221
+ /**
222
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
223
+ * Use `injectFormatDisplayName()` instead, or pass locale explicitly.
224
+ * @example formatDisplayName(this.value)
225
+ */
226
+ declare function formatDisplayName(value: SupportedCode | Signal<SupportedCode>, type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>, opt?: UnsafeFormatDisplayNameOptions | Signal<UnsafeFormatDisplayNameOptions>): string;
227
+ declare const provideFormatDisplayNameDefaults: (valueOrFn: Omit<Partial<FormatDisplayNameOptions>, "locale"> | (() => Omit<Partial<FormatDisplayNameOptions>, "locale"> | Signal<Omit<Partial<FormatDisplayNameOptions>, "locale">>)) => _angular_core.Provider;
228
+
229
+ /**
230
+ * Inject a context-safe date formatting function tied to the current injector.
231
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
232
+ * @example
233
+ * const formatDisplayName = injectFormatDisplayName();
234
+ * readonly region = computed(() => formatDisplayName('US', 'region'));
235
+ */
236
+ declare function injectFormatDisplayName(): (value: SupportedCode | Signal<SupportedCode>, type: Intl.DisplayNamesType | Signal<Intl.DisplayNamesType>, localeOrOpt?: FormatDisplayNameOptions | Signal<FormatDisplayNameOptions> | string | Signal<string>) => string;
151
237
 
152
238
  type ListType = 'conjunction' | 'disjunction' | 'unit';
153
239
  type ListStyle = 'long' | 'short' | 'narrow';
@@ -158,26 +244,50 @@ type SupportedListInput = string[] | null | undefined;
158
244
  type FormatListOptions = {
159
245
  /**
160
246
  * The type of list to format
247
+ * @default 'conjunction'
161
248
  */
162
249
  type?: ListType;
163
250
  /**
164
251
  * The style of list to format
252
+ * @default 'long'
165
253
  */
166
254
  style?: ListStyle;
167
255
  /**
168
- * Locale to use for formatting, opts out to dynamic locale changes
256
+ * Locale to use for formatting
169
257
  */
258
+ locale: string;
259
+ };
260
+ /**
261
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
262
+ */
263
+ type UnsafeFormatListOptions = Omit<FormatListOptions, 'locale'> & {
264
+ /** Optional locale string falling back to the legacy global signal */
170
265
  locale?: string;
171
266
  };
172
267
  /**
173
- * Format a list using the current or provided locale
174
- * 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
175
- *
176
- * @param value - The list to format
177
- * @param opt - Options for formatting
178
- * @returns Formatted list string
268
+ * @example formatList(this.items, this.locale)
269
+ */
270
+ declare function formatList(value: SupportedListInput | Signal<SupportedListInput>, locale: string | Signal<string>): string;
271
+ /**
272
+ * @example formatList(this.items, { locale: 'sl-SI', type: 'disjunction' })
179
273
  */
180
- declare function formatList(value: SupportedListInput | Signal<SupportedListInput>, opt?: FormatListOptions | Signal<FormatListOptions>): string;
274
+ declare function formatList(value: SupportedListInput | Signal<SupportedListInput>, opt: FormatListOptions | Signal<FormatListOptions>): string;
275
+ /**
276
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
277
+ * Use `injectFormatList()` instead, or pass locale explicitly.
278
+ * @example formatList(this.items)
279
+ */
280
+ declare function formatList(value: SupportedListInput | Signal<SupportedListInput>, opt?: UnsafeFormatListOptions | Signal<UnsafeFormatListOptions>): string;
281
+ declare const provideFormatListDefaults: (valueOrFn: Omit<Partial<FormatListOptions>, "locale"> | (() => Omit<Partial<FormatListOptions>, "locale"> | Signal<Omit<Partial<FormatListOptions>, "locale">>)) => _angular_core.Provider;
282
+
283
+ /**
284
+ * Inject a context-safe list formatting function tied to the current injector.
285
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
286
+ * @example
287
+ * const formatList = injectFormatList();
288
+ * readonly displayList = computed(() => formatList(this.items()));
289
+ */
290
+ declare function injectFormatList(): (value: SupportedListInput | Signal<SupportedListInput>, optOrLocale?: Partial<FormatListOptions> | Signal<Partial<FormatListOptions>> | string | Signal<string>) => string;
181
291
 
182
292
  type NumberNotation = 'standard' | 'scientific' | 'engineering' | 'compact';
183
293
  type SupportedNumberValue = number | null | undefined;
@@ -187,6 +297,7 @@ type SupportedNumberValue = number | null | undefined;
187
297
  type FormatNumberOptions = {
188
298
  /**
189
299
  * The notation to use for formatting
300
+ * @default 'standard'
190
301
  */
191
302
  notation?: NumberNotation;
192
303
  /**
@@ -199,27 +310,50 @@ type FormatNumberOptions = {
199
310
  maxFractionDigits?: number;
200
311
  /**
201
312
  * Whether to use grouping
313
+ * @default true
202
314
  */
203
315
  useGrouping?: boolean;
204
- /**
205
- * Locale to use for formatting, opts out to dynamic locale changes
206
- */
207
- locale?: string;
208
316
  /**
209
317
  * If the number is not a valid number, return formatted 0. By default formatter returns an empty string
210
318
  * @default false
211
319
  */
212
320
  fallbackToZero?: boolean;
321
+ /**
322
+ * Locale to use for formatting
323
+ */
324
+ locale: string;
213
325
  };
214
326
  /**
215
- * Format a number using the current or provided locale
216
- * 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
217
- *
218
- * @param number - Number to format
219
- * @param opt - Options for formatting
220
- * @returns Formatted number string
327
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
221
328
  */
222
- declare function formatNumber(value: SupportedNumberValue | Signal<SupportedNumberValue>, opt?: FormatNumberOptions | Signal<FormatNumberOptions>): string;
329
+ type UnsafeFormatNumberOptions = Omit<FormatNumberOptions, 'locale'> & {
330
+ /** Optional locale string falling back to the legacy global signal */
331
+ locale?: string;
332
+ };
333
+ /**
334
+ * @example formatNumber(this.value, this.locale)
335
+ */
336
+ declare function formatNumber(value: SupportedNumberValue | Signal<SupportedNumberValue>, locale: string | Signal<string>): string;
337
+ /**
338
+ * @example formatNumber(this.value, { locale: 'de-DE', notation: 'compact' })
339
+ */
340
+ declare function formatNumber(value: SupportedNumberValue | Signal<SupportedNumberValue>, opt: FormatNumberOptions | Signal<FormatNumberOptions>): string;
341
+ /**
342
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
343
+ * Use `injectFormatNumber()` instead, or pass locale explicitly.
344
+ * @example formatNumber(this.value)
345
+ */
346
+ declare function formatNumber(value: SupportedNumberValue | Signal<SupportedNumberValue>, opt?: UnsafeFormatNumberOptions | Signal<UnsafeFormatNumberOptions>): string;
347
+ declare const provideFormatNumberDefaults: (valueOrFn: Omit<Partial<FormatNumberOptions>, "locale"> | (() => Omit<Partial<FormatNumberOptions>, "locale"> | Signal<Omit<Partial<FormatNumberOptions>, "locale">>)) => _angular_core.Provider;
348
+
349
+ /**
350
+ * Inject a context-safe number formatting function tied to the current injector.
351
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
352
+ * @example
353
+ * const formatNumber = injectFormatNumber();
354
+ * readonly display = computed(() => formatNumber(this.value()));
355
+ */
356
+ declare function injectFormatNumber(): (value: SupportedNumberValue | Signal<SupportedNumberValue>, optOrLocale?: Partial<FormatNumberOptions> | Signal<Partial<FormatNumberOptions>> | string | Signal<string>) => string;
223
357
  /**
224
358
  * Options for formatting a percentage value
225
359
  */
@@ -232,42 +366,97 @@ type FormatPercentOptions = {
232
366
  * Maximum number of fraction digits to use
233
367
  */
234
368
  maxFractionDigits?: number;
235
- /**
236
- * Locale to use for formatting, opts out to dynamic locale changes
237
- */
238
- locale?: string;
239
369
  /**
240
370
  * If the number is not a valid number, return formatted 0. By default formatter returns an empty string
241
371
  * @default false
242
372
  */
243
373
  fallbackToZero?: boolean;
374
+ /**
375
+ * Locale to use for formatting
376
+ */
377
+ locale: string;
244
378
  };
245
379
  /**
246
- * Format a percentage using the current or provided locale
247
- * 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
248
- *
249
- * @param number - Number to format
250
- * @param opt - Options for formatting
251
- * @returns Formatted percentage string
380
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
252
381
  */
253
- declare function formatPercent(value: SupportedNumberValue | Signal<SupportedNumberValue>, opt?: FormatPercentOptions | Signal<FormatPercentOptions>): string;
382
+ type UnsafeFormatPercentOptions = Omit<FormatPercentOptions, 'locale'> & {
383
+ /** Optional locale string falling back to the legacy global signal */
384
+ locale?: string;
385
+ };
386
+ /**
387
+ * @example formatPercent(this.value, this.locale)
388
+ */
389
+ declare function formatPercent(value: SupportedNumberValue | Signal<SupportedNumberValue>, locale: string | Signal<string>): string;
390
+ /**
391
+ * @example formatPercent(this.value, { locale: 'de-DE', maxFractionDigits: 2 })
392
+ */
393
+ declare function formatPercent(value: SupportedNumberValue | Signal<SupportedNumberValue>, opt: FormatPercentOptions | Signal<FormatPercentOptions>): string;
394
+ /**
395
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
396
+ * Use `injectFormatPercent()` instead, or pass locale explicitly.
397
+ * @example formatPercent(this.value)
398
+ */
399
+ declare function formatPercent(value: SupportedNumberValue | Signal<SupportedNumberValue>, opt?: UnsafeFormatPercentOptions | Signal<UnsafeFormatPercentOptions>): string;
400
+ declare const provideFormatPercentDefaults: (valueOrFn: Omit<Partial<FormatPercentOptions>, "locale"> | (() => Omit<Partial<FormatPercentOptions>, "locale"> | Signal<Omit<Partial<FormatPercentOptions>, "locale">>)) => _angular_core.Provider;
401
+
402
+ /**
403
+ * Inject a context-safe percent formatting function tied to the current injector.
404
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
405
+ */
406
+ declare function injectFormatPercent(): (value: SupportedNumberValue | Signal<SupportedNumberValue>, optOrLocale?: Partial<FormatPercentOptions> | Signal<Partial<FormatPercentOptions>> | string | Signal<string>) => string;
254
407
  type CurrencyDisplay = 'symbol' | 'narrowSymbol' | 'code' | 'name';
255
408
  /**
256
409
  * Options for formatting a currency
257
410
  */
258
411
  type FormatCurrencyOptions = {
259
- display?: CurrencyDisplay;
260
412
  /**
261
- * Locale to use for formatting, opts out to dynamic locale changes
413
+ * The display type for the currency format
414
+ * @default 'symbol'
262
415
  */
263
- locale?: string;
416
+ display?: CurrencyDisplay;
264
417
  /**
265
418
  * If the number is not a valid number, return formatted 0. By default formatter returns an empty string
266
419
  * @default false
267
420
  */
268
421
  fallbackToZero?: boolean;
422
+ /**
423
+ * Locale to use for formatting
424
+ */
425
+ locale: string;
426
+ };
427
+ /**
428
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
429
+ */
430
+ type UnsafeFormatCurrencyOptions = Omit<FormatCurrencyOptions, 'locale'> & {
431
+ /** Optional locale string falling back to the legacy global signal */
432
+ locale?: string;
269
433
  };
270
- declare function formatCurrency(value: SupportedNumberValue | Signal<SupportedNumberValue>, currency: string | Signal<string>, opt?: FormatCurrencyOptions | Signal<FormatCurrencyOptions>): string;
434
+ /**
435
+ * @example formatCurrency(this.value, 'USD', this.locale)
436
+ */
437
+ declare function formatCurrency(value: SupportedNumberValue | Signal<SupportedNumberValue>, currency: string | Signal<string>, locale: string | Signal<string>): string;
438
+ /**
439
+ * @example formatCurrency(this.value, 'EUR', { locale: 'de-DE', display: 'code' })
440
+ */
441
+ declare function formatCurrency(value: SupportedNumberValue | Signal<SupportedNumberValue>, currency: string | Signal<string>, opt: FormatCurrencyOptions | Signal<FormatCurrencyOptions>): string;
442
+ /**
443
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
444
+ * Use `injectFormatCurrency()` instead, or pass locale explicitly.
445
+ * @example formatCurrency(this.value, 'USD')
446
+ */
447
+ declare function formatCurrency(value: SupportedNumberValue | Signal<SupportedNumberValue>, currency: string | Signal<string>, opt?: UnsafeFormatCurrencyOptions | Signal<UnsafeFormatCurrencyOptions>): string;
448
+ declare const provideFormatCurrencyDefaults: (valueOrFn: Omit<Partial<FormatCurrencyOptions>, "locale"> | (() => Omit<Partial<FormatCurrencyOptions>, "locale"> | Signal<Omit<Partial<FormatCurrencyOptions>, "locale">>)) => _angular_core.Provider;
449
+
450
+ /**
451
+ * Inject a context-safe currency formatting function tied to the current injector.
452
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
453
+ */
454
+ declare function injectFormatCurrency(): (value: SupportedNumberValue | Signal<SupportedNumberValue>, currency: string | Signal<string>, optOrLocale?: Partial<FormatCurrencyOptions> | Signal<Partial<FormatCurrencyOptions>> | string | Signal<string>) => string;
455
+
456
+ declare function createFormatterProvider<T extends {
457
+ locale: string;
458
+ }>(formatterName: string, libraryDefaults: Omit<T, 'locale'>, nonLocaleEqual: (a: Omit<T, 'locale'>, b: Omit<T, 'locale'>) => boolean): readonly [(valueOrFn: Omit<Partial<T>, "locale"> | (() => Omit<Partial<T>, "locale"> | Signal<Omit<Partial<T>, "locale">>)) => Provider, () => Signal<T>];
459
+ type inferProvideParameter<T extends ReturnType<typeof createFormatterProvider>[0]> = Parameters<T>[0];
271
460
 
272
461
  /**
273
462
  * Options for formatting a relative time value
@@ -284,22 +473,63 @@ type FormatRelativeTimeOptions = {
284
473
  */
285
474
  numeric?: Intl.RelativeTimeFormatNumeric;
286
475
  /**
287
- * Locale to use for formatting, opts out to dynamic locale changes
476
+ * Locale to use for formatting
288
477
  */
478
+ locale: string;
479
+ };
480
+ /**
481
+ * @deprecated UNSAFE FOR SSR/EDGE. Omiting the locale property forces a fallback to a process-level global singleton.
482
+ */
483
+ type UnsafeFormatRelativeTimeOptions = Omit<FormatRelativeTimeOptions, 'locale'> & {
484
+ /** Optional locale string falling back to the legacy global signal */
289
485
  locale?: string;
290
486
  };
291
487
  type RelativeTimeUnit = Intl.RelativeTimeFormatUnit;
292
488
  type SupportedRelativeTimeInput = number | null | undefined;
293
489
  /**
294
- * Format a relative time using the current or provided locale
295
- * 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
296
- *
297
- * @param value - The numeric value to use in the relative time internationalization message
298
- * @param unit - The unit to use in the relative time internationalization message
299
- * @param opt - Options for formatting
300
- * @returns Formatted relative time string
490
+ * @example formatRelativeTime(this.value, this.unit, this.locale)
491
+ */
492
+ declare function formatRelativeTime(value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>, unit: RelativeTimeUnit | Signal<RelativeTimeUnit>, locale: string | Signal<string>): string;
493
+ /**
494
+ * @example formatRelativeTime(this.value, 'day', { locale: 'sl-SI', numeric: 'auto' })
495
+ */
496
+ declare function formatRelativeTime(value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>, unit: RelativeTimeUnit | Signal<RelativeTimeUnit>, opt: FormatRelativeTimeOptions | Signal<FormatRelativeTimeOptions>): string;
497
+ /**
498
+ * @deprecated UNSAFE FOR SSR/EDGE. This signature reads from a process-level global singleton, will be fully removed when Angular 23 drops
499
+ * Use `injectFormatRelativeTime()` instead, or pass locale explicitly.
500
+ * @example formatRelativeTime(this.value, 'day')
301
501
  */
302
- declare function formatRelativeTime(value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>, unit: RelativeTimeUnit | Signal<RelativeTimeUnit>, opt?: FormatRelativeTimeOptions | Signal<FormatRelativeTimeOptions>): string;
502
+ declare function formatRelativeTime(value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>, unit: RelativeTimeUnit | Signal<RelativeTimeUnit>, opt?: UnsafeFormatRelativeTimeOptions | Signal<UnsafeFormatRelativeTimeOptions>): string;
503
+ declare const provideFormatRelativeTimeDefaults: (valueOrFn: Omit<Partial<FormatRelativeTimeOptions>, "locale"> | (() => Omit<Partial<FormatRelativeTimeOptions>, "locale"> | Signal<Omit<Partial<FormatRelativeTimeOptions>, "locale">>)) => _angular_core.Provider;
504
+
505
+ /**
506
+ * Inject a context-safe relative time formatting function tied to the current injector.
507
+ * Uses the libraries locale signal & provided default configuration to react to locale/config changes
508
+ * @example
509
+ * const formatRelativeTime = injectFormatRelativeTime();
510
+ * readonly relativeAge = computed(() => formatRelativeTime(this.delta(), 'day'));
511
+ */
512
+ declare function injectFormatRelativeTime(): (value: SupportedRelativeTimeInput | Signal<SupportedRelativeTimeInput>, unit: RelativeTimeUnit | Signal<RelativeTimeUnit>, optOrLocale?: Partial<FormatRelativeTimeOptions> | Signal<Partial<FormatRelativeTimeOptions>> | string | Signal<string>) => string;
513
+
514
+ type FormatDefaults = {
515
+ date?: inferProvideParameter<typeof provideFormatDateDefaults>;
516
+ displayName?: inferProvideParameter<typeof provideFormatDisplayNameDefaults>;
517
+ list?: inferProvideParameter<typeof provideFormatListDefaults>;
518
+ relativeTime?: inferProvideParameter<typeof provideFormatRelativeTimeDefaults>;
519
+ number?: inferProvideParameter<typeof provideFormatNumberDefaults>;
520
+ percent?: inferProvideParameter<typeof provideFormatPercentDefaults>;
521
+ currency?: inferProvideParameter<typeof provideFormatCurrencyDefaults>;
522
+ };
523
+ declare function provideFormatDefaults(cfg: FormatDefaults): Provider[];
524
+ declare function injectFormatters(): {
525
+ date: (date: _mmstack_translate.SupportedDateInput | _angular_core.Signal<_mmstack_translate.SupportedDateInput>, optOrLocale?: Partial<_mmstack_translate.FormatDateOptions> | _angular_core.Signal<Partial<_mmstack_translate.FormatDateOptions>> | string | _angular_core.Signal<string>) => string;
526
+ displayName: (value: (string | null | undefined) | _angular_core.Signal<string | null | undefined>, type: Intl.DisplayNamesType | _angular_core.Signal<Intl.DisplayNamesType>, localeOrOpt?: _mmstack_translate.FormatDisplayNameOptions | _angular_core.Signal<_mmstack_translate.FormatDisplayNameOptions> | string | _angular_core.Signal<string>) => string;
527
+ list: (value: _mmstack_translate.SupportedListInput | _angular_core.Signal<_mmstack_translate.SupportedListInput>, optOrLocale?: Partial<_mmstack_translate.FormatListOptions> | _angular_core.Signal<Partial<_mmstack_translate.FormatListOptions>> | string | _angular_core.Signal<string>) => string;
528
+ relativeTime: (value: (number | null | undefined) | _angular_core.Signal<number | null | undefined>, unit: _mmstack_translate.RelativeTimeUnit | _angular_core.Signal<_mmstack_translate.RelativeTimeUnit>, optOrLocale?: Partial<_mmstack_translate.FormatRelativeTimeOptions> | _angular_core.Signal<Partial<_mmstack_translate.FormatRelativeTimeOptions>> | string | _angular_core.Signal<string>) => string;
529
+ number: (value: (number | null | undefined) | _angular_core.Signal<number | null | undefined>, optOrLocale?: Partial<_mmstack_translate.FormatNumberOptions> | _angular_core.Signal<Partial<_mmstack_translate.FormatNumberOptions>> | string | _angular_core.Signal<string>) => string;
530
+ percent: (value: (number | null | undefined) | _angular_core.Signal<number | null | undefined>, optOrLocale?: Partial<_mmstack_translate.FormatPercentOptions> | _angular_core.Signal<Partial<_mmstack_translate.FormatPercentOptions>> | string | _angular_core.Signal<string>) => string;
531
+ currency: (value: (number | null | undefined) | _angular_core.Signal<number | null | undefined>, currency: string | _angular_core.Signal<string>, optOrLocale?: Partial<_mmstack_translate.FormatCurrencyOptions> | _angular_core.Signal<Partial<_mmstack_translate.FormatCurrencyOptions>> | string | _angular_core.Signal<string>) => string;
532
+ };
303
533
 
304
534
  type BaseConfig = Omit<IntlConfig, 'locale' | 'messages'> & {
305
535
  /** Checks next locale is in provided array before switching locales */
@@ -484,10 +714,10 @@ declare function provideMockTranslations(options?: MockTranslationOptions): Prov
484
714
 
485
715
  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
716
  private readonly t;
487
- readonly translate: i0.InputSignal<TMap[TKey] extends void ? TKey | [key: TKey] : [key: TKey, vars: TMap[TKey]]>;
717
+ readonly translate: _angular_core.InputSignal<TMap[TKey] extends void ? TKey | [key: TKey] : [key: TKey, vars: TMap[TKey]]>;
488
718
  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>;
719
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<Translate<any, any, any, any>, never>;
720
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<Translate<any, any, any, any>, never, never, { "translate": { "alias": "translate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
491
721
  }
492
722
 
493
723
  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;
@@ -521,5 +751,5 @@ declare abstract class Translator<T extends CompiledTranslation<UnknownStringKey
521
751
  */
522
752
  declare function withParams<const P extends Record<string, unknown>, const S extends string = string>(message: S): WithParams<P, S>;
523
753
 
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 };
525
- export type { CompiledTranslation, FormatCurrencyOptions, FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions, FormatPercentOptions, FormatRelativeTimeOptions, RelativeTimeUnit, SupportedDateInput, SupportedListInput, inferCompiledTranslationMap, inferCompiledTranslationNamespace, inferCompiledTranslationShape, mergeTranslationMaps };
754
+ export { Translate, Translator, canMatchLocale, compileTranslation, createNamespace, formatCurrency, formatDate, formatDisplayName, formatList, formatNumber, formatPercent, formatRelativeTime, injectAddTranslations, injectDynamicLocale, injectFormatCurrency, injectFormatDate, injectFormatDisplayName, injectFormatList, injectFormatNumber, injectFormatPercent, injectFormatRelativeTime, injectFormatters, injectIntl, injectResolveParamLocale, injectSupportedLocales, injectUnsafeT, provideFormatCurrencyDefaults, provideFormatDateDefaults, provideFormatDefaults, provideFormatDisplayNameDefaults, provideFormatListDefaults, provideFormatNumberDefaults, provideFormatPercentDefaults, provideFormatRelativeTimeDefaults, provideIntlConfig, provideMockTranslations, registerNamespace, registerRemoteNamespace, withParams };
755
+ export type { CompiledTranslation, FormatCurrencyOptions, FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions, FormatPercentOptions, FormatRelativeTimeOptions, RelativeTimeUnit, SupportedDateInput, SupportedListInput, UnsafeFormatCurrencyOptions, UnsafeFormatDateOptions, UnsafeFormatDisplayNameOptions, UnsafeFormatListOptions, UnsafeFormatNumberOptions, UnsafeFormatPercentOptions, UnsafeFormatRelativeTimeOptions, inferCompiledTranslationMap, inferCompiledTranslationNamespace, inferCompiledTranslationShape, mergeTranslationMaps };