@stacksjs/defaults 0.75.586 → 0.75.590

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.
@@ -188,8 +188,8 @@ operations must keep different locales.
188
188
  `createLocaleSwitchResponse(request, localeCode, config)` sets a locale cookie
189
189
  and redirects to an equivalent localized path. `stripLocalePrefix` and
190
190
  `localizePath` share its path rules. The default locale remains unprefixed;
191
- other supported locales receive their prefix. Wire the handler through a real
192
- route rather than only changing a client string.
191
+ other supported locales receive their prefix. Use this redirect helper for a deliberate server navigation. For an in-place
192
+ app language switch, use the reactive browser composable below.
193
193
 
194
194
  The package re-exports the ts-i18n disk/codegen surface as
195
195
  `loadTranslationsFromDisk`, `generateI18nTypes`, `generateI18nTypesFromModule`,
@@ -220,3 +220,39 @@ default:
220
220
  - **CLDR rules come from the runtime** - `Intl.PluralRules`, no data shipped and no table to fall out of date
221
221
  - **HTML escaping is opt-in** - `escapeValues: true` in config
222
222
  - **Formatting uses Intl APIs** - delegates to `Intl.DateTimeFormat`, `Intl.NumberFormat`, etc.
223
+
224
+ ## Reactive browser and native screens
225
+
226
+ Use `createI18n` from `@stacksjs/i18n/client` in browser modules requiring a
227
+ framework-independent translator. This entry has no filesystem loader or app
228
+ configuration imports. File loading and request helpers remain in the root entry.
229
+
230
+ Use `useI18n` from `@stacksjs/i18n/stx` inside shared STX browser/native modules.
231
+ Its locale and message reads participate in native STX reactivity. The root
232
+ server entry also re-exports this composable. Keep the instance shared by the
233
+ screen's modules; create separate instances for independent server requests.
234
+
235
+ ```ts
236
+ import { useI18n } from '@stacksjs/i18n/stx'
237
+
238
+ const words = useI18n({
239
+ locale: 'en',
240
+ messages: { en: { verified: 'Email verified' }, de: { verified: 'E-Mail bestätigt' } },
241
+ })
242
+ // STX binding: <p :text="words.t('verified')"></p>
243
+ words.setLocale('de') // Updates that binding; the mounted form survives.
244
+ const stop = words.subscribe(() => console.log(words.locale))
245
+ stop() // Remove an optional observer when its owner is disposed.
246
+ ```
247
+
248
+ `setLocale`, assigning `.locale`, and `addTranslations` invalidate reads.
249
+ Selecting the current locale is a no-op. Instances do not change one another.
250
+ The app owns cookie/account preference persistence and `<html lang>` metadata;
251
+ none of these APIs navigate, refetch HTML, reset forms or repeat verification.
252
+ Persist preferences separately from immediate UI updates. Every visible label
253
+ must be a reactive binding, including shared navigation and error messages.
254
+ Existing server-rendered text alone does not become reactive automatically.
255
+
256
+ `core/i18n/tests/client-i18n.test.ts` verifies browser-safe bundling, reactive
257
+ translation/plural/number updates, preserved unrelated state, subscriptions and
258
+ regional plural fallback. Add app browser tests for the complete switch flow.
@@ -57,7 +57,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
57
57
  | `@stacksjs/health` | [`stacks-health`](../stacks-health/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/health/src/index.ts) | 2 |
58
58
  | `@stacksjs/hq` | [`stacks-hq`](../stacks-hq/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/hq/src/index.ts) | 9 |
59
59
  | `@stacksjs/http` | [`stacks-http`](../stacks-http/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/index.ts) | 4 |
60
- | `@stacksjs/i18n` | [`stacks-i18n`](../stacks-i18n/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/index.ts) | 5 |
60
+ | `@stacksjs/i18n` | [`stacks-i18n`](../stacks-i18n/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/index.ts) | 7 |
61
61
  | `@stacksjs/image` | [`stacks-image`](../stacks-image/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/index.ts) | 4 |
62
62
  | `@stacksjs/lint` | [`stacks-lint`](../stacks-lint/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/lint/src/index.ts) | 3 |
63
63
  | `@stacksjs/logging` | [`stacks-logging`](../stacks-logging/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/src/index.ts) | 14 |
@@ -568,9 +568,9 @@ Guidance: [`stacks-i18n`](../stacks-i18n/SKILL.md). Source: [storage/framework/c
568
568
 
569
569
  Declared runtime exports: `I18n`, `addTranslations`, `applyRequestLocale`, `createI18n`, `createLocaleSwitchResponse`, `createSimpleTranslator`, `ensureLocalesLoaded`, `formatCurrency`, `formatDate`, `formatDateTime`, `formatList`, `formatNumber`, `formatPercent`, `formatPlural`, `formatRelativeTime`, `formatTime`, `generateI18nSampleConfig`, `generateI18nTypes`, `generateI18nTypesFromModule`, `getAvailableLocales`, `getLocale`, `hasTranslation`, `loadTranslations`, `loadTranslationsFromDisk`, `localizePath`, `resolveRequestLocale`, `setLocale`, `stripLocalePrefix`, `t`, `tc`, `te`, `tm`, `trans`, `useI18n`, `writeI18nOutputs`.
570
570
 
571
- Local source modules: [src/bootstrap.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/bootstrap.ts), [src/formatter.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/formatter.ts), [src/loader.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/loader.ts), [src/locale-switch.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/locale-switch.ts), [src/pluralization.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/pluralization.ts), [src/translator.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/translator.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/types.ts).
571
+ Local source modules: [src/bootstrap.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/bootstrap.ts), [src/formatter.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/formatter.ts), [src/loader.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/loader.ts), [src/locale-switch.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/locale-switch.ts), [src/pluralization.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/pluralization.ts), [src/stx.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/stx.ts), [src/translator.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/translator.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/types.ts).
572
572
 
573
- Evidence directory: [5 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
573
+ Evidence directory: [7 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
574
574
 
575
575
  ### @stacksjs/image
576
576
 
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.586",
5
+ "version": "0.75.590",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.586",
5
+ "version": "0.75.590",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,14 +45,14 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.586",
48
+ "@stacksjs/mobile": "0.75.590",
49
49
  "@stacksjs/sanitizer": "^0.2.872",
50
50
  "@stacksjs/stx": "^0.2.872",
51
- "@stacksjs/strings": "0.75.586",
51
+ "@stacksjs/strings": "0.75.590",
52
52
  "@xterm/addon-fit": "^0.11.0",
53
53
  "@xterm/xterm": "^6.0.0",
54
54
  "ts-qr-codes": "^0.1.8",
55
- "@stacksjs/support": "0.75.586",
56
- "@stacksjs/browser": "0.75.586"
55
+ "@stacksjs/support": "0.75.590",
56
+ "@stacksjs/browser": "0.75.590"
57
57
  }
58
58
  }