@intlayer/nuxtjs-i18n 9.5.10
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 +329 -0
- package/dist/esm/constants.mjs +15 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/module.mjs +75 -0
- package/dist/esm/module.mjs.map +1 -0
- package/dist/esm/runtime/NuxtLinkLocale.mjs +42 -0
- package/dist/esm/runtime/NuxtLinkLocale.mjs.map +1 -0
- package/dist/esm/runtime/composer.mjs +71 -0
- package/dist/esm/runtime/composer.mjs.map +1 -0
- package/dist/esm/runtime/define.mjs +23 -0
- package/dist/esm/runtime/define.mjs.map +1 -0
- package/dist/esm/runtime/index.mjs +7 -0
- package/dist/esm/runtime/nuxtPlugin.mjs +32 -0
- package/dist/esm/runtime/nuxtPlugin.mjs.map +1 -0
- package/dist/esm/runtime/nuxtVirtualModules.d.mjs +0 -0
- package/dist/esm/runtime/routing.mjs +143 -0
- package/dist/esm/runtime/routing.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/types/constants.d.ts +13 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/module.d.ts +28 -0
- package/dist/types/module.d.ts.map +1 -0
- package/dist/types/runtime/NuxtLinkLocale.d.ts +42 -0
- package/dist/types/runtime/NuxtLinkLocale.d.ts.map +1 -0
- package/dist/types/runtime/composer.d.ts +66 -0
- package/dist/types/runtime/composer.d.ts.map +1 -0
- package/dist/types/runtime/define.d.ts +23 -0
- package/dist/types/runtime/define.d.ts.map +1 -0
- package/dist/types/runtime/index.d.ts +6 -0
- package/dist/types/runtime/nuxtPlugin.d.ts +12 -0
- package/dist/types/runtime/nuxtPlugin.d.ts.map +1 -0
- package/dist/types/runtime/nuxtVirtualModules.d.ts +8 -0
- package/dist/types/runtime/nuxtVirtualModules.d.ts.map +1 -0
- package/dist/types/runtime/routing.d.ts +47 -0
- package/dist/types/runtime/routing.d.ts.map +1 -0
- package/dist/types/types.d.ts +82 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +109 -0
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://intlayer.org" rel="">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.webp" width="60%" alt="Intlayer Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">
|
|
8
|
+
<strong>Per-component i18n</strong>
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<h2 align="center">
|
|
12
|
+
<strong>AI-powered translation. Visual Editor. Multilingual CMS.</strong>
|
|
13
|
+
</h2>
|
|
14
|
+
|
|
15
|
+
<br />
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">Docs</a> •
|
|
19
|
+
<a href="https://intlayer.org/doc/environment/nextjs" rel="">Next.js</a> •
|
|
20
|
+
<a href="https://intlayer.org/doc/environment/vite-and-react" rel="">React + Vite</a> •
|
|
21
|
+
<a href="https://intlayer.org/doc/concept/cms" rel="">CMS</a> •
|
|
22
|
+
<a href="https://discord.gg/7uxamYVeCk" rel="noopener noreferrer nofollow">Discord</a>
|
|
23
|
+
</p>
|
|
24
|
+
<p align="center" style="margin-top:15px;">
|
|
25
|
+
<a href="https://www.npmjs.com/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/intlayer?style=for-the-badge&labelColor=FFFFFF&color=000000&logoColor=FFFFFF" alt="npm version" height="24"/></a>
|
|
26
|
+
<a href="https://github.com/aymericzip/intlayer/stargazers" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/stars/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logo=github&logoColor=FFD700" alt="GitHub Stars" height="24"/></a>
|
|
27
|
+
<a href="https://www.npmjs.org/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="monthly downloads" height="24"/></a>
|
|
28
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/LICENSE" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/license/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="license"/></a>
|
|
29
|
+
<a href="https://github.com/aymericzip/intlayer/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/last-commit/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="last commit"/>
|
|
30
|
+
</a>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
36
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
37
|
+
</a>
|
|
38
|
+
|
|
39
|
+
## What is Intlayer?
|
|
40
|
+
|
|
41
|
+
Most i18n libraries are either too complex, too rigid, or not built for modern frameworks.
|
|
42
|
+
|
|
43
|
+
Intlayer is a **modern i18n solution** for web and mobile apps.
|
|
44
|
+
It’s framework-agnostic, **AI-powered**, and includes a free **CMS & visual editor**.
|
|
45
|
+
|
|
46
|
+
With **per-locale content files**, **TypeScript autocompletion**, **tree-shakable dictionaries**, and **CI/CD integration**, Intlayer makes internationalization **faster, cleaner, and smarter**.
|
|
47
|
+
|
|
48
|
+
## Keys benefits of Intlayer:
|
|
49
|
+
|
|
50
|
+
| Feature | Description |
|
|
51
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.webp?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
54
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.webp?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
|
|
56
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
57
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
58
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
59
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
|
|
60
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
61
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
62
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.webp?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.webp?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
65
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.webp?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
66
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
67
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
68
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.webp?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
69
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
|
+
|
|
72
|
+
## 📦 Installation
|
|
73
|
+
|
|
74
|
+
Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
|
|
75
|
+
|
|
76
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
77
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
78
|
+
</a>
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install intlayer react-intlayer
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
⚡ Quick Start (Next.js)
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// intlayer.config.ts
|
|
88
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
89
|
+
|
|
90
|
+
const config: IntlayerConfig = {
|
|
91
|
+
internationalization: {
|
|
92
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
93
|
+
defaultLocale: Locales.ENGLISH,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default config;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// app/home.content.ts
|
|
102
|
+
import { t, type Dictionary } from "intlayer";
|
|
103
|
+
|
|
104
|
+
const content = {
|
|
105
|
+
key: "home",
|
|
106
|
+
content: {
|
|
107
|
+
title: t({
|
|
108
|
+
en: "Home",
|
|
109
|
+
fr: "Accueil",
|
|
110
|
+
es: "Inicio",
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
} satisfies Dictionary;
|
|
114
|
+
|
|
115
|
+
export default content;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
// app/page.tsx
|
|
120
|
+
import { useIntlayer } from "react-intlayer";
|
|
121
|
+
|
|
122
|
+
const HomePage = () => {
|
|
123
|
+
const { title } = useIntlayer("home");
|
|
124
|
+
|
|
125
|
+
return <h1>{title}</h1>;
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
<a href="https://intlayer.org/doc/environment/nextjs"> Get the full guide → </a>
|
|
130
|
+
|
|
131
|
+
## 🎥 Live tutorial on YouTube
|
|
132
|
+
|
|
133
|
+
[](https://youtu.be/e_PPG7PTqGU?si=GyU_KpVhr61razRw)
|
|
134
|
+
|
|
135
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
136
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
137
|
+
</a>
|
|
138
|
+
|
|
139
|
+
## Table of Contents
|
|
140
|
+
|
|
141
|
+
Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
|
|
142
|
+
|
|
143
|
+
<details open>
|
|
144
|
+
<summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
|
|
145
|
+
<ul>
|
|
146
|
+
<li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
|
|
147
|
+
<li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
|
|
148
|
+
</ul>
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
|
|
153
|
+
<ul>
|
|
154
|
+
<li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
|
|
155
|
+
<li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
|
|
156
|
+
<li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
|
|
157
|
+
<li><a href="https://intlayer.org/doc/compiler" rel=''>Compiler</a></li>
|
|
158
|
+
|
|
159
|
+
<li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
|
|
160
|
+
<li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
|
|
161
|
+
<li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
|
|
162
|
+
<ul>
|
|
163
|
+
<li><a href="https://intlayer.org/doc/concept/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
|
|
164
|
+
<li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
|
|
165
|
+
<li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
|
|
166
|
+
<li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
|
|
167
|
+
<li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
|
|
168
|
+
<li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
|
|
169
|
+
<li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
|
|
170
|
+
<li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
|
|
171
|
+
<li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
|
|
172
|
+
</ul>
|
|
173
|
+
</li>
|
|
174
|
+
</ul>
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<details open>
|
|
178
|
+
<summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
|
|
179
|
+
<ul>
|
|
180
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 16</a>
|
|
181
|
+
<ul>
|
|
182
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
|
|
183
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
|
|
184
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/next-with-page-router" rel=''>Next.js Page Router</a></li>
|
|
185
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
|
|
186
|
+
</ul>
|
|
187
|
+
</li>
|
|
188
|
+
<li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
|
|
189
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a></li>
|
|
190
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React using Compiler</a></li>
|
|
191
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
|
|
192
|
+
<li><a href="https://intlayer.org/doc/environment/remix-3" rel=''>Remix 3</a></li>
|
|
193
|
+
<li><a href="https://intlayer.org/doc/environment/tanstack-start" rel=''>Tanstack start</a>
|
|
194
|
+
<ul>
|
|
195
|
+
<li><a href="https://intlayer.org/doc/environment/tanstack-start/solid" rel=''>Solid</a></li>
|
|
196
|
+
</ul>
|
|
197
|
+
</li>
|
|
198
|
+
<li><a href="https://intlayer.org/doc/environment/astro" rel=''>Astro</a>
|
|
199
|
+
<ul>
|
|
200
|
+
<li><a href="https://intlayer.org/doc/environment/astro/react" rel=''>React</a></li>
|
|
201
|
+
<li><a href="https://intlayer.org/doc/environment/astro/vue" rel=''>Vue</a></li>
|
|
202
|
+
<li><a href="https://intlayer.org/doc/environment/astro/svelte" rel=''>Svelte</a></li>
|
|
203
|
+
<li><a href="https://intlayer.org/doc/environment/astro/solid" rel=''>Solid</a></li>
|
|
204
|
+
<li><a href="https://intlayer.org/doc/environment/astro/lit" rel=''>Lit</a></li>
|
|
205
|
+
</ul>
|
|
206
|
+
</li>
|
|
207
|
+
|
|
208
|
+
<li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
|
|
209
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
|
|
210
|
+
<li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
|
|
211
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
|
|
212
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
213
|
+
<li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
|
|
214
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
|
|
215
|
+
<li><a href="https://intlayer.org/doc/environment/solid-start" rel=''>Solid Start</a></li>
|
|
216
|
+
<li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li> <li>
|
|
217
|
+
<a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
|
|
218
|
+
<ul>
|
|
219
|
+
<li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
|
|
220
|
+
<li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
|
|
221
|
+
<li><a href="https://intlayer.org/doc/environment/fastify" rel=''>Fastify</a></li>
|
|
222
|
+
<li><a href="https://intlayer.org/doc/environment/adonisjs" rel=''>AdonisJS</a></li>
|
|
223
|
+
<li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
|
|
224
|
+
<li><a href="https://intlayer.org/doc/environment/elysia" rel=''>Elysia</a></li>
|
|
225
|
+
</ul>
|
|
226
|
+
</li>
|
|
227
|
+
</ul>
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary style="font-size:16px; font-weight:bold;">📊 Benchmark</summary>
|
|
232
|
+
<ul>
|
|
233
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/nextjs.md" rel=''>Next.js</a></li>
|
|
234
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/tanstack.md" rel=''>TanStack Start</a></li>
|
|
235
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md" rel=''>Vue</a></li>
|
|
236
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/solid.md" rel=''>Solid</a></li>
|
|
237
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/svelte.md" rel=''>Svelte</a></li>
|
|
238
|
+
</ul>
|
|
239
|
+
</details>
|
|
240
|
+
|
|
241
|
+
<details>
|
|
242
|
+
<summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
|
|
243
|
+
<ul>
|
|
244
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
|
|
245
|
+
<li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
|
|
246
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
|
|
247
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
|
|
248
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
|
|
249
|
+
</ul>
|
|
250
|
+
</details>
|
|
251
|
+
|
|
252
|
+
## Multilingual content management system
|
|
253
|
+
|
|
254
|
+
More than an i18n library, Intlayer is a complete **multilingual content management system**. A full CMS is available for free at [app.intlayer.org](https://app.intlayer.org).
|
|
255
|
+
|
|
256
|
+
Intlayer connects **developers**, **copywriters**, and **AI agents** in one workflow for creating and maintaining multilingual websites effortlessly.Intlayer replaces the following stack in a single solution:
|
|
257
|
+
|
|
258
|
+
- i18n solutions (e.g. `i18next`, `next-intl`, `vue-i18n`)
|
|
259
|
+
- TMSs (Translation Management Systems) (e.g. Crowdin, Phrase, Lokalise)
|
|
260
|
+
- Feature flags
|
|
261
|
+
- Headless CMSs (e.g. Contentful, Strapi, Sanity)
|
|
262
|
+
|
|
263
|
+

|
|
264
|
+
|
|
265
|
+
## 🌐 Readme in other languages
|
|
266
|
+
|
|
267
|
+
<p align="center">
|
|
268
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/readme.md">English</a> •
|
|
269
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/readme.md">简体中文</a> •
|
|
270
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/readme.md">Русский</a> •
|
|
271
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/readme.md">日本語</a> •
|
|
272
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/readme.md">Français</a> •
|
|
273
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/readme.md">한국어</a> •
|
|
274
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/readme.md">Español</a> •
|
|
275
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/readme.md">Deutsch</a> •
|
|
276
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/readme.md">العربية</a> •
|
|
277
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/readme.md">Italiano</a> •
|
|
278
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/readme.md">English (UK)</a> •
|
|
279
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/readme.md">Português</a> •
|
|
280
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/readme.md">हिन्दी</a> •
|
|
281
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/readme.md">Türkçe</a>
|
|
282
|
+
</p>
|
|
283
|
+
|
|
284
|
+
## 🤝 Community
|
|
285
|
+
|
|
286
|
+
Intlayer is built with and for the community and we’d love your input!
|
|
287
|
+
|
|
288
|
+
- Have a suggestion? [Open an issue](https://github.com/aymericzip/intlayer/issues)
|
|
289
|
+
- Found a bug or improvement? [Submit a PR](https://github.com/aymericzip/intlayer/pulls)
|
|
290
|
+
- Need help or want to connect? [Join our Discord](https://discord.gg/7uxamYVeCk)
|
|
291
|
+
|
|
292
|
+
You can also follow us on :
|
|
293
|
+
|
|
294
|
+
<div>
|
|
295
|
+
<br/>
|
|
296
|
+
<p align="center">
|
|
297
|
+
<a href="https://discord.gg/528mBV4N" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
298
|
+
src="https://img.shields.io/badge/discord-5865F2.svg?style=for-the-badge&logo=discord&logoColor=white"
|
|
299
|
+
alt="Intlayer Discord" height="30"/></a>
|
|
300
|
+
<a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
301
|
+
src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
|
|
302
|
+
alt="Intlayer LinkedIn" height="30"/></a>
|
|
303
|
+
<a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
304
|
+
src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
|
|
305
|
+
alt="Intlayer Instagram" height="30"/></a>
|
|
306
|
+
<a href="https://x.com/Intlayer183096" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
307
|
+
src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
|
|
308
|
+
alt="Intlayer X" height="30"/></a>
|
|
309
|
+
<a href="https://www.youtube.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
310
|
+
src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
|
|
311
|
+
alt="Intlayer YouTube" height="30"/></a>
|
|
312
|
+
<a href="https://www.tiktok.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
313
|
+
src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
|
|
314
|
+
alt="Intlayer TikTok" height="30"/></a>
|
|
315
|
+
<br>
|
|
316
|
+
</p>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
### Contribution
|
|
320
|
+
|
|
321
|
+
For more detailed guidelines on contributing to this project, please refer to the [`CONTRIBUTING.md`](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md) file. It contains essential information on our development process, commit message conventions, and release procedures. Your contributions are valuable to us, and we appreciate your efforts in making this project better!
|
|
322
|
+
|
|
323
|
+
Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https://gitlab.com/ay.pineau/intlayer), or [Bitbucket](https://bitbucket.org/intlayer/intlayer/).
|
|
324
|
+
|
|
325
|
+
### Thank You for the Support
|
|
326
|
+
|
|
327
|
+
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
328
|
+
|
|
329
|
+
[](https://star-history.com/#aymericzip/intlayer&Date)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
const STRATEGY_PREFIX = "prefix";
|
|
3
|
+
const STRATEGY_PREFIX_EXCEPT_DEFAULT = "prefix_except_default";
|
|
4
|
+
const STRATEGY_PREFIX_AND_DEFAULT = "prefix_and_default";
|
|
5
|
+
const STRATEGY_NO_PREFIX = "no_prefix";
|
|
6
|
+
const STRATEGIES = {
|
|
7
|
+
PREFIX: "prefix",
|
|
8
|
+
PREFIX_EXCEPT_DEFAULT: "prefix_except_default",
|
|
9
|
+
PREFIX_AND_DEFAULT: "prefix_and_default",
|
|
10
|
+
NO_PREFIX: "no_prefix"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT };
|
|
15
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/constants.ts"],"sourcesContent":["export const STRATEGY_PREFIX = 'prefix';\nexport const STRATEGY_PREFIX_EXCEPT_DEFAULT = 'prefix_except_default';\nexport const STRATEGY_PREFIX_AND_DEFAULT = 'prefix_and_default';\nexport const STRATEGY_NO_PREFIX = 'no_prefix';\n\nexport const STRATEGIES = {\n PREFIX: 'prefix',\n PREFIX_EXCEPT_DEFAULT: 'prefix_except_default',\n PREFIX_AND_DEFAULT: 'prefix_and_default',\n NO_PREFIX: 'no_prefix',\n} as const;\n"],"mappings":";AAAA,MAAa,kBAAkB;AAC/B,MAAa,iCAAiC;AAC9C,MAAa,8BAA8B;AAC3C,MAAa,qBAAqB;AAElC,MAAa,aAAa;CACxB,QAAQ;CACR,uBAAuB;CACvB,oBAAoB;CACpB,WAAW;AACb"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import nuxtjsI18nModule from "./module.mjs";
|
|
2
|
+
import { STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT } from "./constants.mjs";
|
|
3
|
+
|
|
4
|
+
export { STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT, nuxtjsI18nModule as default, nuxtjsI18nModule };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { NUXTJS_I18N_CALLERS } from "@intlayer/config/callers";
|
|
2
|
+
import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule, installModule } from "@nuxt/kit";
|
|
3
|
+
import nuxtIntlayerModule from "nuxt-intlayer";
|
|
4
|
+
|
|
5
|
+
//#region src/module.ts
|
|
6
|
+
/** Specifier of the client runtime, as auto-imports and the registry see it. */
|
|
7
|
+
const RUNTIME_MODULE = "@intlayer/nuxtjs-i18n/runtime";
|
|
8
|
+
/** Composables and helpers @nuxtjs/i18n auto-imports. */
|
|
9
|
+
const AUTO_IMPORTS = [
|
|
10
|
+
"useI18n",
|
|
11
|
+
"useDictionary",
|
|
12
|
+
"useDictionaryDynamic",
|
|
13
|
+
"useLocalePath",
|
|
14
|
+
"useSwitchLocalePath",
|
|
15
|
+
"useLocaleRoute",
|
|
16
|
+
"useRouteBaseName",
|
|
17
|
+
"useLocaleHead",
|
|
18
|
+
"useBrowserLocale",
|
|
19
|
+
"useCookieLocale",
|
|
20
|
+
"useSetI18nParams",
|
|
21
|
+
"useI18nPreloadKeys",
|
|
22
|
+
"defineI18nRoute",
|
|
23
|
+
"defineI18nConfig",
|
|
24
|
+
"defineI18nLocale",
|
|
25
|
+
"defineI18nLocaleDetector"
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Nuxt module replacing `@nuxtjs/i18n` with intlayer.
|
|
29
|
+
*
|
|
30
|
+
* - installs `nuxt-intlayer` (dictionaries, locale routing, Vite plugin) with
|
|
31
|
+
* the `useI18n` caller, so `useI18n({ namespace })` call sites are
|
|
32
|
+
* rewritten to import only their dictionary;
|
|
33
|
+
* - aliases `#i18n` and auto-imports the @nuxtjs/i18n composables;
|
|
34
|
+
* - registers `<NuxtLinkLocale>` and the plugin providing `$t`,
|
|
35
|
+
* `$localePath`, `$switchLocalePath`…
|
|
36
|
+
*
|
|
37
|
+
* Locales, default locale and routing come from `intlayer.config.ts`; the
|
|
38
|
+
* `i18n` key of `nuxt.config` is accepted for migration and ignored.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // nuxt.config.ts
|
|
43
|
+
* export default defineNuxtConfig({
|
|
44
|
+
* modules: ['@intlayer/nuxtjs-i18n'],
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
const nuxtjsI18nModule = defineNuxtModule({
|
|
49
|
+
meta: {
|
|
50
|
+
name: "@intlayer/nuxtjs-i18n",
|
|
51
|
+
configKey: "i18n"
|
|
52
|
+
},
|
|
53
|
+
setup: async (_options, nuxt) => {
|
|
54
|
+
const resolver = createResolver(import.meta.url);
|
|
55
|
+
await installModule(nuxtIntlayerModule, { compatCallers: NUXTJS_I18N_CALLERS });
|
|
56
|
+
nuxt.options.alias["#i18n"] = RUNTIME_MODULE;
|
|
57
|
+
addImports(AUTO_IMPORTS.map((name) => ({
|
|
58
|
+
name,
|
|
59
|
+
from: RUNTIME_MODULE
|
|
60
|
+
})));
|
|
61
|
+
addComponent({
|
|
62
|
+
name: "NuxtLinkLocale",
|
|
63
|
+
export: "NuxtLinkLocale",
|
|
64
|
+
filePath: RUNTIME_MODULE
|
|
65
|
+
});
|
|
66
|
+
addPlugin({
|
|
67
|
+
src: resolver.resolve("./runtime/nuxtPlugin"),
|
|
68
|
+
mode: "all"
|
|
69
|
+
}, { append: true });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
export { nuxtjsI18nModule as default, nuxtjsI18nModule };
|
|
75
|
+
//# sourceMappingURL=module.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.mjs","names":[],"sources":["../../src/module.ts"],"sourcesContent":["import { NUXTJS_I18N_CALLERS } from '@intlayer/config/callers';\nimport {\n addComponent,\n addImports,\n addPlugin,\n createResolver,\n defineNuxtModule,\n installModule,\n} from '@nuxt/kit';\nimport type { NuxtModule } from '@nuxt/schema';\nimport nuxtIntlayerModule from 'nuxt-intlayer';\nimport type { NuxtI18nOptions } from './types';\n\n/** Specifier of the client runtime, as auto-imports and the registry see it. */\nconst RUNTIME_MODULE = '@intlayer/nuxtjs-i18n/runtime';\n\n/** Composables and helpers @nuxtjs/i18n auto-imports. */\nconst AUTO_IMPORTS = [\n 'useI18n',\n 'useDictionary',\n 'useDictionaryDynamic',\n 'useLocalePath',\n 'useSwitchLocalePath',\n 'useLocaleRoute',\n 'useRouteBaseName',\n 'useLocaleHead',\n 'useBrowserLocale',\n 'useCookieLocale',\n 'useSetI18nParams',\n 'useI18nPreloadKeys',\n 'defineI18nRoute',\n 'defineI18nConfig',\n 'defineI18nLocale',\n 'defineI18nLocaleDetector',\n];\n\n/**\n * Nuxt module replacing `@nuxtjs/i18n` with intlayer.\n *\n * - installs `nuxt-intlayer` (dictionaries, locale routing, Vite plugin) with\n * the `useI18n` caller, so `useI18n({ namespace })` call sites are\n * rewritten to import only their dictionary;\n * - aliases `#i18n` and auto-imports the @nuxtjs/i18n composables;\n * - registers `<NuxtLinkLocale>` and the plugin providing `$t`,\n * `$localePath`, `$switchLocalePath`…\n *\n * Locales, default locale and routing come from `intlayer.config.ts`; the\n * `i18n` key of `nuxt.config` is accepted for migration and ignored.\n *\n * @example\n * ```ts\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: ['@intlayer/nuxtjs-i18n'],\n * });\n * ```\n */\nexport const nuxtjsI18nModule: NuxtModule<NuxtI18nOptions> =\n defineNuxtModule<NuxtI18nOptions>({\n meta: {\n name: '@intlayer/nuxtjs-i18n',\n configKey: 'i18n',\n },\n setup: async (_options, nuxt) => {\n const resolver = createResolver(import.meta.url);\n\n await installModule(nuxtIntlayerModule, {\n compatCallers: NUXTJS_I18N_CALLERS,\n });\n\n nuxt.options.alias['#i18n'] = RUNTIME_MODULE;\n\n addImports(AUTO_IMPORTS.map((name) => ({ name, from: RUNTIME_MODULE })));\n\n addComponent({\n name: 'NuxtLinkLocale',\n export: 'NuxtLinkLocale',\n filePath: RUNTIME_MODULE,\n });\n\n // Appended: it must run after nuxt-intlayer's plugin, which installs\n // the intlayer client (`addPlugin` prepends by default).\n addPlugin(\n {\n src: resolver.resolve('./runtime/nuxtPlugin'),\n mode: 'all',\n },\n { append: true }\n );\n },\n });\n\nexport default nuxtjsI18nModule;\n"],"mappings":";;;;;;AAcA,MAAM,iBAAiB;;AAGvB,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,mBACX,iBAAkC;CAChC,MAAM;EACJ,MAAM;EACN,WAAW;CACb;CACA,OAAO,OAAO,UAAU,SAAS;EAC/B,MAAM,WAAW,eAAe,YAAY,GAAG;EAE/C,MAAM,cAAc,oBAAoB,EACtC,eAAe,oBACjB,CAAC;EAED,KAAK,QAAQ,MAAM,WAAW;EAE9B,WAAW,aAAa,KAAK,UAAU;GAAE;GAAM,MAAM;EAAe,EAAE,CAAC;EAEvE,aAAa;GACX,MAAM;GACN,QAAQ;GACR,UAAU;EACZ,CAAC;EAID,UACE;GACE,KAAK,SAAS,QAAQ,sBAAsB;GAC5C,MAAM;EACR,GACA,EAAE,QAAQ,KAAK,CACjB;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useLocalePath } from "./routing.mjs";
|
|
2
|
+
import { defineComponent, h } from "vue";
|
|
3
|
+
import { NuxtLink } from "#components";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/NuxtLinkLocale.ts
|
|
6
|
+
/**
|
|
7
|
+
* `<NuxtLinkLocale to="/about" locale="fr">` — a `<NuxtLink>` whose target
|
|
8
|
+
* is localized for the active (or given) locale.
|
|
9
|
+
*/
|
|
10
|
+
const NuxtLinkLocale = defineComponent({
|
|
11
|
+
name: "NuxtLinkLocale",
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
props: {
|
|
14
|
+
to: {
|
|
15
|
+
type: [String, Object],
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
href: {
|
|
19
|
+
type: [String, Object],
|
|
20
|
+
default: void 0
|
|
21
|
+
},
|
|
22
|
+
locale: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: void 0
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
setup(props, { slots, attrs }) {
|
|
28
|
+
const localePath = useLocalePath();
|
|
29
|
+
return () => {
|
|
30
|
+
const target = props.to ?? props.href ?? "/";
|
|
31
|
+
const localizedTarget = typeof target === "string" && /^[a-z][a-z\d+\-.]*:/i.test(target) ? target : localePath(target, props.locale);
|
|
32
|
+
return h(NuxtLink, {
|
|
33
|
+
...attrs,
|
|
34
|
+
to: localizedTarget
|
|
35
|
+
}, slots.default);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { NuxtLinkLocale };
|
|
42
|
+
//# sourceMappingURL=NuxtLinkLocale.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NuxtLinkLocale.mjs","names":[],"sources":["../../../src/runtime/NuxtLinkLocale.ts"],"sourcesContent":["import { defineComponent, h, type PropType } from 'vue';\nimport { NuxtLink } from '#components';\nimport type { RouteLocationGeneric } from '../types';\nimport { useLocalePath } from './routing';\n\n/**\n * `<NuxtLinkLocale to=\"/about\" locale=\"fr\">` — a `<NuxtLink>` whose target\n * is localized for the active (or given) locale.\n */\nexport const NuxtLinkLocale = defineComponent({\n name: 'NuxtLinkLocale',\n inheritAttrs: false,\n props: {\n to: {\n type: [String, Object] as PropType<RouteLocationGeneric>,\n default: undefined,\n },\n href: {\n type: [String, Object] as PropType<RouteLocationGeneric>,\n default: undefined,\n },\n locale: {\n type: String,\n default: undefined,\n },\n },\n setup(props, { slots, attrs }) {\n const localePath = useLocalePath();\n\n return () => {\n const target = props.to ?? props.href ?? '/';\n const isExternal =\n typeof target === 'string' && /^[a-z][a-z\\d+\\-.]*:/i.test(target);\n const localizedTarget = isExternal\n ? target\n : localePath(target, props.locale);\n\n return h(NuxtLink, { ...attrs, to: localizedTarget }, slots.default);\n };\n },\n});\n"],"mappings":";;;;;;;;;AASA,MAAa,iBAAiB,gBAAgB;CAC5C,MAAM;CACN,cAAc;CACd,OAAO;EACL,IAAI;GACF,MAAM,CAAC,QAAQ,MAAM;GACrB,SAAS;EACX;EACA,MAAM;GACJ,MAAM,CAAC,QAAQ,MAAM;GACrB,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,SAAS;EACX;CACF;CACA,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,aAAa,cAAc;EAEjC,aAAa;GACX,MAAM,SAAS,MAAM,MAAM,MAAM,QAAQ;GAGzC,MAAM,kBADJ,OAAO,WAAW,YAAY,uBAAuB,KAAK,MAAM,IAE9D,SACA,WAAW,QAAQ,MAAM,MAAM;GAEnC,OAAO,EAAE,UAAU;IAAE,GAAG;IAAO,IAAI;GAAgB,GAAG,MAAM,OAAO;EACrE;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defaultLocale, detectBrowserLocale, getActiveLocale, getCurrentFullPath, getRouter, localeCodes, localizeFullPath, strategy } from "./routing.mjs";
|
|
2
|
+
import { getHTMLTextDir, getLocaleName } from "@intlayer/core/localization";
|
|
3
|
+
import { getCachedLocaleFromStorageClient, localeStorageOptions, setLocaleInStorageClient } from "@intlayer/core/utils";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
import { createIntlayerClient } from "vue-intlayer";
|
|
6
|
+
import { useDictionary as useDictionary$1, useDictionaryDynamic as useDictionaryDynamic$1, useI18n as useI18n$1 } from "@intlayer/vue-i18n";
|
|
7
|
+
|
|
8
|
+
//#region src/runtime/composer.ts
|
|
9
|
+
/** The @nuxtjs/i18n locale object describing a locale code. */
|
|
10
|
+
const toLocaleObject = (code) => ({
|
|
11
|
+
code,
|
|
12
|
+
language: code,
|
|
13
|
+
name: getLocaleName(code, code),
|
|
14
|
+
dir: getHTMLTextDir(code)
|
|
15
|
+
});
|
|
16
|
+
const localeObjects = localeCodes.map(toLocaleObject);
|
|
17
|
+
const resolveNothing = () => Promise.resolve();
|
|
18
|
+
/**
|
|
19
|
+
* Builds the Nuxt extras. Must run in a component setup, where the router is
|
|
20
|
+
* reachable for `setLocale` navigation.
|
|
21
|
+
*/
|
|
22
|
+
const createComposerExtras = () => {
|
|
23
|
+
const router = getRouter();
|
|
24
|
+
const intlayerClient = createIntlayerClient();
|
|
25
|
+
const setLocaleCookie = (locale) => setLocaleInStorageClient(locale, localeStorageOptions);
|
|
26
|
+
return {
|
|
27
|
+
locales: computed(() => localeObjects),
|
|
28
|
+
localeCodes: computed(() => localeCodes),
|
|
29
|
+
localeProperties: computed(() => toLocaleObject(getActiveLocale())),
|
|
30
|
+
defaultLocale,
|
|
31
|
+
strategy,
|
|
32
|
+
setLocale: async (locale) => {
|
|
33
|
+
if (!localeCodes.includes(locale)) return;
|
|
34
|
+
intlayerClient.setLocale(locale);
|
|
35
|
+
setLocaleCookie(locale);
|
|
36
|
+
if (!router || strategy === "no_prefix") return;
|
|
37
|
+
await router.push(localizeFullPath(getCurrentFullPath(router), locale));
|
|
38
|
+
},
|
|
39
|
+
getBrowserLocale: detectBrowserLocale,
|
|
40
|
+
getLocaleCookie: () => getCachedLocaleFromStorageClient(),
|
|
41
|
+
setLocaleCookie,
|
|
42
|
+
finalizePendingLocaleChange: resolveNothing,
|
|
43
|
+
waitForPendingLocaleChange: resolveNothing,
|
|
44
|
+
loadLocaleMessages: resolveNothing
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* `useI18n()` of @nuxtjs/i18n: vue-i18n's composer (backed by intlayer
|
|
49
|
+
* dictionaries) plus the Nuxt locale helpers.
|
|
50
|
+
*/
|
|
51
|
+
const useI18n = ((options) => ({
|
|
52
|
+
...useI18n$1(options),
|
|
53
|
+
...createComposerExtras()
|
|
54
|
+
}));
|
|
55
|
+
/**
|
|
56
|
+
* Build-optimized `useI18n({ namespace })`: the optimize pass rewrites the
|
|
57
|
+
* call to pass the dictionary, so only it reaches the bundle.
|
|
58
|
+
*/
|
|
59
|
+
const useDictionary = ((dictionary, options) => ({
|
|
60
|
+
...useDictionary$1(dictionary, options),
|
|
61
|
+
...createComposerExtras()
|
|
62
|
+
}));
|
|
63
|
+
/** Per-locale lazy variant of {@link useDictionary}. */
|
|
64
|
+
const useDictionaryDynamic = ((dictionaryLoaders, key, options) => ({
|
|
65
|
+
...useDictionaryDynamic$1(dictionaryLoaders, key, options),
|
|
66
|
+
...createComposerExtras()
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { toLocaleObject, useDictionary, useDictionaryDynamic, useI18n };
|
|
71
|
+
//# sourceMappingURL=composer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.mjs","names":["useI18nBase","useDictionaryBase","useDictionaryDynamicBase"],"sources":["../../../src/runtime/composer.ts"],"sourcesContent":["import { getHTMLTextDir, getLocaleName } from '@intlayer/core/localization';\nimport {\n getCachedLocaleFromStorageClient,\n localeStorageOptions,\n setLocaleInStorageClient,\n} from '@intlayer/core/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport {\n type LooseComposer,\n type ScopedComposer,\n type TypedComposer,\n useDictionary as useDictionaryBase,\n useDictionaryDynamic as useDictionaryDynamicBase,\n useI18n as useI18nBase,\n} from '@intlayer/vue-i18n';\nimport { type ComputedRef, computed } from 'vue';\nimport { createIntlayerClient } from 'vue-intlayer';\nimport type { LocaleObject, Strategies } from '../types';\nimport {\n defaultLocale,\n detectBrowserLocale,\n getActiveLocale,\n getCurrentFullPath,\n getRouter,\n localeCodes,\n localizeFullPath,\n strategy,\n} from './routing';\n\n/** What @nuxtjs/i18n adds to vue-i18n's composer. */\nexport type NuxtI18nComposerExtras = {\n locales: ComputedRef<LocaleObject[]>;\n localeCodes: ComputedRef<string[]>;\n localeProperties: ComputedRef<LocaleObject>;\n defaultLocale: string;\n strategy: Strategies;\n /** Activates a locale, persists it and navigates to the localized route. */\n setLocale: (locale: string) => Promise<void>;\n getBrowserLocale: () => string | undefined;\n getLocaleCookie: () => string | undefined;\n setLocaleCookie: (locale: string) => void;\n /** Kept for API parity: locale switches are never deferred. */\n finalizePendingLocaleChange: () => Promise<void>;\n /** Kept for API parity: locale switches are never deferred. */\n waitForPendingLocaleChange: () => Promise<void>;\n /** Kept for API parity: intlayer dictionaries need no loading. */\n loadLocaleMessages: (locale: string) => Promise<void>;\n};\n\n/** The @nuxtjs/i18n locale object describing a locale code. */\nexport const toLocaleObject = (code: string): LocaleObject => ({\n code,\n language: code,\n name: getLocaleName(code as LocalesValues, code as LocalesValues),\n dir: getHTMLTextDir(code as LocalesValues),\n});\n\nconst localeObjects = localeCodes.map(toLocaleObject);\n\nconst resolveNothing = (): Promise<void> => Promise.resolve();\n\n/**\n * Builds the Nuxt extras. Must run in a component setup, where the router is\n * reachable for `setLocale` navigation.\n */\nconst createComposerExtras = (): NuxtI18nComposerExtras => {\n const router = getRouter();\n const intlayerClient = createIntlayerClient();\n\n const setLocaleCookie = (locale: string): void =>\n setLocaleInStorageClient(locale as LocalesValues, localeStorageOptions);\n\n return {\n locales: computed(() => localeObjects),\n localeCodes: computed(() => localeCodes),\n localeProperties: computed(() => toLocaleObject(getActiveLocale())),\n defaultLocale,\n strategy,\n setLocale: async (locale) => {\n if (!localeCodes.includes(locale)) return;\n\n intlayerClient.setLocale(locale as LocalesValues);\n setLocaleCookie(locale);\n\n if (!router || strategy === 'no_prefix') return;\n\n await router.push(localizeFullPath(getCurrentFullPath(router), locale));\n },\n getBrowserLocale: detectBrowserLocale,\n getLocaleCookie: () => getCachedLocaleFromStorageClient(),\n setLocaleCookie,\n finalizePendingLocaleChange: resolveNothing,\n waitForPendingLocaleChange: resolveNothing,\n loadLocaleMessages: resolveNothing,\n };\n};\n\ntype ComposerOptions = Record<string, unknown>;\n\ntype NuxtUseI18n = {\n <N extends DictionaryKeys>(\n options: ComposerOptions & { namespace: N }\n ): TypedComposer<N> & NuxtI18nComposerExtras;\n (\n options?: ComposerOptions & { namespace?: undefined }\n ): LooseComposer & NuxtI18nComposerExtras;\n};\n\ntype NuxtUseDictionary = {\n <T extends Dictionary>(\n dictionary: T,\n options?: ComposerOptions & { namespace?: undefined }\n ): TypedComposer<T['key'] & DictionaryKeys> & NuxtI18nComposerExtras;\n <T extends Dictionary, Prefix extends string>(\n dictionary: T,\n options: ComposerOptions & { namespace: Prefix }\n ): ScopedComposer<T['key'] & DictionaryKeys, Prefix> & NuxtI18nComposerExtras;\n};\n\ntype NuxtUseDictionaryDynamic = {\n <T extends Dictionary, K extends DictionaryKeys>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n options?: ComposerOptions & { namespace?: undefined }\n ): TypedComposer<K> & NuxtI18nComposerExtras;\n <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n options: ComposerOptions & { namespace: Prefix }\n ): ScopedComposer<K, Prefix> & NuxtI18nComposerExtras;\n};\n\n/**\n * `useI18n()` of @nuxtjs/i18n: vue-i18n's composer (backed by intlayer\n * dictionaries) plus the Nuxt locale helpers.\n */\nexport const useI18n = ((options?: ComposerOptions) => ({\n ...useI18nBase(options),\n ...createComposerExtras(),\n})) as NuxtUseI18n;\n\n/**\n * Build-optimized `useI18n({ namespace })`: the optimize pass rewrites the\n * call to pass the dictionary, so only it reaches the bundle.\n */\nexport const useDictionary = ((\n dictionary: Dictionary,\n options?: ComposerOptions\n) => ({\n ...useDictionaryBase(dictionary, options),\n ...createComposerExtras(),\n})) as NuxtUseDictionary;\n\n/** Per-locale lazy variant of {@link useDictionary}. */\nexport const useDictionaryDynamic = ((\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<Dictionary>>,\n key: DictionaryKeys,\n options?: ComposerOptions\n) => ({\n ...useDictionaryDynamicBase(dictionaryLoaders, key, options),\n ...createComposerExtras(),\n})) as NuxtUseDictionaryDynamic;\n"],"mappings":";;;;;;;;;AAuDA,MAAa,kBAAkB,UAAgC;CAC7D;CACA,UAAU;CACV,MAAM,cAAc,MAAuB,IAAqB;CAChE,KAAK,eAAe,IAAqB;AAC3C;AAEA,MAAM,gBAAgB,YAAY,IAAI,cAAc;AAEpD,MAAM,uBAAsC,QAAQ,QAAQ;;;;;AAM5D,MAAM,6BAAqD;CACzD,MAAM,SAAS,UAAU;CACzB,MAAM,iBAAiB,qBAAqB;CAE5C,MAAM,mBAAmB,WACvB,yBAAyB,QAAyB,oBAAoB;CAExE,OAAO;EACL,SAAS,eAAe,aAAa;EACrC,aAAa,eAAe,WAAW;EACvC,kBAAkB,eAAe,eAAe,gBAAgB,CAAC,CAAC;EAClE;EACA;EACA,WAAW,OAAO,WAAW;GAC3B,IAAI,CAAC,YAAY,SAAS,MAAM,GAAG;GAEnC,eAAe,UAAU,MAAuB;GAChD,gBAAgB,MAAM;GAEtB,IAAI,CAAC,UAAU,aAAa,aAAa;GAEzC,MAAM,OAAO,KAAK,iBAAiB,mBAAmB,MAAM,GAAG,MAAM,CAAC;EACxE;EACA,kBAAkB;EAClB,uBAAuB,iCAAiC;EACxD;EACA,6BAA6B;EAC7B,4BAA4B;EAC5B,oBAAoB;CACtB;AACF;;;;;AAyCA,MAAa,YAAY,aAA+B;CACtD,GAAGA,UAAY,OAAO;CACtB,GAAG,qBAAqB;AAC1B;;;;;AAMA,MAAa,kBACX,YACA,aACI;CACJ,GAAGC,gBAAkB,YAAY,OAAO;CACxC,GAAG,qBAAqB;AAC1B;;AAGA,MAAa,yBACX,mBACA,KACA,aACI;CACJ,GAAGC,uBAAyB,mBAAmB,KAAK,OAAO;CAC3D,GAAG,qBAAqB;AAC1B"}
|