@ultimat3/i18n 15.0.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/i18n",
3
- "version": "15.0.0",
3
+ "version": "17.0.0",
4
4
  "description": "Dependency-free translator, catalog flattening, locale negotiation and loud missing-key rendering",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,6 +35,6 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@ultimat3/core": "15.0.0"
38
+ "@ultimat3/core": "17.0.0"
39
39
  }
40
40
  }
@@ -238,7 +238,6 @@
238
238
  },
239
239
  "policy": {
240
240
  "all-granted": "every required permission is granted",
241
- "evaluated": "the policy decided this",
242
241
  "granted": "the grant list contains this permission",
243
242
  "missing": "no policy is registered for this permission",
244
243
  "not-granted": "the grant list does not contain this permission"
package/src/context.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * No call site passes a locale by hand — `t()` here is the ambient translator.
4
4
  */
5
5
 
6
- import { cachedFormatter, canonicalLocale, tryUseContext } from '@ultimat3/core';
6
+ import { assertLocale, cachedFormatter, canonicalLocale, tryUseContext } from '@ultimat3/core';
7
7
  import { type Catalog, mergeCatalogs } from './catalog';
8
8
  import {
9
9
  DEFAULT_LOCALE,
@@ -85,8 +85,19 @@ function freshDefaultConfig(): LocaleConfig {
85
85
 
86
86
  let config: LocaleConfig = freshDefaultConfig();
87
87
 
88
- /** Called once at boot from `app.config.ts`. */
88
+ /**
89
+ * Called once at boot from `app.config.ts`.
90
+ *
91
+ * Screened before it is stored, and this is the ONE screen the locale path needs: `resolveLocale`
92
+ * can only ever answer with a member of `supported` or the fallback — every other candidate
93
+ * normalises away — so a tag the APP declares is the only route by which a string `Intl` cannot
94
+ * parse reaches `ctx.locale`, and from there `formatDate`, `formatMoney` and `Intl.PluralRules`
95
+ * one request at a time, several frames from the config line that caused it. Refused whole: a
96
+ * rejected call leaves the previous config in place rather than half of a new one.
97
+ */
89
98
  export function configureLocales(partial: Partial<LocaleConfig>): LocaleConfig {
99
+ for (const tag of partial.supported ?? []) assertLocale(tag);
100
+ if (partial.fallback !== undefined) assertLocale(partial.fallback);
90
101
  config = { ...config, ...partial };
91
102
  return config;
92
103
  }