@ultimat3/i18n 22.6.2 → 22.7.1

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": "22.6.2",
3
+ "version": "22.7.1",
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": "22.6.2"
38
+ "@ultimat3/core": "22.7.1"
39
39
  }
40
40
  }
@@ -27,6 +27,16 @@ export interface CatalogSet<TLocales extends CatalogSources> {
27
27
  keys(): string[];
28
28
  }
29
29
 
30
+ let declarations = 0;
31
+
32
+ /**
33
+ * How many times `defineCatalogs()` has run in this process. `@ultimat3/testing` reads it across a
34
+ * test file: an app's catalog module imported lazily in a test body configures the worker's
35
+ * locales once for good (the module is cached), while a test that calls `configureLocales()` by
36
+ * hand is a change to undo — this count is what tells the two apart.
37
+ */
38
+ export const catalogDeclarationCount = (): number => declarations;
39
+
30
40
  export function defineCatalogs<TLocales extends CatalogSources>(
31
41
  input: DefineCatalogsInput<TLocales>,
32
42
  ): CatalogSet<TLocales> {
@@ -44,6 +54,7 @@ export function defineCatalogs<TLocales extends CatalogSources>(
44
54
  registerCatalog(locale, catalog);
45
55
  }
46
56
  configureLocales({ supported: locales, fallback: input.default });
57
+ declarations += 1;
47
58
 
48
59
  const catalogs = Object.fromEntries(loaded) as Readonly<Record<keyof TLocales & string, Catalog>>;
49
60
  return {
package/src/index.ts CHANGED
@@ -44,6 +44,7 @@ export {
44
44
  export {
45
45
  type CatalogSet,
46
46
  type CatalogSources,
47
+ catalogDeclarationCount,
47
48
  type DefineCatalogsInput,
48
49
  defineCatalogs,
49
50
  } from './define-catalogs';