@verbaly/sveltekit 0.22.0 → 0.23.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/README.md +7 -7
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="https://raw.githubusercontent.com/AronSoto/verbaly/develop/assets/logo.png" alt="Verbaly" width="300" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<p align="center"><em>SvelteKit SSR integration for Verbaly
|
|
5
|
+
<p align="center"><em>SvelteKit SSR integration for Verbaly: per-request locale negotiation and flash-free hydration.</em></p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://www.npmjs.com/package/@verbaly/sveltekit"><img src="https://img.shields.io/npm/v/@verbaly/sveltekit?logo=npm&color=cb3837" alt="npm version" /></a>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
Server-rendered pages arrive already translated in the visitor's language
|
|
14
|
+
Server-rendered pages arrive already translated in the visitor's language (cookie first, then `Accept-Language`, then your fallback) and the client hydrates with the **same locale and the same catalog**, so there's no flash of untranslated text and no hydration mismatch. Each request gets its **own instance**: no locale leaking between concurrent users.
|
|
15
15
|
|
|
16
16
|
## 🚀 Install
|
|
17
17
|
|
|
@@ -37,7 +37,7 @@ export default { plugins: [verbaly(), sveltekit()] };
|
|
|
37
37
|
<html lang="%verbaly.lang%">
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
**3. Server hook
|
|
40
|
+
**3. Server hook**: negotiates the locale per request:
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
43
|
// src/hooks.server.ts
|
|
@@ -63,7 +63,7 @@ declare namespace App {
|
|
|
63
63
|
export const load = ({ locals }) => ({ locale: locals.verbalyLocale });
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
**5. One instance per render, catalog awaited
|
|
66
|
+
**5. One instance per render, catalog awaited**: the no-FOUC guarantee, in one call:
|
|
67
67
|
|
|
68
68
|
```ts
|
|
69
69
|
// src/routes/+layout.ts
|
|
@@ -89,7 +89,7 @@ export const load = async ({ data }) => ({
|
|
|
89
89
|
{@render children()}
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
**6. Switching languages** (client)
|
|
92
|
+
**6. Switching languages** (client): persists the cookie the server hook reads:
|
|
93
93
|
|
|
94
94
|
```html
|
|
95
95
|
<script>
|
|
@@ -108,10 +108,10 @@ export const load = async ({ data }) => ({
|
|
|
108
108
|
| --- | --- |
|
|
109
109
|
| `verbalyHandle({ locales, fallback?, cookie? })` | SvelteKit `handle` hook: resolves the request locale (cookie → `Accept-Language` → fallback), sets `event.locals.verbalyLocale`, fills `%verbaly.lang%` in `app.html`. |
|
|
110
110
|
| `switchLocale(instance, locale, { cookie?, maxAge? })` | Awaits the catalog, switches the locale, writes the cookie and syncs `<html lang>`. SSR-safe. |
|
|
111
|
-
| `LOCALE_COOKIE` | Default cookie name (`verbaly-locale`)
|
|
111
|
+
| `LOCALE_COOKIE` | Default cookie name (`verbaly-locale`), shared with core's `localStorage` key. |
|
|
112
112
|
|
|
113
113
|
- `cookie: false` disables cookie reading/writing (pure `Accept-Language`).
|
|
114
|
-
- No dependency on `@sveltejs/kit
|
|
114
|
+
- No dependency on `@sveltejs/kit`: the hook is typed structurally and stays compatible across Kit 2.x.
|
|
115
115
|
|
|
116
116
|
## 📚 Docs
|
|
117
117
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/sveltekit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "SvelteKit SSR integration for Verbaly
|
|
3
|
+
"version": "0.23.0",
|
|
4
|
+
"description": "SvelteKit SSR integration for Verbaly: per-request locale negotiation and flash-free hydration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
7
7
|
"sveltekit",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"verbaly": "^0.
|
|
43
|
+
"verbaly": "^0.23.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sveltejs/kit": "^2.69.
|
|
46
|
+
"@sveltejs/kit": "^2.69.3",
|
|
47
47
|
"svelte": "^5.56.4",
|
|
48
|
-
"verbaly": "0.
|
|
48
|
+
"verbaly": "0.23.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsdown",
|