@verbaly/nuxt 0.76.0 → 0.78.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 CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  Server-rendered pages arrive already translated in the visitor's language (the address first when your URLs carry it, then the cookie, 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
- One line in `nuxt.config` wires everything: the Vite plugin (live extraction + the `virtual:verbaly` module), the per-request negotiation and `<html lang>`/`<html dir>`.
16
+ One line in `nuxt.config` wires everything: the Vite plugin (live extraction + the `verbaly/app` module), the per-request negotiation and `<html lang>`/`<html dir>`.
17
17
 
18
18
  ## 🚀 Install
19
19
 
@@ -54,17 +54,18 @@ const t = useT();
54
54
 
55
55
  `useT()` is typed by your catalog: the types go to `.nuxt/verbaly.d.ts`, where Nuxt links them, and `npx verbaly extract` writes that same file. A key no catalog has fails `nuxi typecheck`.
56
56
 
57
- **3. Switching languages** (client): persists the cookie the server reads:
57
+ **3. Switching languages** (client): with a prefix in your URLs it goes to the same page in the other language; without one it loads the catalog and switches this page. Either way it saves the choice in the cookie the server reads:
58
58
 
59
59
  ```vue
60
60
  <script setup>
61
- import { switchLocale } from 'verbaly';
61
+ import { switchLocale } from 'verbaly/app';
62
62
  import { useVerbaly } from '@verbaly/vue';
63
+ // the instance this page renders with: the module builds one per request
63
64
  const verbaly = useVerbaly();
64
65
  </script>
65
66
 
66
67
  <template>
67
- <button @click="switchLocale(verbaly, 'es')">Español</button>
68
+ <button @click="switchLocale('es', { instance: verbaly })">Español</button>
68
69
  </template>
69
70
  ```
70
71
 
package/dist/module.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ViteVerbalyOptions, ViteVerbalyOptions as ViteVerbalyOptions$1 } from "@verbaly/vite";
2
- //#region src/module.d.ts
3
2
  export interface VerbalyNuxtOptions extends ViteVerbalyOptions$1 {
4
3
  cookie?: string | false;
5
4
  fallback?: string;
@@ -38,5 +37,4 @@ declare namespace verbalyModule {
38
37
  };
39
38
  var getOptions: (inlineOptions?: Partial<VerbalyNuxtOptions>, nuxt?: NuxtLike) => Promise<VerbalyNuxtOptions>;
40
39
  }
41
- //#endregion
42
40
  export { type ViteVerbalyOptions, verbalyModule as default };
package/dist/module.js CHANGED
@@ -2,7 +2,7 @@ import { loadCatalogs, loadConfig, writeDts } from "@verbaly/compiler";
2
2
  import verbalyVite from "@verbaly/vite";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- //#region src/module.ts
5
+ // src/module.ts
6
6
  const runtimeDir = join(dirname(fileURLToPath(import.meta.url)), "runtime");
7
7
  function verbalyModule(inlineOptions, nuxt) {
8
8
  const { cookie, fallback, ...vite } = {
@@ -37,5 +37,4 @@ verbalyModule.getOptions = async (inlineOptions, nuxt) => ({
37
37
  ...nuxt?.options.verbaly,
38
38
  ...inlineOptions
39
39
  });
40
- //#endregion
41
40
  export { verbalyModule as default };
@@ -3,7 +3,7 @@ import { verbalyPlugin } from "@verbaly/vue";
3
3
  import { LOCALE_STORAGE_KEY, localeDirection, resolveRequestLocale } from "verbaly";
4
4
  import { createRequestInstance, locales, routing, sourceLocale } from "virtual:verbaly";
5
5
  import { shallowRef } from "vue";
6
- //#region src/runtime/plugin.ts
6
+ // src/runtime/plugin.ts
7
7
  function readCookie(header, name) {
8
8
  if (!header) return void 0;
9
9
  for (const part of header.split(";")) {
@@ -19,7 +19,7 @@ function readCookie(header, name) {
19
19
  }
20
20
  }
21
21
  var plugin_default = defineNuxtPlugin(async (nuxtApp) => {
22
- if (!Array.isArray(locales) || locales.length === 0) throw new Error("[verbaly] no `locales` in 'virtual:verbaly': declare them in verbaly.config or in the module options (`verbaly: { locales: [...] }` in nuxt.config)");
22
+ if (!Array.isArray(locales) || locales.length === 0) throw new Error("[verbaly] no `locales` in 'verbaly/app': declare them in verbaly.config or in the module options (`verbaly: { locales: [...] }` in nuxt.config)");
23
23
  const runtime = useRuntimeConfig();
24
24
  const config = runtime.public.verbaly ?? {};
25
25
  const cookieName = config.cookie === false ? false : config.cookie || LOCALE_STORAGE_KEY;
@@ -59,5 +59,4 @@ var plugin_default = defineNuxtPlugin(async (nuxtApp) => {
59
59
  dir
60
60
  } });
61
61
  });
62
- //#endregion
63
62
  export { plugin_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/nuxt",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "description": "Nuxt integration for Verbaly: zero-config module with per-request locale negotiation and flash-free hydration.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -21,6 +21,10 @@
21
21
  "bugs": {
22
22
  "url": "https://github.com/AronSoto/verbaly/issues"
23
23
  },
24
+ "funding": {
25
+ "type": "github",
26
+ "url": "https://github.com/sponsors/AronSoto"
27
+ },
24
28
  "type": "module",
25
29
  "types": "./dist/module.d.ts",
26
30
  "exports": {
@@ -41,19 +45,19 @@
41
45
  "access": "public"
42
46
  },
43
47
  "dependencies": {
44
- "@verbaly/compiler": "^0.76.0",
45
- "@verbaly/vite": "^0.76.0"
48
+ "@verbaly/compiler": "^0.78.0",
49
+ "@verbaly/vite": "^0.78.0"
46
50
  },
47
51
  "peerDependencies": {
48
- "@verbaly/vue": "^0.76.0",
49
- "verbaly": "^0.76.0",
52
+ "@verbaly/vue": "^0.78.0",
53
+ "verbaly": "^0.78.0",
50
54
  "vue": "^3.4.0"
51
55
  },
52
56
  "devDependencies": {
53
- "@nuxt/schema": "^4.6.2",
54
- "@verbaly/vue": "^0.76.0",
57
+ "@nuxt/schema": "^4.6.3",
58
+ "@verbaly/vue": "^0.78.0",
55
59
  "happy-dom": "^21.0.4",
56
- "verbaly": "^0.76.0",
60
+ "verbaly": "^0.78.0",
57
61
  "vue": "^3.5.44"
58
62
  },
59
63
  "scripts": {