@intlayer/docs 7.0.4 → 7.0.6
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/blog/ar/intlayer_with_i18next.md +72 -19
- package/blog/ar/intlayer_with_next-i18next.md +61 -36
- package/blog/ar/intlayer_with_next-intl.md +61 -13
- package/blog/ar/intlayer_with_react-i18next.md +67 -18
- package/blog/ar/intlayer_with_react-intl.md +66 -13
- package/blog/ar/intlayer_with_vue-i18n.md +180 -0
- package/blog/de/intlayer_with_i18next.md +61 -26
- package/blog/de/intlayer_with_next-i18next.md +66 -17
- package/blog/de/intlayer_with_next-intl.md +62 -13
- package/blog/de/intlayer_with_react-i18next.md +66 -17
- package/blog/de/intlayer_with_react-intl.md +66 -14
- package/blog/de/intlayer_with_vue-i18n.md +178 -0
- package/blog/en/intlayer_with_i18next.md +53 -2
- package/blog/en/intlayer_with_next-i18next.md +52 -16
- package/blog/en/intlayer_with_next-intl.md +49 -0
- package/blog/en/intlayer_with_react-i18next.md +50 -1
- package/blog/en/intlayer_with_react-intl.md +53 -0
- package/blog/en/intlayer_with_vue-i18n.md +178 -0
- package/blog/en-GB/intlayer_with_i18next.md +58 -7
- package/blog/en-GB/intlayer_with_next-i18next.md +55 -9
- package/blog/en-GB/intlayer_with_next-intl.md +55 -6
- package/blog/en-GB/intlayer_with_react-i18next.md +55 -6
- package/blog/en-GB/intlayer_with_react-intl.md +56 -3
- package/blog/en-GB/intlayer_with_vue-i18n.md +180 -0
- package/blog/es/intlayer_with_i18next.md +69 -18
- package/blog/es/intlayer_with_next-i18next.md +70 -24
- package/blog/es/intlayer_with_next-intl.md +64 -13
- package/blog/es/intlayer_with_react-i18next.md +61 -12
- package/blog/es/intlayer_with_react-intl.md +65 -12
- package/blog/es/intlayer_with_vue-i18n.md +178 -0
- package/blog/fr/intlayer_with_i18next.md +77 -16
- package/blog/fr/intlayer_with_next-i18next.md +55 -31
- package/blog/fr/intlayer_with_next-intl.md +57 -7
- package/blog/fr/intlayer_with_react-i18next.md +64 -7
- package/blog/fr/intlayer_with_react-intl.md +63 -10
- package/blog/fr/intlayer_with_vue-i18n.md +178 -0
- package/blog/hi/intlayer_with_i18next.md +67 -16
- package/blog/hi/intlayer_with_next-i18next.md +69 -23
- package/blog/hi/intlayer_with_next-intl.md +61 -8
- package/blog/hi/intlayer_with_react-i18next.md +63 -14
- package/blog/hi/intlayer_with_react-intl.md +66 -13
- package/blog/hi/intlayer_with_vue-i18n.md +180 -0
- package/blog/id/intlayer_with_i18next.md +65 -14
- package/blog/id/intlayer_with_next-i18next.md +58 -12
- package/blog/id/intlayer_with_next-intl.md +60 -11
- package/blog/id/intlayer_with_react-i18next.md +59 -10
- package/blog/id/intlayer_with_react-intl.md +66 -13
- package/blog/id/intlayer_with_vue-i18n.md +178 -0
- package/blog/it/intlayer_with_i18next.md +70 -19
- package/blog/it/intlayer_with_next-i18next.md +68 -22
- package/blog/it/intlayer_with_next-intl.md +62 -12
- package/blog/it/intlayer_with_react-i18next.md +65 -16
- package/blog/it/intlayer_with_react-intl.md +67 -14
- package/blog/it/intlayer_with_vue-i18n.md +178 -0
- package/blog/ja/intlayer_with_i18next.md +74 -24
- package/blog/ja/intlayer_with_next-i18next.md +60 -37
- package/blog/ja/intlayer_with_next-intl.md +63 -15
- package/blog/ja/intlayer_with_react-i18next.md +70 -21
- package/blog/ja/intlayer_with_react-intl.md +73 -21
- package/blog/ja/intlayer_with_vue-i18n.md +180 -0
- package/blog/ko/intlayer_with_i18next.md +60 -29
- package/blog/ko/intlayer_with_next-i18next.md +59 -32
- package/blog/ko/intlayer_with_next-intl.md +52 -23
- package/blog/ko/intlayer_with_react-i18next.md +65 -16
- package/blog/ko/intlayer_with_react-intl.md +74 -22
- package/blog/ko/intlayer_with_vue-i18n.md +180 -0
- package/blog/pl/intlayer_with_i18next.md +63 -12
- package/blog/pl/intlayer_with_next-i18next.md +74 -17
- package/blog/pl/intlayer_with_next-intl.md +59 -8
- package/blog/pl/intlayer_with_react-i18next.md +59 -10
- package/blog/pl/intlayer_with_react-intl.md +65 -12
- package/blog/pl/intlayer_with_vue-i18n.md +180 -0
- package/blog/pt/intlayer_with_i18next.md +67 -16
- package/blog/pt/intlayer_with_next-i18next.md +65 -19
- package/blog/pt/intlayer_with_next-intl.md +62 -12
- package/blog/pt/intlayer_with_react-i18next.md +67 -18
- package/blog/pt/intlayer_with_react-intl.md +62 -10
- package/blog/pt/intlayer_with_vue-i18n.md +178 -0
- package/blog/ru/intlayer_with_i18next.md +68 -15
- package/blog/ru/intlayer_with_next-i18next.md +71 -25
- package/blog/ru/intlayer_with_next-intl.md +56 -7
- package/blog/ru/intlayer_with_react-i18next.md +65 -16
- package/blog/ru/intlayer_with_react-intl.md +69 -16
- package/blog/ru/intlayer_with_vue-i18n.md +180 -0
- package/blog/tr/intlayer_with_i18next.md +67 -16
- package/blog/tr/intlayer_with_next-i18next.md +78 -21
- package/blog/tr/intlayer_with_next-intl.md +69 -18
- package/blog/tr/intlayer_with_react-i18next.md +65 -16
- package/blog/tr/intlayer_with_react-intl.md +71 -19
- package/blog/tr/intlayer_with_vue-i18n.md +180 -0
- package/blog/vi/intlayer_with_i18next.md +64 -13
- package/blog/vi/intlayer_with_next-i18next.md +72 -26
- package/blog/vi/intlayer_with_next-intl.md +62 -11
- package/blog/vi/intlayer_with_react-i18next.md +66 -17
- package/blog/vi/intlayer_with_react-intl.md +70 -17
- package/blog/vi/intlayer_with_vue-i18n.md +180 -0
- package/blog/zh/intlayer_with_i18next.md +67 -17
- package/blog/zh/intlayer_with_next-i18next.md +67 -22
- package/blog/zh/intlayer_with_next-intl.md +61 -13
- package/blog/zh/intlayer_with_react-i18next.md +67 -18
- package/blog/zh/intlayer_with_react-intl.md +69 -17
- package/blog/zh/intlayer_with_vue-i18n.md +180 -0
- package/dist/cjs/generated/blog.entry.cjs +19 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +19 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_nextjs_15.md +36 -9
- package/docs/ar/intlayer_with_nextjs_16.md +36 -9
- package/docs/de/intlayer_with_nextjs_15.md +36 -9
- package/docs/de/intlayer_with_nextjs_16.md +24 -6
- package/docs/en/intlayer_with_nextjs_14.md +37 -9
- package/docs/en/intlayer_with_nextjs_15.md +40 -10
- package/docs/en/intlayer_with_nextjs_16.md +40 -10
- package/docs/en/plugins/sync-json.md +152 -55
- package/docs/en/releases/v7.md +1 -1
- package/docs/en-GB/intlayer_with_nextjs_15.md +36 -9
- package/docs/en-GB/intlayer_with_nextjs_16.md +36 -9
- package/docs/en-GB/releases/v7.md +1 -1
- package/docs/es/intlayer_with_nextjs_15.md +36 -9
- package/docs/es/intlayer_with_nextjs_16.md +36 -9
- package/docs/fr/intlayer_with_nextjs_15.md +36 -9
- package/docs/fr/intlayer_with_nextjs_16.md +37 -24
- package/docs/hi/intlayer_with_nextjs_15.md +36 -9
- package/docs/hi/intlayer_with_nextjs_16.md +36 -9
- package/docs/id/intlayer_with_nextjs_16.md +36 -9
- package/docs/it/intlayer_with_nextjs_15.md +36 -9
- package/docs/it/intlayer_with_nextjs_16.md +36 -9
- package/docs/ja/intlayer_with_nextjs_15.md +36 -9
- package/docs/ja/intlayer_with_nextjs_16.md +36 -9
- package/docs/ko/intlayer_with_nextjs_15.md +36 -9
- package/docs/ko/intlayer_with_nextjs_16.md +36 -9
- package/docs/pl/intlayer_with_nextjs_16.md +36 -9
- package/docs/pt/intlayer_with_nextjs_15.md +36 -9
- package/docs/pt/intlayer_with_nextjs_16.md +36 -9
- package/docs/ru/intlayer_with_nextjs_15.md +36 -9
- package/docs/ru/intlayer_with_nextjs_16.md +36 -9
- package/docs/tr/intlayer_with_nextjs_15.md +36 -9
- package/docs/tr/intlayer_with_nextjs_16.md +39 -21
- package/docs/vi/intlayer_with_nextjs_16.md +36 -9
- package/docs/zh/intlayer_with_nextjs_15.md +36 -9
- package/docs/zh/intlayer_with_nextjs_16.md +36 -9
- package/package.json +14 -14
- package/src/generated/blog.entry.ts +19 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-08-23
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Intlayer and vue-i18n
|
|
5
|
+
description: Integrate Intlayer with vue-i18n for a comprehensive Vue.js internationalisation solution
|
|
6
|
+
keywords:
|
|
7
|
+
- vue-i18n
|
|
8
|
+
- Intlayer
|
|
9
|
+
- Internationalisation
|
|
10
|
+
- Blog
|
|
11
|
+
- Vue.js
|
|
12
|
+
- Nuxt
|
|
13
|
+
- JavaScript
|
|
14
|
+
- Vue
|
|
15
|
+
slugs:
|
|
16
|
+
- blog
|
|
17
|
+
- intlayer-with-vue-i18n
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Add loadJSON plugin
|
|
22
|
+
- version: 7.0.0
|
|
23
|
+
date: 2025-10-29
|
|
24
|
+
changes: Change to syncJSON plugin and comprehensive rewrite
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Vue.js Internationalisation (i18n) with vue-i18n and Intlayer
|
|
28
|
+
|
|
29
|
+
## Table of Contents
|
|
30
|
+
|
|
31
|
+
<TOC/>
|
|
32
|
+
|
|
33
|
+
## What is Intlayer?
|
|
34
|
+
|
|
35
|
+
**Intlayer** is an innovative, open-source internationalisation library designed to address the shortcomings of traditional i18n solutions. It offers a modern approach to content management in Vue.js and Nuxt applications.
|
|
36
|
+
|
|
37
|
+
See a concrete comparison with vue-i18n in our [vue-i18n vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/vue-i18n_vs_intlayer.md) blog post.
|
|
38
|
+
|
|
39
|
+
## Why Combine Intlayer with vue-i18n?
|
|
40
|
+
|
|
41
|
+
While Intlayer provides an excellent standalone i18n solution (see our [Vue.js integration guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+vue.md)), you might want to combine it with vue-i18n for several reasons:
|
|
42
|
+
|
|
43
|
+
1. **Existing codebase**: You have an established vue-i18n implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
44
|
+
2. **Legacy requirements**: Your project requires compatibility with existing vue-i18n plugins or workflows.
|
|
45
|
+
3. **Team familiarity**: Your team is comfortable with vue-i18n but wants better content management.
|
|
46
|
+
4. **Using Intlayer features**: You want to use Intlayer features like content declaration, translation automation, testing translations, and more.
|
|
47
|
+
|
|
48
|
+
**For that, Intlayer can be implemented as an adapter for vue-i18n to help automate your JSON translations in CLI or CI/CD pipelines, test your translations, and more.**
|
|
49
|
+
|
|
50
|
+
This guide shows you how to leverage Intlayer's superior content declaration system whilst maintaining compatibility with vue-i18n.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Step-by-Step Guide to Set Up Intlayer with vue-i18n
|
|
55
|
+
|
|
56
|
+
### Step 1: Install Dependencies
|
|
57
|
+
|
|
58
|
+
Install the necessary packages using your preferred package manager:
|
|
59
|
+
|
|
60
|
+
```bash packageManager="npm"
|
|
61
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```bash packageManager="pnpm"
|
|
65
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash packageManager="yarn"
|
|
69
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Package explanations:**
|
|
77
|
+
|
|
78
|
+
- **intlayer**: Core library for content declaration and management
|
|
79
|
+
- **@intlayer/sync-json-plugin**: Plugin to synchronise Intlayer content declarations to vue-i18n JSON format
|
|
80
|
+
|
|
81
|
+
### Step 2: Implement the Intlayer plugin to wrap the JSON
|
|
82
|
+
|
|
83
|
+
Create an Intlayer configuration file to define your supported locales:
|
|
84
|
+
|
|
85
|
+
**If you also want to export JSON dictionaries for vue-i18n**, add the `syncJSON` plugin:
|
|
86
|
+
|
|
87
|
+
```typescript fileName="intlayer.config.ts"
|
|
88
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
89
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
90
|
+
|
|
91
|
+
const config: IntlayerConfig = {
|
|
92
|
+
internationalization: {
|
|
93
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
94
|
+
defaultLocale: Locales.ENGLISH,
|
|
95
|
+
},
|
|
96
|
+
plugins: [
|
|
97
|
+
syncJSON({
|
|
98
|
+
source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default config;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The `syncJSON` plugin will automatically wrap the JSON. It will read and write the JSON files without changing the content architecture.
|
|
107
|
+
|
|
108
|
+
If you want to make that JSON coexist with Intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
109
|
+
|
|
110
|
+
1. load both JSON and content declaration files and transform them into an Intlayer dictionary.
|
|
111
|
+
2. if there are conflicts between the JSON and the content declaration files, Intlayer will merge all those dictionaries. This depends on the priority of the plugins, and that of the content declaration file (all are configurable).
|
|
112
|
+
|
|
113
|
+
If changes are made using the CLI to translate the JSON, or using the CMS, Intlayer will update the JSON file with the new translations.
|
|
114
|
+
|
|
115
|
+
To see more details about the `syncJSON` plugin, please refer to the [syncJSON plugin documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/plugins/sync-json.md).
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronise both JSON and content declaration files. See [the content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md) for more details. But if you prefer, using an Intlayer plugin, you can also implement per-component management of JSON localised anywhere in your codebase.
|
|
122
|
+
|
|
123
|
+
For that, you can use the `loadJSON` plugin.
|
|
124
|
+
|
|
125
|
+
```ts fileName="intlayer.config.ts"
|
|
126
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
127
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
128
|
+
|
|
129
|
+
const config: IntlayerConfig = {
|
|
130
|
+
internationalisation: {
|
|
131
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Keep your current JSON files in sync with Intlayer dictionaries
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Will load all the JSON files in the src that match the pattern {key}.i18n json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Ensures these JSON files take precedence over files at `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Will load, and write the output and translations back to the JSON files in the locales directory
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This will load all the JSON files in the `src` directory that match the pattern `{key}.i18n.json` and load them as Intlayer dictionaries.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Git Configuration
|
|
163
|
+
|
|
164
|
+
Exclude generated files from version control:
|
|
165
|
+
|
|
166
|
+
```plaintext fileName=".gitignore"
|
|
167
|
+
# Ignore files generated by Intlayer
|
|
168
|
+
.intlayer
|
|
169
|
+
intl
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
These files are automatically regenerated during the build process and do not need to be committed to your repository.
|
|
173
|
+
|
|
174
|
+
### VS Code Extension
|
|
175
|
+
|
|
176
|
+
For improved developer experience, install the official **Intlayer VS Code Extension**:
|
|
177
|
+
|
|
178
|
+
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
179
|
+
|
|
180
|
+
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2024-12-24
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-11-01
|
|
4
4
|
title: Cómo automatizar tus traducciones JSON de i18next usando Intlayer
|
|
5
5
|
description: Automatiza tus traducciones JSON con Intlayer e i18next para una internacionalización mejorada en aplicaciones JavaScript.
|
|
6
6
|
keywords:
|
|
@@ -20,26 +20,30 @@ slugs:
|
|
|
20
20
|
- blog
|
|
21
21
|
- intlayer-with-i18next
|
|
22
22
|
history:
|
|
23
|
+
- version: 7.0.6
|
|
24
|
+
date: 2025-11-01
|
|
25
|
+
changes: Añadir plugin loadJSON
|
|
23
26
|
- version: 7.0.0
|
|
24
27
|
date: 2025-10-29
|
|
25
|
-
changes:
|
|
28
|
+
changes: Cambiar a plugin syncJSON
|
|
26
29
|
---
|
|
27
30
|
|
|
28
31
|
# Cómo automatizar tus traducciones JSON de i18next usando Intlayer
|
|
29
32
|
|
|
30
33
|
## ¿Qué es Intlayer?
|
|
31
34
|
|
|
32
|
-
**Intlayer** es una biblioteca innovadora y de código abierto para la internacionalización, diseñada para abordar las limitaciones de las soluciones tradicionales
|
|
35
|
+
**Intlayer** es una biblioteca innovadora y de código abierto para la internacionalización, diseñada para abordar las limitaciones de las soluciones i18n tradicionales. Ofrece un enfoque moderno para la gestión de contenido en aplicaciones JavaScript.
|
|
33
36
|
|
|
34
37
|
Consulta una comparación concreta con i18next en nuestro artículo del blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/es/next-i18next_vs_next-intl_vs_intlayer.md).
|
|
35
38
|
|
|
36
39
|
## ¿Por qué combinar Intlayer con i18next?
|
|
37
40
|
|
|
38
|
-
Aunque Intlayer
|
|
41
|
+
Aunque Intlayer ofrece una excelente solución i18n independiente (consulta nuestra [guía de integración con Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_nextjs_16.md)), es posible que desees combinarlo con i18next por varias razones:
|
|
39
42
|
|
|
40
43
|
1. **Base de código existente**: Tienes una implementación establecida de i18next y deseas migrar gradualmente a la mejor experiencia de desarrollo que ofrece Intlayer.
|
|
41
|
-
2. **Requisitos heredados**: Tu proyecto requiere compatibilidad con plugins o flujos de trabajo existentes de i18next.
|
|
42
|
-
3. **Familiaridad del equipo**: Tu equipo está
|
|
44
|
+
2. **Requisitos heredados**: Tu proyecto requiere compatibilidad con los plugins o flujos de trabajo existentes de i18next.
|
|
45
|
+
3. **Familiaridad del equipo**: Tu equipo está familiarizado con i18next pero quiere una mejor gestión de contenido.
|
|
46
|
+
4. **Uso de las funcionalidades de Intlayer**: Quieres utilizar funciones de Intlayer como la declaración de contenido, gestión de claves de traducción, estado de traducción y más.
|
|
43
47
|
|
|
44
48
|
**Para ello, Intlayer puede implementarse como un adaptador para i18next que ayuda a automatizar tus traducciones JSON en la CLI o en pipelines CI/CD, probar tus traducciones y más.**
|
|
45
49
|
|
|
@@ -49,9 +53,9 @@ Esta guía te muestra cómo aprovechar el sistema superior de declaración de co
|
|
|
49
53
|
|
|
50
54
|
<TOC/>
|
|
51
55
|
|
|
52
|
-
## Guía
|
|
56
|
+
## Guía Paso a Paso para Configurar Intlayer con i18next
|
|
53
57
|
|
|
54
|
-
### Paso 1: Instalar
|
|
58
|
+
### Paso 1: Instalar Dependencias
|
|
55
59
|
|
|
56
60
|
Instala los paquetes necesarios:
|
|
57
61
|
|
|
@@ -67,6 +71,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
67
71
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
```bash packageManager="bun"
|
|
75
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
76
|
+
```
|
|
77
|
+
|
|
70
78
|
**Descripción de los paquetes:**
|
|
71
79
|
|
|
72
80
|
- **intlayer**: Biblioteca principal para la gestión de internacionalización, declaración de contenido y construcción
|
|
@@ -74,9 +82,9 @@ yarn add intlayer @intlayer/sync-json-plugin
|
|
|
74
82
|
|
|
75
83
|
### Paso 2: Implementar el plugin de Intlayer para envolver el JSON
|
|
76
84
|
|
|
77
|
-
Crea un archivo de configuración de Intlayer para definir
|
|
85
|
+
Crea un archivo de configuración de Intlayer para definir los locales soportados:
|
|
78
86
|
|
|
79
|
-
**Si también
|
|
87
|
+
**Si también quieres exportar diccionarios JSON para i18next**, añade el plugin `syncJSON`:
|
|
80
88
|
|
|
81
89
|
```typescript fileName="intlayer.config.ts"
|
|
82
90
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -89,7 +97,7 @@ const config: IntlayerConfig = {
|
|
|
89
97
|
},
|
|
90
98
|
plugins: [
|
|
91
99
|
syncJSON({
|
|
92
|
-
source: ({ key, locale }) => `./
|
|
100
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
93
101
|
}),
|
|
94
102
|
],
|
|
95
103
|
};
|
|
@@ -99,13 +107,58 @@ export default config;
|
|
|
99
107
|
|
|
100
108
|
El plugin `syncJSON` envolverá automáticamente el JSON. Leerá y escribirá los archivos JSON sin cambiar la arquitectura del contenido.
|
|
101
109
|
|
|
102
|
-
Si quieres hacer coexistir ese JSON con los archivos de declaración de contenido de
|
|
110
|
+
Si quieres hacer coexistir ese JSON con los archivos de declaración de contenido de Intlayer (archivos `.content`), Intlayer procederá de la siguiente manera:
|
|
103
111
|
|
|
104
|
-
1.
|
|
105
|
-
2. si hay conflictos entre el JSON y los archivos de declaración de contenido, Intlayer procederá a fusionar todos esos diccionarios. Dependiendo de la prioridad de los plugins y la del archivo de declaración de contenido (todos son configurables).
|
|
112
|
+
1. cargará tanto los archivos JSON como los archivos de declaración de contenido y los transformará en un diccionario de Intlayer.
|
|
113
|
+
2. si hay conflictos entre el JSON y los archivos de declaración de contenido, Intlayer procederá a fusionar todos esos diccionarios. Dependiendo de la prioridad de los plugins y de la del archivo de declaración de contenido (todos son configurables).
|
|
106
114
|
|
|
107
115
|
Si se realizan cambios usando la CLI para traducir el JSON, o usando el CMS, Intlayer actualizará el archivo JSON con las nuevas traducciones.
|
|
108
116
|
|
|
117
|
+
Para ver más detalles sobre el plugin `syncJSON`, por favor consulta la [documentación del plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/plugins/sync-json.md).
|
|
118
|
+
|
|
119
|
+
### (Opcional) Paso 3: Implementar traducciones JSON por componente
|
|
120
|
+
|
|
121
|
+
Por defecto, Intlayer cargará, combinará y sincronizará tanto los archivos JSON como los archivos de declaración de contenido. Consulta [la documentación de declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/content_file.md) para más detalles. Pero si prefieres, usando un plugin de Intlayer, también puedes implementar la gestión por componente de JSON localizado en cualquier parte de tu base de código.
|
|
122
|
+
|
|
123
|
+
Para ello, puedes usar el plugin `loadJSON`.
|
|
124
|
+
|
|
125
|
+
```ts fileName="intlayer.config.ts"
|
|
126
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
127
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
128
|
+
|
|
129
|
+
const config: IntlayerConfig = {
|
|
130
|
+
internationalization: {
|
|
131
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Mantén tus archivos JSON actuales sincronizados con los diccionarios de Intlayer
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Cargará todos los archivos JSON en src que coincidan con el patrón {key}.i18n.json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Asegura que estos archivos JSON tengan prioridad sobre los archivos en `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Cargará y escribirá la salida y las traducciones de vuelta en los archivos JSON en el directorio locales
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Esto cargará todos los archivos JSON en el directorio `src` que coincidan con el patrón `{key}.i18n.json` y los cargará como diccionarios de Intlayer.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
109
162
|
## Configuración de Git
|
|
110
163
|
|
|
111
164
|
Se recomienda ignorar los archivos generados automáticamente por Intlayer:
|
|
@@ -115,12 +168,10 @@ Se recomienda ignorar los archivos generados automáticamente por Intlayer:
|
|
|
115
168
|
.intlayer
|
|
116
169
|
```
|
|
117
170
|
|
|
118
|
-
Estos archivos pueden
|
|
171
|
+
Estos archivos pueden regenerarse durante tu proceso de compilación y no necesitan ser comprometidos en el control de versiones.
|
|
119
172
|
|
|
120
|
-
### Extensión
|
|
173
|
+
### Extensión de VS Code
|
|
121
174
|
|
|
122
175
|
Para mejorar la experiencia del desarrollador, instala la extensión oficial **Intlayer VS Code Extension**:
|
|
123
176
|
|
|
124
177
|
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
125
|
-
|
|
126
|
-
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -16,9 +16,12 @@ slugs:
|
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-next-i18next
|
|
18
18
|
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Añadir plugin loadJSON
|
|
19
22
|
- version: 7.0.0
|
|
20
23
|
date: 2025-10-29
|
|
21
|
-
changes: Cambio
|
|
24
|
+
changes: Cambio a plugin syncJSON y reescritura completa
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
# Internacionalización (i18n) en Next.js con next-i18next e Intlayer
|
|
@@ -29,11 +32,11 @@ history:
|
|
|
29
32
|
|
|
30
33
|
## ¿Qué es next-i18next?
|
|
31
34
|
|
|
32
|
-
**next-i18next** es uno de los frameworks de internacionalización (i18n) más populares para aplicaciones Next.js. Construido sobre el poderoso ecosistema de **i18next**,
|
|
35
|
+
**next-i18next** es uno de los frameworks de internacionalización (i18n) más populares para aplicaciones Next.js. Construido sobre el poderoso ecosistema de **i18next**, proporciona una solución integral para gestionar traducciones, localización y cambio de idioma en proyectos Next.js.
|
|
33
36
|
|
|
34
37
|
Sin embargo, next-i18next presenta algunos desafíos:
|
|
35
38
|
|
|
36
|
-
- **Configuración compleja**: Configurar next-i18next requiere múltiples archivos de configuración y una configuración cuidadosa de las instancias i18n del lado del servidor
|
|
39
|
+
- **Configuración compleja**: Configurar next-i18next requiere múltiples archivos de configuración y una configuración cuidadosa de las instancias i18n tanto del lado del servidor como del cliente.
|
|
37
40
|
- **Traducciones dispersas**: Los archivos de traducción suelen almacenarse en directorios separados de los componentes, lo que dificulta mantener la consistencia.
|
|
38
41
|
- **Gestión manual de namespaces**: Los desarrolladores deben gestionar manualmente los namespaces y asegurar la correcta carga de los recursos de traducción.
|
|
39
42
|
- **Seguridad de tipos limitada**: El soporte para TypeScript requiere configuración adicional y no proporciona generación automática de tipos para las traducciones.
|
|
@@ -46,15 +49,15 @@ Consulta una comparación concreta con next-intl en nuestro artículo del blog [
|
|
|
46
49
|
|
|
47
50
|
## ¿Por qué combinar Intlayer con next-i18next?
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
Aunque Intlayer ofrece una excelente solución i18n independiente (consulta nuestra [guía de integración con Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_nextjs_16.md)), es posible que desees combinarlo con next-i18next por varias razones:
|
|
50
53
|
|
|
51
|
-
1. **
|
|
54
|
+
1. **Base de código existente**: Tienes una implementación establecida de next-i18next y quieres migrar gradualmente a la mejor experiencia de desarrollo que ofrece Intlayer.
|
|
52
55
|
2. **Requisitos heredados**: Tu proyecto requiere compatibilidad con plugins o flujos de trabajo existentes de i18next.
|
|
53
56
|
3. **Familiaridad del equipo**: Tu equipo está cómodo con next-i18next pero desea una mejor gestión de contenido.
|
|
54
57
|
|
|
55
|
-
**Para ello, Intlayer puede implementarse como un adaptador para next-i18next
|
|
58
|
+
**Para ello, Intlayer puede implementarse como un adaptador para next-i18next para ayudar a automatizar tus traducciones JSON en la CLI o en pipelines de CI/CD, probar tus traducciones y más.**
|
|
56
59
|
|
|
57
|
-
Esta guía te muestra cómo aprovechar el sistema
|
|
60
|
+
Esta guía te muestra cómo aprovechar el superior sistema de declaración de contenido de Intlayer mientras mantienes la compatibilidad con next-i18next.
|
|
58
61
|
|
|
59
62
|
---
|
|
60
63
|
|
|
@@ -76,18 +79,18 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
76
79
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
77
80
|
```
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
```bash packageManager="bun"
|
|
83
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Explicaciones de los paquetes:**
|
|
80
87
|
|
|
81
88
|
- **intlayer**: Biblioteca principal para la declaración y gestión de contenido
|
|
82
|
-
- **next-intlayer**: Capa de integración para Next.js con plugins de compilación
|
|
83
|
-
- **i18next**: Framework principal de i18n
|
|
84
|
-
- **next-i18next**: Wrapper de Next.js para i18next
|
|
85
|
-
- **i18next-resources-to-backend**: Carga dinámica de recursos para i18next
|
|
86
89
|
- **@intlayer/sync-json-plugin**: Plugin para sincronizar las declaraciones de contenido de Intlayer al formato JSON de i18next
|
|
87
90
|
|
|
88
91
|
### Paso 2: Implementar el plugin de Intlayer para envolver el JSON
|
|
89
92
|
|
|
90
|
-
Crea un archivo de configuración de Intlayer para definir los locales
|
|
93
|
+
Crea un archivo de configuración de Intlayer para definir los locales que soportas:
|
|
91
94
|
|
|
92
95
|
**Si también quieres exportar diccionarios JSON para i18next**, añade el plugin `syncJSON`:
|
|
93
96
|
|
|
@@ -102,7 +105,7 @@ const config: IntlayerConfig = {
|
|
|
102
105
|
},
|
|
103
106
|
plugins: [
|
|
104
107
|
syncJSON({
|
|
105
|
-
source: ({ key, locale }) => `./
|
|
108
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
106
109
|
}),
|
|
107
110
|
],
|
|
108
111
|
};
|
|
@@ -112,18 +115,63 @@ export default config;
|
|
|
112
115
|
|
|
113
116
|
El plugin `syncJSON` envolverá automáticamente el JSON. Leerá y escribirá los archivos JSON sin cambiar la arquitectura del contenido.
|
|
114
117
|
|
|
115
|
-
Si deseas hacer coexistir ese JSON con los archivos de declaración de contenido de
|
|
118
|
+
Si deseas hacer coexistir ese JSON con los archivos de declaración de contenido de Intlayer (`.content` files), Intlayer procederá de la siguiente manera:
|
|
116
119
|
|
|
117
|
-
1. cargar tanto los archivos JSON como los archivos de declaración de contenido y transformarlos en un diccionario de
|
|
118
|
-
2. si hay conflictos entre
|
|
120
|
+
1. cargar tanto los archivos JSON como los archivos de declaración de contenido y transformarlos en un diccionario de Intlayer.
|
|
121
|
+
2. si hay conflictos entre los archivos JSON y los archivos de declaración de contenido, Intlayer procederá a fusionar todos esos diccionarios. Dependiendo de la prioridad de los plugins y la del archivo de declaración de contenido (todos son configurables).
|
|
119
122
|
|
|
120
|
-
Si se realizan cambios
|
|
123
|
+
Si se realizan cambios utilizando la CLI para traducir el JSON, o usando el CMS, Intlayer actualizará el archivo JSON con las nuevas traducciones.
|
|
124
|
+
|
|
125
|
+
Para ver más detalles sobre el plugin `syncJSON`, por favor consulta la [documentación del plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/plugins/sync-json.md).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### (Opcional) Paso 3: Implementar traducciones JSON por componente
|
|
130
|
+
|
|
131
|
+
Por defecto, Intlayer cargará, combinará y sincronizará tanto los archivos JSON como los archivos de declaración de contenido. Consulta [la documentación de declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/content_file.md) para más detalles. Pero si prefieres, usando un plugin de Intlayer, también puedes implementar la gestión por componente de JSON localizado en cualquier parte de tu base de código.
|
|
132
|
+
|
|
133
|
+
Para eso, puedes usar el plugin `loadJSON`.
|
|
134
|
+
|
|
135
|
+
```ts fileName="intlayer.config.ts"
|
|
136
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
137
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
138
|
+
|
|
139
|
+
const config: IntlayerConfig = {
|
|
140
|
+
internationalization: {
|
|
141
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
142
|
+
defaultLocale: Locales.ENGLISH,
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// Mantén tus archivos JSON actuales sincronizados con los diccionarios de Intlayer
|
|
146
|
+
plugins: [
|
|
147
|
+
/**
|
|
148
|
+
* Cargará todos los archivos JSON en src que coincidan con el patrón {key}.i18n.json
|
|
149
|
+
*/
|
|
150
|
+
loadJSON({
|
|
151
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
152
|
+
locale: Locales.ENGLISH,
|
|
153
|
+
priority: 1, // Asegura que estos archivos JSON tengan prioridad sobre los archivos en `./public/locales/en/${key}.json`
|
|
154
|
+
}),
|
|
155
|
+
/**
|
|
156
|
+
* Cargará y escribirá la salida y las traducciones de vuelta en los archivos JSON en el directorio de locales
|
|
157
|
+
*/
|
|
158
|
+
syncJSON({
|
|
159
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
160
|
+
priority: 0,
|
|
161
|
+
}),
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default config;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Esto cargará todos los archivos JSON en el directorio `src` que coincidan con el patrón `{key}.i18n.json` y los cargará como diccionarios de Intlayer.
|
|
121
169
|
|
|
122
170
|
---
|
|
123
171
|
|
|
124
172
|
## Configuración de Git
|
|
125
173
|
|
|
126
|
-
|
|
174
|
+
Excluye los archivos generados del control de versiones:
|
|
127
175
|
|
|
128
176
|
```plaintext fileName=".gitignore"
|
|
129
177
|
# Ignorar archivos generados por Intlayer
|
|
@@ -131,12 +179,10 @@ Excluir archivos generados del control de versiones:
|
|
|
131
179
|
intl
|
|
132
180
|
```
|
|
133
181
|
|
|
134
|
-
Estos archivos se regeneran automáticamente durante el proceso de compilación y no necesitan ser
|
|
135
|
-
|
|
136
|
-
### Extensión de VS Code
|
|
182
|
+
Estos archivos se regeneran automáticamente durante el proceso de compilación y no necesitan ser confirmados en tu repositorio.
|
|
137
183
|
|
|
138
|
-
|
|
184
|
+
### Extensión para VS Code
|
|
139
185
|
|
|
140
|
-
|
|
186
|
+
Para mejorar la experiencia del desarrollador, instala la extensión oficial **Intlayer para VS Code**:
|
|
141
187
|
|
|
142
188
|
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -7,30 +7,33 @@ slugs:
|
|
|
7
7
|
- blog
|
|
8
8
|
- intlayer-with-next-intl
|
|
9
9
|
history:
|
|
10
|
+
- version: 7.0.6
|
|
11
|
+
date: 2025-11-01
|
|
12
|
+
changes: Añadir el plugin loadJSON
|
|
10
13
|
- version: 7.0.0
|
|
11
14
|
date: 2025-10-29
|
|
12
|
-
changes:
|
|
15
|
+
changes: Cambiar al plugin syncJSON
|
|
13
16
|
---
|
|
14
17
|
|
|
15
18
|
# Cómo automatizar tus traducciones JSON de next-intl usando Intlayer
|
|
16
19
|
|
|
17
20
|
## ¿Qué es Intlayer?
|
|
18
21
|
|
|
19
|
-
**Intlayer** es una biblioteca innovadora
|
|
22
|
+
**Intlayer** es una biblioteca innovadora y de código abierto para la internacionalización, diseñada para abordar las limitaciones de las soluciones tradicionales de i18n. Ofrece un enfoque moderno para la gestión de contenido en aplicaciones Next.js.
|
|
20
23
|
|
|
21
|
-
Consulta una comparación concreta con next-intl en
|
|
24
|
+
Consulta una comparación concreta con next-intl en nuestra publicación del blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/es/next-i18next_vs_next-intl_vs_intlayer.md).
|
|
22
25
|
|
|
23
26
|
## ¿Por qué combinar Intlayer con next-intl?
|
|
24
27
|
|
|
25
|
-
Aunque Intlayer ofrece una excelente solución
|
|
28
|
+
Aunque Intlayer ofrece una excelente solución i18n independiente (consulta nuestra [guía de integración con Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_nextjs_16.md)), es posible que desees combinarlo con next-intl por varias razones:
|
|
26
29
|
|
|
27
30
|
1. **Código existente**: Tienes una implementación establecida de next-intl y quieres migrar gradualmente a la mejor experiencia de desarrollo que ofrece Intlayer.
|
|
28
31
|
2. **Requisitos heredados**: Tu proyecto requiere compatibilidad con plugins o flujos de trabajo existentes de next-intl.
|
|
29
32
|
3. **Familiaridad del equipo**: Tu equipo está cómodo con next-intl pero desea una mejor gestión de contenido.
|
|
30
33
|
|
|
31
|
-
**Para ello, Intlayer puede implementarse como un adaptador para next-intl que ayude a automatizar tus traducciones JSON en la CLI o en pipelines
|
|
34
|
+
**Para ello, Intlayer puede implementarse como un adaptador para next-intl que ayude a automatizar tus traducciones JSON en la CLI o en pipelines CI/CD, probar tus traducciones y más.**
|
|
32
35
|
|
|
33
|
-
Esta guía te muestra cómo aprovechar el superior
|
|
36
|
+
Esta guía te muestra cómo aprovechar el sistema superior de declaración de contenido de Intlayer manteniendo la compatibilidad con next-intl.
|
|
34
37
|
|
|
35
38
|
## Tabla de Contenidos
|
|
36
39
|
|
|
@@ -54,16 +57,20 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
54
57
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
55
58
|
```
|
|
56
59
|
|
|
60
|
+
```bash packageManager="bun"
|
|
61
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
57
64
|
**Descripción de los paquetes:**
|
|
58
65
|
|
|
59
66
|
- **intlayer**: Biblioteca principal para la gestión de internacionalización, declaración de contenido y construcción
|
|
60
|
-
- **@intlayer/sync-json-plugin**: Plugin para exportar
|
|
67
|
+
- **@intlayer/sync-json-plugin**: Plugin para exportar declaraciones de contenido de Intlayer a un formato JSON compatible con next-intl
|
|
61
68
|
|
|
62
69
|
### Paso 2: Implementar el plugin de Intlayer para envolver el JSON
|
|
63
70
|
|
|
64
|
-
Crea un archivo de configuración de Intlayer para definir
|
|
71
|
+
Crea un archivo de configuración de Intlayer para definir tus locales soportados:
|
|
65
72
|
|
|
66
|
-
**Si también
|
|
73
|
+
**Si también deseas exportar diccionarios JSON para next-intl**, añade el plugin `syncJSON`:
|
|
67
74
|
|
|
68
75
|
```typescript fileName="intlayer.config.ts"
|
|
69
76
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -88,11 +95,55 @@ El plugin `syncJSON` envolverá automáticamente el JSON. Leerá y escribirá lo
|
|
|
88
95
|
|
|
89
96
|
Si deseas hacer coexistir ese JSON con los archivos de declaración de contenido de intlayer (archivos `.content`), Intlayer procederá de la siguiente manera:
|
|
90
97
|
|
|
91
|
-
1.
|
|
92
|
-
|
|
98
|
+
1. cargará tanto los archivos JSON como los archivos de declaración de contenido y los transformará en un diccionario de intlayer.
|
|
99
|
+
|
|
100
|
+
2. si hay conflictos entre el JSON y los archivos de declaración de contenido, Intlayer procederá a la fusión de todos esos diccionarios. Dependiendo de la prioridad de los plugins y la del archivo de declaración de contenido (todos son configurables).
|
|
93
101
|
|
|
94
102
|
Si se realizan cambios usando la CLI para traducir el JSON, o usando el CMS, Intlayer actualizará el archivo JSON con las nuevas traducciones.
|
|
95
103
|
|
|
104
|
+
Para ver más detalles sobre el plugin `syncJSON`, por favor consulte la [documentación del plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/plugins/sync-json.md).
|
|
105
|
+
|
|
106
|
+
### (Opcional) Paso 3: Implementar traducciones JSON por componente
|
|
107
|
+
|
|
108
|
+
Por defecto, Intlayer cargará, fusionará y sincronizará tanto los archivos JSON como los archivos de declaración de contenido. Consulte [la documentación de declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/content_file.md) para más detalles. Pero si lo prefiere, utilizando un plugin de Intlayer, también puede implementar la gestión por componente de JSON localizado en cualquier parte de su base de código.
|
|
109
|
+
|
|
110
|
+
Para ello, puede usar el plugin `loadJSON`.
|
|
111
|
+
|
|
112
|
+
```ts fileName="intlayer.config.ts"
|
|
113
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
114
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
115
|
+
|
|
116
|
+
const config: IntlayerConfig = {
|
|
117
|
+
internationalization: {
|
|
118
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
119
|
+
defaultLocale: Locales.ENGLISH,
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
// Mantenga sus archivos JSON actuales sincronizados con los diccionarios de Intlayer
|
|
123
|
+
plugins: [
|
|
124
|
+
/**
|
|
125
|
+
* Cargará todos los archivos JSON en src que coincidan con el patrón {key}.i18n.json
|
|
126
|
+
*/
|
|
127
|
+
loadJSON({
|
|
128
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
129
|
+
locale: Locales.ENGLISH,
|
|
130
|
+
priority: 1, // Asegura que estos archivos JSON tengan prioridad sobre los archivos en `./locales/en/${key}.json`
|
|
131
|
+
}),
|
|
132
|
+
/**
|
|
133
|
+
* Cargará y escribirá la salida y las traducciones de vuelta en los archivos JSON en el directorio locales
|
|
134
|
+
*/
|
|
135
|
+
syncJSON({
|
|
136
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
137
|
+
priority: 0,
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default config;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Esto cargará todos los archivos JSON en el directorio `src` que coincidan con el patrón `{key}.i18n.json` y los cargará como diccionarios de Intlayer.
|
|
146
|
+
|
|
96
147
|
## Configuración de Git
|
|
97
148
|
|
|
98
149
|
Se recomienda ignorar los archivos generados automáticamente por Intlayer:
|
|
@@ -102,10 +153,10 @@ Se recomienda ignorar los archivos generados automáticamente por Intlayer:
|
|
|
102
153
|
.intlayer
|
|
103
154
|
```
|
|
104
155
|
|
|
105
|
-
Estos archivos pueden
|
|
156
|
+
Estos archivos pueden regenerarse durante su proceso de compilación y no necesitan ser comprometidos en el control de versiones.
|
|
106
157
|
|
|
107
158
|
### Extensión de VS Code
|
|
108
159
|
|
|
109
|
-
Para mejorar la experiencia del desarrollador,
|
|
160
|
+
Para mejorar la experiencia del desarrollador, instale la **Extensión oficial de Intlayer para VS Code**:
|
|
110
161
|
|
|
111
162
|
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|