@uipkge/nuxt 0.1.1 → 10.2.3-i18now.1
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/LICENSE +25 -0
- package/README.md +23 -105
- package/dist/module.d.mts +653 -20
- package/dist/module.json +5 -4
- package/dist/module.mjs +1746 -56
- package/dist/runtime/compatibility.d.ts +15 -0
- package/dist/runtime/compatibility.js +7 -0
- package/dist/runtime/components/NuxtLinkLocale.d.ts +8 -0
- package/dist/runtime/components/NuxtLinkLocale.js +59 -0
- package/dist/runtime/components/SwitchLocalePathLink.d.ts +16 -0
- package/dist/runtime/components/SwitchLocalePathLink.js +45 -0
- package/dist/runtime/composables/index-server.d.ts +2 -0
- package/dist/runtime/composables/index-server.js +2 -0
- package/dist/runtime/composables/index.d.ts +189 -0
- package/dist/runtime/composables/index.js +89 -0
- package/dist/runtime/composables/server.d.ts +41 -0
- package/dist/runtime/composables/server.js +3 -0
- package/dist/runtime/composables/shared.d.ts +36 -0
- package/dist/runtime/composables/shared.js +6 -0
- package/dist/runtime/context.d.ts +49 -0
- package/dist/runtime/context.js +136 -0
- package/dist/runtime/kit/browser.d.ts +11 -0
- package/dist/runtime/kit/browser.js +32 -0
- package/dist/runtime/kit/head.d.ts +51 -0
- package/dist/runtime/kit/head.js +141 -0
- package/dist/runtime/kit/routing.d.ts +17 -0
- package/dist/runtime/kit/routing.js +29 -0
- package/dist/runtime/kit/types.d.ts +35 -0
- package/dist/runtime/kit/types.js +0 -0
- package/dist/runtime/plugins/dev.d.ts +11 -0
- package/dist/runtime/plugins/dev.js +84 -0
- package/dist/runtime/plugins/i18n.d.ts +2 -0
- package/dist/runtime/plugins/i18n.js +134 -0
- package/dist/runtime/plugins/i18now.client.d.ts +2 -0
- package/dist/runtime/plugins/i18now.client.js +35 -0
- package/dist/runtime/plugins/preload.d.ts +2 -0
- package/dist/runtime/plugins/preload.js +81 -0
- package/dist/runtime/plugins/route-locale-detect.d.ts +2 -0
- package/dist/runtime/plugins/route-locale-detect.js +30 -0
- package/dist/runtime/plugins/ssg-detect.d.ts +2 -0
- package/dist/runtime/plugins/ssg-detect.js +20 -0
- package/dist/runtime/plugins/switch-locale-path-ssr.d.ts +2 -0
- package/dist/runtime/plugins/switch-locale-path-ssr.js +30 -0
- package/dist/runtime/routing/domain.d.ts +5 -0
- package/dist/runtime/routing/domain.js +18 -0
- package/dist/runtime/routing/head.d.ts +17 -0
- package/dist/runtime/routing/head.js +98 -0
- package/dist/runtime/routing/i18n.d.ts +13 -0
- package/dist/runtime/routing/i18n.js +40 -0
- package/dist/runtime/routing/routing.d.ts +23 -0
- package/dist/runtime/routing/routing.js +54 -0
- package/dist/runtime/routing/utils.d.ts +11 -0
- package/dist/runtime/routing/utils.js +27 -0
- package/dist/runtime/server/context.d.ts +142 -0
- package/dist/runtime/server/context.js +47 -0
- package/dist/runtime/server/plugin.d.ts +2 -0
- package/dist/runtime/server/plugin.js +192 -0
- package/dist/runtime/server/routes/i18now-sync.d.ts +2 -0
- package/dist/runtime/server/routes/i18now-sync.js +36 -0
- package/dist/runtime/server/routes/messages.d.ts +7 -0
- package/dist/runtime/server/routes/messages.js +38 -0
- package/dist/runtime/server/type-generation.d.ts +2 -0
- package/dist/runtime/server/type-generation.js +91 -0
- package/dist/runtime/server/utils/cache.d.ts +15 -0
- package/dist/runtime/server/utils/cache.js +33 -0
- package/dist/runtime/server/utils/locale-detector.d.ts +7 -0
- package/dist/runtime/server/utils/locale-detector.js +36 -0
- package/dist/runtime/server/utils/messages-utils.d.ts +21 -0
- package/dist/runtime/server/utils/messages-utils.js +33 -0
- package/dist/runtime/server/utils/messages.d.ts +9 -0
- package/dist/runtime/server/utils/messages.js +55 -0
- package/dist/runtime/shared/detection.d.ts +12 -0
- package/dist/runtime/shared/detection.js +33 -0
- package/dist/runtime/shared/domain.d.ts +8 -0
- package/dist/runtime/shared/domain.js +28 -0
- package/dist/runtime/shared/locales.d.ts +21 -0
- package/dist/runtime/shared/locales.js +45 -0
- package/dist/runtime/shared/matching.d.ts +6 -0
- package/dist/runtime/shared/matching.js +50 -0
- package/dist/runtime/shared/messages.d.ts +21 -0
- package/dist/runtime/shared/messages.js +72 -0
- package/dist/runtime/shared/utils.d.ts +13 -0
- package/dist/runtime/shared/utils.js +29 -0
- package/dist/runtime/shared/vue-i18n.d.ts +7 -0
- package/dist/runtime/shared/vue-i18n.js +13 -0
- package/dist/runtime/types.d.ts +111 -0
- package/dist/runtime/types.js +0 -0
- package/dist/runtime/utils.d.ts +56 -0
- package/dist/runtime/utils.js +202 -0
- package/dist/types.d.mts +13 -2
- package/internals.d.ts +34 -0
- package/package.json +118 -29
- package/dist/runtime/composables/useI18n.d.ts +0 -11
- package/dist/runtime/composables/useI18n.js +0 -24
- package/dist/runtime/plugin.client.d.ts +0 -9
- package/dist/runtime/plugin.client.js +0 -100
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -30
- package/dist/runtime/plugin.suppress-warnings.d.ts +0 -12
- package/dist/runtime/plugin.suppress-warnings.js +0 -11
- package/dist/runtime/server/sync.d.ts +0 -2
- package/dist/runtime/server/sync.js +0 -48
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Nuxt Community
|
|
4
|
+
Copyright (c) Rafał Chłodnicki (@rchl)
|
|
5
|
+
Copyright (c) Paul Gascou-Vaillancourt (@paulgv)
|
|
6
|
+
Copyright (c) Kazuya Kawaguchi (@kazupon)
|
|
7
|
+
Copyright (c) Bobbie Goede (@BobbieGoede)
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,130 +1,48 @@
|
|
|
1
1
|
# @uipkge/nuxt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A fork of [@nuxtjs/i18n](https://github.com/nuxt-modules/i18n) with built-in [i18now](https://i18now.com) key sync.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What's different
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Reloads translations on locale switch (client-side)
|
|
9
|
-
- In development: detects missing translation keys and syncs them to i18now automatically
|
|
10
|
-
- Suppresses vue-i18n missing-key warnings in dev — missing keys are expected until published
|
|
11
|
-
- API key is never exposed to the browser (proxied through a local Nuxt server route)
|
|
12
|
-
- Zero bundle impact in production — dev-only code is tree-shaken at build time
|
|
7
|
+
This package is identical to `@nuxtjs/i18n` with one addition: when `i18now` is configured, missing translation keys detected in development are automatically synced to your i18now project.
|
|
13
8
|
|
|
14
|
-
##
|
|
9
|
+
## Install
|
|
15
10
|
|
|
16
|
-
```
|
|
17
|
-
npm install @uipkge/nuxt
|
|
18
|
-
# or
|
|
11
|
+
```sh
|
|
19
12
|
pnpm add @uipkge/nuxt
|
|
20
13
|
```
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
## Usage
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Add the module to `nuxt.config.ts`:
|
|
17
|
+
Replace `@nuxtjs/i18n` with `@uipkge/nuxt` in your `nuxt.config.ts`. All existing configuration works the same — follow the [@nuxtjs/i18n documentation](https://i18n.nuxtjs.org/) for setup, locales, routing, and all other options.
|
|
27
18
|
|
|
28
19
|
```ts
|
|
20
|
+
// nuxt.config.ts
|
|
29
21
|
export default defineNuxtConfig({
|
|
30
22
|
modules: ['@uipkge/nuxt'],
|
|
31
|
-
|
|
32
|
-
i18now: {
|
|
33
|
-
projectId: process.env.I18NOW_PROJECT_ID ?? '',
|
|
34
|
-
apiKey: process.env.I18NOW_API_KEY ?? '',
|
|
35
|
-
},
|
|
36
|
-
|
|
37
23
|
i18n: {
|
|
38
24
|
defaultLocale: 'en',
|
|
39
|
-
locales: [
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
locales: [
|
|
26
|
+
{ code: 'en', file: 'en.json' },
|
|
27
|
+
{ code: 'fr', file: 'fr.json' },
|
|
28
|
+
],
|
|
29
|
+
langDir: 'i18n/locales/',
|
|
30
|
+
|
|
31
|
+
// i18now sync — add this block to enable automatic key collection in dev
|
|
32
|
+
i18now: {
|
|
33
|
+
projectId: process.env.I18NOW_PROJECT_ID,
|
|
34
|
+
apiKey: process.env.I18NOW_API_KEY,
|
|
42
35
|
},
|
|
43
36
|
},
|
|
44
37
|
})
|
|
45
38
|
```
|
|
46
39
|
|
|
47
|
-
|
|
40
|
+
When `i18now` is configured, any `$t('key', 'Default text')` call where the key is missing from your locale files will be automatically collected and sent to i18now during development. The `apiKey` is kept server-side and never exposed to the browser.
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|---------------|------------|----------------------------|-----------------------------------------------------------------------------|
|
|
51
|
-
| `projectId` | `string` | — | **Required.** Your i18now project ID. |
|
|
52
|
-
| `apiKey` | `string` | — | **Required.** Your i18now API key. Never sent to the browser. |
|
|
53
|
-
| `host` | `string` | `https://i18now.com` | i18now server URL. Set to `http://localhost:3220` for local development. |
|
|
54
|
-
| `cdnUrl` | `string` | `https://cdn.i18now.com` | CDN base URL where published translations are served. |
|
|
55
|
-
| `environment` | `string` | `'dev'` | Which published environment to load translations from (`dev`, `stage`, `prod`). |
|
|
56
|
-
| `syncIn` | `string[]` | `['development']` | Node environments where missing-key sync is active. Keep as `['development']`. |
|
|
57
|
-
| `locale` | `string` | `'en'` | Fallback locale used before `@nuxtjs/i18n` initialises. |
|
|
58
|
-
|
|
59
|
-
### Environment variables
|
|
60
|
-
|
|
61
|
-
Store secrets in `.env`:
|
|
62
|
-
|
|
63
|
-
```env
|
|
64
|
-
I18NOW_PROJECT_ID=your-project-id
|
|
65
|
-
I18NOW_API_KEY=your-api-key
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## How it works
|
|
69
|
-
|
|
70
|
-
### Production
|
|
71
|
-
|
|
72
|
-
The server plugin fetches the published translation JSON from the CDN (`{cdnUrl}/{projectId}/publish/{environment}/{locale}.json`) during SSR and injects it into vue-i18n. Translations are refreshed on locale switch.
|
|
73
|
-
|
|
74
|
-
### Development
|
|
75
|
-
|
|
76
|
-
The client plugin intercepts every `$t()` and `useI18n().t()` call. When a key is missing from the CDN snapshot it batches that key (with its default value) and POSTs it to a local Nuxt server route (`/api/_i18now/sync`). The server route adds the API key and forwards the request to i18now — so your API key never appears in browser network requests.
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
Browser $t('key', 'Default text')
|
|
80
|
-
→ client plugin detects missing key
|
|
81
|
-
→ POST /api/_i18now/sync { keys: [{ key, value }] }
|
|
82
|
-
→ Nuxt server adds apiKey
|
|
83
|
-
→ POST i18now /api/v1/projects/:id/sync
|
|
84
|
-
```
|
|
42
|
+
## Documentation
|
|
85
43
|
|
|
86
|
-
|
|
44
|
+
For all i18n configuration options, refer to the official [@nuxtjs/i18n docs](https://i18n.nuxtjs.org/).
|
|
87
45
|
|
|
88
|
-
|
|
46
|
+
## License
|
|
89
47
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
- `apiKey` is stored in Nuxt's private (server-only) `runtimeConfig` — it is never serialised into the client bundle or sent in any browser request.
|
|
93
|
-
- The `syncIn` option defaults to `['development']`. **Never add `'production'` or `'staging'`** — doing so would expose your API key to end users and flood your project with traffic.
|
|
94
|
-
|
|
95
|
-
## Local development against a local i18now server
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
// nuxt.config.ts
|
|
99
|
-
i18now: {
|
|
100
|
-
projectId: 'your-project-id',
|
|
101
|
-
apiKey: 'your-api-key',
|
|
102
|
-
host: 'http://localhost:3220',
|
|
103
|
-
cdnUrl: 'http://localhost:3220', // if serving snapshots locally
|
|
104
|
-
environment: 'dev',
|
|
105
|
-
},
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Playground
|
|
109
|
-
|
|
110
|
-
A minimal playground is included in `playground/`. To run it:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
pnpm dev:playground
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Building locally
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
pnpm build
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
To use the built package in another local project, add a `file:` reference:
|
|
123
|
-
|
|
124
|
-
```json
|
|
125
|
-
{
|
|
126
|
-
"dependencies": {
|
|
127
|
-
"@uipkge/nuxt": "file:../path/to/i18now/packages/nuxt"
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
```
|
|
48
|
+
[MIT](./LICENSE) — based on @nuxtjs/i18n, Copyright (c) Nuxt Community
|