tina4-nodejs 3.13.47 → 3.13.48

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/CLAUDE.md CHANGED
@@ -1,4 +1,4 @@
1
- # CLAUDE.md - AI Developer Guide for tina4-nodejs (v3.13.47)
1
+ # CLAUDE.md - AI Developer Guide for tina4-nodejs (v3.13.48)
2
2
 
3
3
  > This file helps AI assistants (Claude, Copilot, Cursor, etc.) understand and work on this codebase effectively.
4
4
 
package/package.json CHANGED
@@ -1,12 +1,8 @@
1
1
  {
2
2
  "name": "tina4-nodejs",
3
-
4
-
5
-
6
- "version": "3.13.47",
7
-
3
+ "version": "3.13.48",
8
4
  "type": "module",
9
- "description": "Tina4 for Node.js/TypeScript \u2014 54 built-in features, zero dependencies",
5
+ "description": "Tina4 for Node.js/TypeScript - 54 built-in features, zero dependencies",
10
6
  "keywords": [
11
7
  "tina4",
12
8
  "framework",
@@ -57,18 +53,19 @@
57
53
  "scripts": {
58
54
  "build": "npm run build --workspaces",
59
55
  "clean": "rm -rf packages/*/dist",
60
- "test": "tsx test/run-all.ts",
56
+ "test": "tsx test/run-all.ts && npm run test:i18n",
57
+ "test:i18n": "vitest run test/i18n.test.ts test/i18n-leaf-alias.test.ts",
61
58
  "typecheck": "tsc -p tsconfig.typecheck.json"
62
59
  },
63
60
  "engines": {
64
61
  "node": ">=22.0.0"
65
62
  },
66
- "dependencies": {},
67
63
  "devDependencies": {
68
- "typescript": "^5.7.0",
69
- "tsx": "^4.19.0",
64
+ "@types/node": "^22.10.0",
70
65
  "esbuild": "^0.24.0",
71
66
  "mongodb": "^6.0.0",
72
- "@types/node": "^22.10.0"
67
+ "tsx": "^4.19.0",
68
+ "typescript": "^5.7.0",
69
+ "vitest": "^4.1.9"
73
70
  }
74
- }
71
+ }
@@ -10,11 +10,20 @@ export class I18n {
10
10
  private _currentLocale: string;
11
11
  private _translations: Map<string, Record<string, string>> = new Map();
12
12
 
13
- constructor(localeDir?: string, defaultLocale?: string) {
13
+ /**
14
+ * @param locale Default locale code (e.g. "en"). Falls back to
15
+ * TINA4_LOCALE, then "en".
16
+ * @param path Directory holding the JSON/YAML locale files. Falls back to
17
+ * TINA4_LOCALE_DIR, then "src/locales".
18
+ *
19
+ * Arg order is (locale, path) to match the Python master `I18n(locale, path)`
20
+ * (BUG-7, BREAKING in 3.13.x — was previously (localeDir, defaultLocale)).
21
+ */
22
+ constructor(locale?: string, path?: string) {
14
23
  this._localeDir = resolve(
15
- localeDir ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
24
+ path ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
16
25
  );
17
- this._defaultLocale = defaultLocale ?? process.env.TINA4_LOCALE ?? "en";
26
+ this._defaultLocale = locale ?? process.env.TINA4_LOCALE ?? "en";
18
27
  this._currentLocale = this._defaultLocale;
19
28
  this._loadLocale(this._defaultLocale);
20
29
  }
@@ -878,7 +878,7 @@ ${reset}
878
878
  try {
879
879
  const localeFiles = readdirSync(localeDir).filter((f: string) => f.endsWith(".json"));
880
880
  if (localeFiles.length > 0 && !frondEngine.globals?.t) {
881
- const i18nInstance = new I18n(localeDir, process.env.TINA4_LOCALE ?? "en");
881
+ const i18nInstance = new I18n(process.env.TINA4_LOCALE ?? "en", localeDir);
882
882
  frondEngine.addGlobal("t", (key: string, params?: Record<string, string>) => i18nInstance.t(key, params));
883
883
  }
884
884
  } catch {