@warlock.js/core 5.12.0 → 5.13.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
@@ -25,13 +25,12 @@
25
25
  "@mongez/slug": "^1.0.7",
26
26
  "@mongez/supportive-is": "^2.1.4",
27
27
  "@mongez/time-wizard": "^1.0.6",
28
- "@warlock.js/auth": "5.12.0",
29
- "@warlock.js/cache": "5.12.0",
30
- "@warlock.js/cascade": "5.12.0",
31
- "@warlock.js/context": "5.12.0",
32
- "@warlock.js/logger": "5.12.0",
33
- "@warlock.js/seal": "5.12.0",
34
- "@warlock.js/fs": "5.12.0",
28
+ "@warlock.js/cache": "5.13.0",
29
+ "@warlock.js/cascade": "5.13.0",
30
+ "@warlock.js/context": "5.13.0",
31
+ "@warlock.js/logger": "5.13.0",
32
+ "@warlock.js/seal": "5.13.0",
33
+ "@warlock.js/fs": "5.13.0",
35
34
  "chokidar": "^5.0.0",
36
35
  "dayjs": "^1.11.19",
37
36
  "es-module-lexer": "^2.0.0",
@@ -57,10 +56,10 @@
57
56
  "react": "^19.2.3",
58
57
  "react-dom": "^19.2.3",
59
58
  "@react-email/render": "^2.0.5",
60
- "@warlock.js/herald": "5.12.0",
61
- "@warlock.js/ai": "5.12.0",
62
- "@warlock.js/access": "5.12.0",
63
- "@warlock.js/notifications": "5.12.0"
59
+ "@warlock.js/herald": "5.13.0",
60
+ "@warlock.js/ai": "5.13.0",
61
+ "@warlock.js/access": "5.13.0",
62
+ "@warlock.js/notifications": "5.13.0"
64
63
  },
65
64
  "peerDependenciesMeta": {
66
65
  "sharp": {
@@ -123,7 +122,7 @@
123
122
  ],
124
123
  "author": "hassanzohdy",
125
124
  "license": "MIT",
126
- "version": "5.12.0",
125
+ "version": "5.13.0",
127
126
  "type": "module",
128
127
  "main": "./esm/index.mjs",
129
128
  "module": "./esm/index.mjs",
@@ -20,7 +20,7 @@ import { groupedTranslations } from "@mongez/localization";
20
20
 
21
21
  groupedTranslations("products", {
22
22
  notFound: { en: "Product not found", ar: "المنتج غير موجود" },
23
- created: { en: "Product created", ar: "تم إنشاء المنتج" },
23
+ created: { en: "Product created", ar: "تم إنشاء المنتج" },
24
24
  });
25
25
 
26
26
  // 2. Look up in a controller / service
@@ -45,11 +45,11 @@ Every module owns its translation namespace under `src/app/<module>/utils/locale
45
45
  import { groupedTranslations } from "@mongez/localization";
46
46
 
47
47
  groupedTranslations("products", {
48
- notFound: { en: "Product not found", ar: "المنتج غير موجود" },
49
- outOfStock: { en: "Product out of stock", ar: "المنتج غير متوفر" },
50
- created: { en: "Product created", ar: "تم إنشاء المنتج" },
51
- updated: { en: "Product updated", ar: "تم تحديث المنتج" },
52
- deleted: { en: "Product deleted", ar: "تم حذف المنتج" },
48
+ notFound: { en: "Product not found", ar: "المنتج غير موجود" },
49
+ outOfStock: { en: "Product out of stock", ar: "المنتج غير متوفر" },
50
+ created: { en: "Product created", ar: "تم إنشاء المنتج" },
51
+ updated: { en: "Product updated", ar: "تم تحديث المنتج" },
52
+ deleted: { en: "Product deleted", ar: "تم حذف المنتج" },
53
53
  });
54
54
  ```
55
55
 
@@ -96,6 +96,10 @@ request.trans("products.notFound");
96
96
 
97
97
  All three lookups go through `@mongez/localization`'s `trans()` under the hood, with the locale pulled from the request context (or the global default).
98
98
 
99
+ ### Web `useTrans()` key checking
100
+
101
+ When an app uses `@warlock.js/web`, `warlock dev` writes `.warlock/typings/translations.d.ts` from literal `groupedTranslations("group", { key: ... })` registrations. It augments web's `TranslationKeyRegistry`, so `useTrans()("products.notFound")` is checked against registered keys and a typo fails TypeScript. Before the generated file exists, `useTrans()` accepts `string` for a non-breaking first boot. Dynamic groups/keys and placeholders are not inferred.
102
+
99
103
  ### Locale on a specific lookup
100
104
 
101
105
  ```ts
@@ -123,7 +127,7 @@ Configure the default:
123
127
 
124
128
  ```ts title="src/config/app.ts"
125
129
  export default {
126
- localeCode: "en", // app-wide default
130
+ localeCode: "en", // app-wide default
127
131
  // ...
128
132
  };
129
133
  ```
@@ -142,20 +146,19 @@ When a column stores per-locale values as an array:
142
146
 
143
147
  ```ts
144
148
  // Schema (Seal):
145
- name_translations: v.array(
149
+ name_translations: (v.array(
146
150
  v.object({
147
- localeCode: v.string(), // "en", "ar", ...
151
+ localeCode: v.string(), // "en", "ar", ...
148
152
  value: v.string(),
149
- })
153
+ }),
150
154
  ),
151
-
152
- // Stored row (DB):
153
- {
154
- name_translations: [
155
- { localeCode: "en", value: "Hello World" },
156
- { localeCode: "ar", value: "مرحبا" },
157
- ],
158
- }
155
+ // Stored row (DB):
156
+ {
157
+ name_translations: [
158
+ { localeCode: "en", value: "Hello World" },
159
+ { localeCode: "ar", value: "مرحبا" },
160
+ ],
161
+ });
159
162
  ```
160
163
 
161
164
  Pick the right one for the current request:
@@ -179,12 +182,12 @@ getLocalized(
179
182
  ```
180
183
 
181
184
  - **`values`** — the localized-array column.
182
- - **`localeCode`** *(optional)* — pin to a specific locale. Defaults to the current request's locale (reads via `useRequestStore()`).
183
- - **`key`** *(default `"value"`)* — which property of the matched entry to return. Use a different key if your localized objects store the value under a different name.
185
+ - **`localeCode`** _(optional)_ — pin to a specific locale. Defaults to the current request's locale (reads via `useRequestStore()`).
186
+ - **`key`** _(default `"value"`)_ — which property of the matched entry to return. Use a different key if your localized objects store the value under a different name.
184
187
 
185
188
  ```ts
186
189
  const slug = getLocalized(product.get("slug_translations"), undefined, "value");
187
- const tagline = getLocalized(product.get("name_translations"), "fr"); // force French
190
+ const tagline = getLocalized(product.get("name_translations"), "fr"); // force French
188
191
  ```
189
192
 
190
193
  ### Use inside a resource for clean per-locale responses