@intlayer/docs 7.3.1 → 7.3.2-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/blog/ar/compiler_vs_declarative_i18n.md +1 -2
- package/blog/ar/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/de/compiler_vs_declarative_i18n.md +1 -2
- package/blog/de/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/en/compiler_vs_declarative_i18n.md +1 -2
- package/blog/en/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/en/list_i18n_technologies/frameworks/svelte.md +19 -3
- package/blog/en/list_i18n_technologies/frameworks/vue.md +16 -2
- package/blog/en-GB/compiler_vs_declarative_i18n.md +1 -2
- package/blog/en-GB/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/es/compiler_vs_declarative_i18n.md +1 -2
- package/blog/es/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/fr/compiler_vs_declarative_i18n.md +1 -2
- package/blog/fr/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/hi/compiler_vs_declarative_i18n.md +1 -2
- package/blog/hi/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/id/compiler_vs_declarative_i18n.md +1 -2
- package/blog/id/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/it/compiler_vs_declarative_i18n.md +1 -2
- package/blog/it/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/ja/compiler_vs_declarative_i18n.md +1 -2
- package/blog/ja/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/ko/compiler_vs_declarative_i18n.md +1 -2
- package/blog/ko/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/pl/compiler_vs_declarative_i18n.md +1 -2
- package/blog/pl/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/pt/compiler_vs_declarative_i18n.md +1 -2
- package/blog/pt/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/ru/compiler_vs_declarative_i18n.md +1 -2
- package/blog/ru/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/tr/compiler_vs_declarative_i18n.md +1 -2
- package/blog/tr/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/vi/compiler_vs_declarative_i18n.md +1 -2
- package/blog/vi/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/blog/zh/compiler_vs_declarative_i18n.md +1 -2
- package/blog/zh/list_i18n_technologies/frameworks/flutter.md +0 -22
- package/dist/cjs/generated/docs.entry.cjs +19 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +19 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/bundle_optimization.md +6 -2
- package/docs/ar/compiler.md +133 -0
- package/docs/de/bundle_optimization.md +6 -2
- package/docs/de/compiler.md +133 -0
- package/docs/en/bundle_optimization.md +6 -2
- package/docs/en/compiler.md +133 -0
- package/docs/en-GB/bundle_optimization.md +6 -2
- package/docs/en-GB/compiler.md +133 -0
- package/docs/es/bundle_optimization.md +6 -2
- package/docs/es/compiler.md +133 -0
- package/docs/fr/bundle_optimization.md +6 -2
- package/docs/fr/compiler.md +133 -0
- package/docs/hi/bundle_optimization.md +6 -2
- package/docs/hi/compiler.md +133 -0
- package/docs/id/bundle_optimization.md +6 -2
- package/docs/id/compiler.md +133 -0
- package/docs/it/bundle_optimization.md +6 -2
- package/docs/it/compiler.md +133 -0
- package/docs/ja/bundle_optimization.md +6 -2
- package/docs/ja/compiler.md +133 -0
- package/docs/ko/bundle_optimization.md +6 -2
- package/docs/ko/compiler.md +133 -0
- package/docs/pl/bundle_optimization.md +6 -2
- package/docs/pl/compiler.md +133 -0
- package/docs/pt/bundle_optimization.md +6 -2
- package/docs/pt/compiler.md +133 -0
- package/docs/ru/bundle_optimization.md +6 -2
- package/docs/ru/compiler.md +133 -0
- package/docs/tr/bundle_optimization.md +6 -2
- package/docs/tr/compiler.md +133 -0
- package/docs/vi/bundle_optimization.md +6 -2
- package/docs/vi/compiler.md +133 -0
- package/docs/zh/bundle_optimization.md +6 -2
- package/docs/zh/compiler.md +133 -0
- package/package.json +8 -7
- package/src/generated/docs.entry.ts +19 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-09-09
|
|
3
|
+
updatedAt: 2025-09-09
|
|
4
|
+
title: Intlayer Compiler | Extracción Automática de Contenido para i18n
|
|
5
|
+
description: Automatiza tu proceso de internacionalización con el Intlayer Compiler. Extrae contenido directamente de tus componentes para una i18n más rápida y eficiente en Vite, Next.js y más.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- Compiler
|
|
9
|
+
- Internacionalización
|
|
10
|
+
- i18n
|
|
11
|
+
- Automatización
|
|
12
|
+
- Extracción
|
|
13
|
+
- Velocidad
|
|
14
|
+
- Vite
|
|
15
|
+
- Next.js
|
|
16
|
+
- React
|
|
17
|
+
- Vue
|
|
18
|
+
- Svelte
|
|
19
|
+
slugs:
|
|
20
|
+
- doc
|
|
21
|
+
- compiler
|
|
22
|
+
history:
|
|
23
|
+
- version: 7.3.1
|
|
24
|
+
date: 2025-11-27
|
|
25
|
+
changes: Lanzamiento del Compiler
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Intlayer Compiler | Extracción Automática de Contenido para i18n
|
|
29
|
+
|
|
30
|
+
## ¿Qué es el Intlayer Compiler?
|
|
31
|
+
|
|
32
|
+
El **Intlayer Compiler** es una herramienta poderosa diseñada para automatizar el proceso de internacionalización (i18n) en tus aplicaciones. Escanea tu código fuente (JSX, TSX, Vue, Svelte) en busca de declaraciones de contenido, las extrae y genera automáticamente los archivos de diccionario necesarios. Esto te permite mantener tu contenido junto a tus componentes mientras Intlayer se encarga de la gestión y sincronización de tus diccionarios.
|
|
33
|
+
|
|
34
|
+
## ¿Por qué usar el Intlayer Compiler?
|
|
35
|
+
|
|
36
|
+
- **Automatización**: Elimina el copiado manual de contenido en los diccionarios.
|
|
37
|
+
- **Velocidad**: Extracción de contenido optimizada que asegura que tu proceso de build siga siendo rápido.
|
|
38
|
+
- **Experiencia del desarrollador**: Mantén las declaraciones de contenido justo donde se usan, mejorando la mantenibilidad.
|
|
39
|
+
- **Actualizaciones en vivo**: Soporta Hot Module Replacement (HMR) para retroalimentación instantánea durante el desarrollo.
|
|
40
|
+
|
|
41
|
+
Consulta el artículo del blog [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/es/compiler_vs_declarative_i18n.md) para una comparación más profunda.
|
|
42
|
+
|
|
43
|
+
## ¿Por qué no usar el Intlayer Compiler?
|
|
44
|
+
|
|
45
|
+
Si bien el compilador ofrece una excelente experiencia de "funciona sin más", también introduce algunos compromisos de los que debes ser consciente:
|
|
46
|
+
|
|
47
|
+
- **Ambigüedad heurística**: El compilador debe adivinar qué es contenido orientado al usuario frente a la lógica de la aplicación (por ejemplo, `className="active"`, códigos de estado, IDs de productos). En bases de código complejas, esto puede llevar a falsos positivos o cadenas omitidas que requieren anotaciones manuales y excepciones.
|
|
48
|
+
- **Extracción solo estática**: La extracción basada en compilador se basa en análisis estático. Las cadenas que solo existen en tiempo de ejecución (códigos de error de API, campos CMS, etc.) no pueden ser descubiertas o traducidas por el compilador solo, por lo que aún necesitas una estrategia i18n de tiempo de ejecución complementaria.
|
|
49
|
+
|
|
50
|
+
Para una comparación arquitectónica más profunda, consulta el artículo del blog [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/es/compiler_vs_declarative_i18n.md).
|
|
51
|
+
|
|
52
|
+
Como alternativa, para automatizar tu proceso i18n mientras mantienes el control total de tu contenido, Intlayer también proporciona un comando de auto-extracción `intlayer transform` (consulta la [documentación CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/cli/transform.md)), o el comando `Intlayer: extract content to Dictionary` de la extensión Intlayer VS Code (consulta la [documentación de la extensión VS Code](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/vs_code_extension.md)).
|
|
53
|
+
|
|
54
|
+
## Uso
|
|
55
|
+
|
|
56
|
+
### Vite
|
|
57
|
+
|
|
58
|
+
Para aplicaciones basadas en Vite (React, Vue, Svelte, etc.), la forma más sencilla de usar el compilador es a través del plugin `vite-intlayer`.
|
|
59
|
+
|
|
60
|
+
#### Instalación
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install vite-intlayer
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Configuración
|
|
67
|
+
|
|
68
|
+
Actualiza tu `vite.config.ts` para incluir el plugin `intlayerCompiler`:
|
|
69
|
+
|
|
70
|
+
```ts fileName="vite.config.ts"
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
import { intlayer, intlayerCompiler } from "vite-intlayer";
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [
|
|
76
|
+
intlayer(),
|
|
77
|
+
intlayerCompiler(), // Añade el plugin del compilador
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Soporte de Framework
|
|
83
|
+
|
|
84
|
+
El plugin de Vite detecta y maneja automáticamente diferentes tipos de archivos:
|
|
85
|
+
|
|
86
|
+
- **React / JSX / TSX**: Manejado de forma nativa.
|
|
87
|
+
- **Vue**: Requiere `@intlayer/vue-compiler`.
|
|
88
|
+
- **Svelte**: Requiere `@intlayer/svelte-compiler`.
|
|
89
|
+
|
|
90
|
+
Asegúrate de instalar el paquete de compilador adecuado para tu framework:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Para Vue
|
|
94
|
+
npm install @intlayer/vue-compiler
|
|
95
|
+
|
|
96
|
+
# Para Svelte
|
|
97
|
+
npm install @intlayer/svelte-compiler
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Next.js (Babel)
|
|
101
|
+
|
|
102
|
+
Para Next.js u otras aplicaciones basadas en Webpack que usan Babel, puedes configurar el compilador usando el plugin `@intlayer/babel`.
|
|
103
|
+
|
|
104
|
+
#### Instalación
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install @intlayer/babel
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Configuración
|
|
111
|
+
|
|
112
|
+
Actualiza tu `babel.config.js` (o `babel.config.json`) para incluir el plugin de extracción. Proporcionamos un helper `getExtractPluginOptions` para cargar automáticamente tu configuración de Intlayer.
|
|
113
|
+
|
|
114
|
+
```js fileName="babel.config.js"
|
|
115
|
+
const {
|
|
116
|
+
intlayerExtractBabelPlugin,
|
|
117
|
+
intlayerOptimizeBabelPlugin,
|
|
118
|
+
getExtractPluginOptions,
|
|
119
|
+
getOptimizePluginOptions,
|
|
120
|
+
} = require("@intlayer/babel");
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
presets: ["next/babel"],
|
|
124
|
+
plugins: [
|
|
125
|
+
// Extract content from components into dictionaries
|
|
126
|
+
[intlayerExtractBabelPlugin, getExtractPluginOptions()],
|
|
127
|
+
// Optimize imports by replacing useIntlayer with direct dictionary imports
|
|
128
|
+
[intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Esta configuración asegura que el contenido declarado en tus componentes se extraiga automáticamente y se utilice para generar diccionarios durante tu proceso de compilación.
|
|
@@ -153,9 +153,13 @@ const content = useIntlayer("my-key");
|
|
|
153
153
|
// Code optimisé (Dynamique)
|
|
154
154
|
const content = useDictionaryAsync({
|
|
155
155
|
en: () =>
|
|
156
|
-
import(".intlayer/dynamic_dictionary/en.json").then(
|
|
156
|
+
import(".intlayer/dynamic_dictionary/my-key/en.json").then(
|
|
157
|
+
(mod) => mod.default
|
|
158
|
+
),
|
|
157
159
|
fr: () =>
|
|
158
|
-
import(".intlayer/dynamic_dictionary/fr.json").then(
|
|
160
|
+
import(".intlayer/dynamic_dictionary/my-key/fr.json").then(
|
|
161
|
+
(mod) => mod.default
|
|
162
|
+
),
|
|
159
163
|
});
|
|
160
164
|
```
|
|
161
165
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-09-09
|
|
3
|
+
updatedAt: 2025-09-09
|
|
4
|
+
title: Intlayer Compiler | Extraction Automatisée de Contenu pour i18n
|
|
5
|
+
description: Automatisez votre processus d'internationalisation avec l'Intlayer Compiler. Extrayez le contenu directement de vos composants pour une i18n plus rapide et plus efficace dans Vite, Next.js, et plus encore.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- Compiler
|
|
9
|
+
- Internationalisation
|
|
10
|
+
- i18n
|
|
11
|
+
- Automatisation
|
|
12
|
+
- Extraction
|
|
13
|
+
- Rapidité
|
|
14
|
+
- Vite
|
|
15
|
+
- Next.js
|
|
16
|
+
- React
|
|
17
|
+
- Vue
|
|
18
|
+
- Svelte
|
|
19
|
+
slugs:
|
|
20
|
+
- doc
|
|
21
|
+
- compiler
|
|
22
|
+
history:
|
|
23
|
+
- version: 7.3.1
|
|
24
|
+
date: 2025-11-27
|
|
25
|
+
changes: Sortie du Compiler
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Intlayer Compiler | Extraction Automatisée de Contenu pour i18n
|
|
29
|
+
|
|
30
|
+
## Qu'est-ce que l'Intlayer Compiler ?
|
|
31
|
+
|
|
32
|
+
Le **Intlayer Compiler** est un outil puissant conçu pour automatiser le processus d'internationalisation (i18n) dans vos applications. Il analyse votre code source (JSX, TSX, Vue, Svelte) à la recherche de déclarations de contenu, les extrait, et génère automatiquement les fichiers de dictionnaire nécessaires. Cela vous permet de garder votre contenu localisé avec vos composants tandis qu'Intlayer gère la gestion et la synchronisation de vos dictionnaires.
|
|
33
|
+
|
|
34
|
+
## Pourquoi utiliser le Intlayer Compiler ?
|
|
35
|
+
|
|
36
|
+
- **Automatisation** : Élimine le copier-coller manuel du contenu dans les dictionnaires.
|
|
37
|
+
- **Rapidité** : Extraction de contenu optimisée garantissant que votre processus de build reste rapide.
|
|
38
|
+
- **Expérience développeur** : Gardez les déclarations de contenu là où elles sont utilisées, améliorant ainsi la maintenabilité.
|
|
39
|
+
- **Mises à jour en direct** : Prend en charge le Hot Module Replacement (HMR) pour un retour instantané pendant le développement.
|
|
40
|
+
|
|
41
|
+
Consultez l'article de blog [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/fr/compiler_vs_declarative_i18n.md) pour une comparaison plus approfondie.
|
|
42
|
+
|
|
43
|
+
## Pourquoi ne pas utiliser l'Intlayer Compiler ?
|
|
44
|
+
|
|
45
|
+
Bien que le compilateur offre une excellente expérience "fonctionne tout seul", il introduit également certains compromis dont vous devez être conscient :
|
|
46
|
+
|
|
47
|
+
- **Ambiguïté heuristique** : Le compilateur doit deviner ce qui est du contenu destiné aux utilisateurs par rapport à la logique de l'application (par exemple, `className="active"`, codes de statut, identifiants de produits). Dans des bases de code complexes, cela peut conduire à de faux positifs ou à des chaînes manquées qui nécessitent des annotations manuelles et des exceptions.
|
|
48
|
+
- **Extraction statique uniquement** : L'extraction basée sur le compilateur repose sur l'analyse statique. Les chaînes qui n'existent qu'à l'exécution (codes d'erreur API, champs CMS, etc.) ne peuvent pas être découvertes ou traduites par le compilateur seul, vous avez donc toujours besoin d'une stratégie i18n d'exécution complémentaire.
|
|
49
|
+
|
|
50
|
+
Pour une comparaison architecturale plus approfondie, consultez l'article de blog [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/fr/compiler_vs_declarative_i18n.md).
|
|
51
|
+
|
|
52
|
+
Comme alternative, pour automatiser votre processus i18n tout en gardant un contrôle total de votre contenu, Intlayer fournit également une commande d'auto-extraction `intlayer transform` (voir la [documentation CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/transform.md)), ou la commande `Intlayer: extract content to Dictionary` de l'extension Intlayer VS Code (voir la [documentation de l'extension VS Code](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/vs_code_extension.md)).
|
|
53
|
+
|
|
54
|
+
## Utilisation
|
|
55
|
+
|
|
56
|
+
### Vite
|
|
57
|
+
|
|
58
|
+
Pour les applications basées sur Vite (React, Vue, Svelte, etc.), la manière la plus simple d'utiliser le compilateur est via le plugin `vite-intlayer`.
|
|
59
|
+
|
|
60
|
+
#### Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install vite-intlayer
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Configuration
|
|
67
|
+
|
|
68
|
+
Mettez à jour votre `vite.config.ts` pour inclure le plugin `intlayerCompiler` :
|
|
69
|
+
|
|
70
|
+
```ts fileName="vite.config.ts"
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
import { intlayer, intlayerCompiler } from "vite-intlayer";
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [
|
|
76
|
+
intlayer(),
|
|
77
|
+
intlayerCompiler(), // Ajoute le plugin du compilateur
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Support des frameworks
|
|
83
|
+
|
|
84
|
+
Le plugin Vite détecte et gère automatiquement différents types de fichiers :
|
|
85
|
+
|
|
86
|
+
- **React / JSX / TSX** : Pris en charge nativement.
|
|
87
|
+
- **Vue** : Nécessite `@intlayer/vue-compiler`.
|
|
88
|
+
- **Svelte** : Nécessite `@intlayer/svelte-compiler`.
|
|
89
|
+
|
|
90
|
+
Assurez-vous d'installer le paquet compilateur approprié pour votre framework :
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Pour Vue
|
|
94
|
+
npm install @intlayer/vue-compiler
|
|
95
|
+
|
|
96
|
+
# Pour Svelte
|
|
97
|
+
npm install @intlayer/svelte-compiler
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Next.js (Babel)
|
|
101
|
+
|
|
102
|
+
Pour Next.js ou d'autres applications basées sur Webpack utilisant Babel, vous pouvez configurer le compilateur en utilisant le plugin `@intlayer/babel`.
|
|
103
|
+
|
|
104
|
+
#### Installation
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install @intlayer/babel
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Configuration
|
|
111
|
+
|
|
112
|
+
Mettez à jour votre fichier `babel.config.js` (ou `babel.config.json`) pour inclure le plugin d'extraction. Nous fournissons un helper `getExtractPluginOptions` pour charger automatiquement votre configuration Intlayer.
|
|
113
|
+
|
|
114
|
+
```js fileName="babel.config.js"
|
|
115
|
+
const {
|
|
116
|
+
intlayerExtractBabelPlugin,
|
|
117
|
+
intlayerOptimizeBabelPlugin,
|
|
118
|
+
getExtractPluginOptions,
|
|
119
|
+
getOptimizePluginOptions,
|
|
120
|
+
} = require("@intlayer/babel");
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
presets: ["next/babel"],
|
|
124
|
+
plugins: [
|
|
125
|
+
// Extract content from components into dictionaries
|
|
126
|
+
[intlayerExtractBabelPlugin, getExtractPluginOptions()],
|
|
127
|
+
// Optimize imports by replacing useIntlayer with direct dictionary imports
|
|
128
|
+
[intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Cette configuration garantit que le contenu déclaré dans vos composants est automatiquement extrait et utilisé pour générer les dictionnaires lors de votre processus de build.
|
|
@@ -153,9 +153,13 @@ const content = useIntlayer("my-key");
|
|
|
153
153
|
// अनुकूलित कोड (डायनामिक)
|
|
154
154
|
const content = useDictionaryAsync({
|
|
155
155
|
en: () =>
|
|
156
|
-
import(".intlayer/dynamic_dictionary/en.json").then(
|
|
156
|
+
import(".intlayer/dynamic_dictionary/my-key/en.json").then(
|
|
157
|
+
(mod) => mod.default
|
|
158
|
+
),
|
|
157
159
|
fr: () =>
|
|
158
|
-
import(".intlayer/dynamic_dictionary/fr.json").then(
|
|
160
|
+
import(".intlayer/dynamic_dictionary/my-key/fr.json").then(
|
|
161
|
+
(mod) => mod.default
|
|
162
|
+
),
|
|
159
163
|
});
|
|
160
164
|
```
|
|
161
165
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-09-09
|
|
3
|
+
updatedAt: 2025-09-09
|
|
4
|
+
title: Intlayer Compiler | i18n के लिए स्वचालित सामग्री निष्कर्षण
|
|
5
|
+
description: Intlayer Compiler के साथ अपने अंतरराष्ट्रीयकरण प्रक्रिया को स्वचालित करें। Vite, Next.js, और अन्य में तेज़, अधिक कुशल i18n के लिए सीधे अपने कंपोनेंट्स से सामग्री निकालें।
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- Compiler
|
|
9
|
+
- Internationalization
|
|
10
|
+
- i18n
|
|
11
|
+
- Automation
|
|
12
|
+
- Extraction
|
|
13
|
+
- Speed
|
|
14
|
+
- Vite
|
|
15
|
+
- Next.js
|
|
16
|
+
- React
|
|
17
|
+
- Vue
|
|
18
|
+
- Svelte
|
|
19
|
+
slugs:
|
|
20
|
+
- doc
|
|
21
|
+
- compiler
|
|
22
|
+
history:
|
|
23
|
+
- version: 7.3.1
|
|
24
|
+
date: 2025-11-27
|
|
25
|
+
changes: Release Compiler
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Intlayer Compiler | i18n के लिए स्वचालित सामग्री निष्कर्षण
|
|
29
|
+
|
|
30
|
+
## Intlayer Compiler क्या है?
|
|
31
|
+
|
|
32
|
+
**Intlayer Compiler** एक शक्तिशाली उपकरण है जिसे आपके एप्लिकेशन में अंतरराष्ट्रीयकरण (i18n) की प्रक्रिया को स्वचालित करने के लिए डिज़ाइन किया गया है। यह आपके स्रोत कोड (JSX, TSX, Vue, Svelte) में सामग्री घोषणाओं को स्कैन करता है, उन्हें निकालता है, और आवश्यक शब्दकोश फ़ाइलों को स्वचालित रूप से उत्पन्न करता है। यह आपको अपनी सामग्री को आपके कंपोनेंट्स के साथ सह-स्थित रखने की अनुमति देता है जबकि Intlayer आपके शब्दकोशों के प्रबंधन और समन्वय को संभालता है।
|
|
33
|
+
|
|
34
|
+
## Intlayer Compiler का उपयोग क्यों करें?
|
|
35
|
+
|
|
36
|
+
- **स्वचालन**: सामग्री को शब्दकोशों में मैन्युअल कॉपी-पेस्ट करने की आवश्यकता समाप्त करता है।
|
|
37
|
+
- **गति**: अनुकूलित सामग्री निष्कर्षण सुनिश्चित करता है कि आपका बिल्ड प्रक्रिया तेज़ बनी रहे।
|
|
38
|
+
- **डेवलपर अनुभव**: सामग्री घोषणाओं को वहीं रखें जहां उनका उपयोग होता है, जिससे रखरखाव में सुधार होता है।
|
|
39
|
+
- **लाइव अपडेट्स**: विकास के दौरान त्वरित प्रतिक्रिया के लिए Hot Module Replacement (HMR) का समर्थन करता है।
|
|
40
|
+
|
|
41
|
+
गहरे तुलना के लिए [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/compiler_vs_declarative_i18n.md) ब्लॉग पोस्ट देखें।
|
|
42
|
+
|
|
43
|
+
## Intlayer Compiler का उपयोग क्यों न करें?
|
|
44
|
+
|
|
45
|
+
हालांकि कंपाइलर एक उत्कृष्ट "बस काम करता है" अनुभव प्रदान करता है, यह कुछ समझौते भी पेश करता है जिनके बारे में आपको पता होना चाहिए:
|
|
46
|
+
|
|
47
|
+
- **हेयूरिस्टिक अस्पष्टता**: कंपाइलर को यह अनुमान लगाना होगा कि उपयोगकर्ता-सामना करने वाली सामग्री बनाम एप्लिकेशन लॉजिक क्या है (उदाहरण के लिए, `className="active"`, स्थिति कोड, उत्पाद ID)। जटिल कोडबेस में, यह गलत सकारात्मक या छूटी हुई स्ट्रिंग्स का कारण बन सकता है जिन्हें मैन्युअल एनोटेशन और अपवादों की आवश्यकता होती है।
|
|
48
|
+
- **केवल स्थैतिक निष्कर्षण**: कंपाइलर-आधारित निष्कर्षण स्थैतिक विश्लेषण पर निर्भर करता है। स्ट्रिंग्स जो केवल रनटाइम पर मौजूद होती हैं (API त्रुटि कोड, CMS फ़ील्ड, आदि) को कंपाइलर द्वारा अकेले खोजा या अनुवादित नहीं किया जा सकता है, इसलिए आपको अभी भी एक पूरक रनटाइम i18n रणनीति की आवश्यकता है।
|
|
49
|
+
|
|
50
|
+
गहरी वास्तुकला तुलना के लिए, [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/compiler_vs_declarative_i18n.md) ब्लॉग पोस्ट देखें।
|
|
51
|
+
|
|
52
|
+
वैकल्पिक रूप से, अपनी सामग्री पर पूर्ण नियंत्रण रखते हुए अपनी i18n प्रक्रिया को स्वचालित करने के लिए, Intlayer एक स्वचालित निष्कर्षण कमांड `intlayer transform` (देखें [CLI दस्तावेज़ीकरण](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/cli/transform.md)) या Intlayer VS Code एक्सटेंशन का `Intlayer: extract content to Dictionary` कमांड (देखें [VS Code एक्सटेंशन दस्तावेज़ीकरण](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/vs_code_extension.md)) भी प्रदान करता है।
|
|
53
|
+
|
|
54
|
+
## उपयोग
|
|
55
|
+
|
|
56
|
+
### Vite
|
|
57
|
+
|
|
58
|
+
Vite-आधारित एप्लिकेशन (React, Vue, Svelte, आदि) के लिए, कंपाइलर का उपयोग करने का सबसे आसान तरीका `vite-intlayer` प्लगइन के माध्यम से है।
|
|
59
|
+
|
|
60
|
+
#### स्थापना
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install vite-intlayer
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### कॉन्फ़िगरेशन
|
|
67
|
+
|
|
68
|
+
अपने `vite.config.ts` को अपडेट करें ताकि `intlayerCompiler` प्लगइन शामिल हो:
|
|
69
|
+
|
|
70
|
+
```ts fileName="vite.config.ts"
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
import { intlayer, intlayerCompiler } from "vite-intlayer";
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [
|
|
76
|
+
intlayer(),
|
|
77
|
+
intlayerCompiler(), // कंपाइलर प्लगइन जोड़ता है
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### फ्रेमवर्क समर्थन
|
|
83
|
+
|
|
84
|
+
Vite प्लगइन स्वचालित रूप से विभिन्न फ़ाइल प्रकारों का पता लगाता है और उन्हें संभालता है:
|
|
85
|
+
|
|
86
|
+
- **React / JSX / TSX**: मूल रूप से संभाला जाता है।
|
|
87
|
+
- **Vue**: इसके लिए `@intlayer/vue-compiler` आवश्यक है।
|
|
88
|
+
- **Svelte**: इसके लिए `@intlayer/svelte-compiler` आवश्यक है।
|
|
89
|
+
|
|
90
|
+
सुनिश्चित करें कि आपने अपने फ्रेमवर्क के लिए उपयुक्त कंपाइलर पैकेज इंस्टॉल किया है:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Vue के लिए
|
|
94
|
+
npm install @intlayer/vue-compiler
|
|
95
|
+
|
|
96
|
+
# Svelte के लिए
|
|
97
|
+
npm install @intlayer/svelte-compiler
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Next.js (Babel)
|
|
101
|
+
|
|
102
|
+
Next.js या अन्य Webpack-आधारित एप्लिकेशन जो Babel का उपयोग करते हैं, उनके लिए आप `@intlayer/babel` प्लगइन का उपयोग करके कंपाइलर को कॉन्फ़िगर कर सकते हैं।
|
|
103
|
+
|
|
104
|
+
#### स्थापना
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install @intlayer/babel
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### कॉन्फ़िगरेशन
|
|
111
|
+
|
|
112
|
+
अपना `babel.config.js` (या `babel.config.json`) अपडेट करें ताकि extraction प्लगइन शामिल हो सके। हम एक हेल्पर `getExtractPluginOptions` प्रदान करते हैं जो आपके Intlayer कॉन्फ़िगरेशन को स्वचालित रूप से लोड करता है।
|
|
113
|
+
|
|
114
|
+
```js fileName="babel.config.js"
|
|
115
|
+
const {
|
|
116
|
+
intlayerExtractBabelPlugin,
|
|
117
|
+
intlayerOptimizeBabelPlugin,
|
|
118
|
+
getExtractPluginOptions,
|
|
119
|
+
getOptimizePluginOptions,
|
|
120
|
+
} = require("@intlayer/babel");
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
presets: ["next/babel"],
|
|
124
|
+
plugins: [
|
|
125
|
+
// Extract content from components into dictionaries
|
|
126
|
+
[intlayerExtractBabelPlugin, getExtractPluginOptions()],
|
|
127
|
+
// Optimize imports by replacing useIntlayer with direct dictionary imports
|
|
128
|
+
[intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
यह कॉन्फ़िगरेशन सुनिश्चित करता है कि आपके कंपोनेंट्स में घोषित सामग्री स्वचालित रूप से निकाली जाए और आपके बिल्ड प्रक्रिया के दौरान शब्दकोश बनाने के लिए उपयोग की जाए।
|
|
@@ -153,9 +153,13 @@ const content = useIntlayer("my-key");
|
|
|
153
153
|
// Kode yang Dioptimalkan (Dinamis)
|
|
154
154
|
const content = useDictionaryAsync({
|
|
155
155
|
en: () =>
|
|
156
|
-
import(".intlayer/dynamic_dictionary/en.json").then(
|
|
156
|
+
import(".intlayer/dynamic_dictionary/my-key/en.json").then(
|
|
157
|
+
(mod) => mod.default
|
|
158
|
+
),
|
|
157
159
|
fr: () =>
|
|
158
|
-
import(".intlayer/dynamic_dictionary/fr.json").then(
|
|
160
|
+
import(".intlayer/dynamic_dictionary/my-key/fr.json").then(
|
|
161
|
+
(mod) => mod.default
|
|
162
|
+
),
|
|
159
163
|
});
|
|
160
164
|
```
|
|
161
165
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-09-09
|
|
3
|
+
updatedAt: 2025-09-09
|
|
4
|
+
title: Intlayer Compiler | Ekstraksi Konten Otomatis untuk i18n
|
|
5
|
+
description: Otomatiskan proses internasionalisasi Anda dengan Intlayer Compiler. Ekstrak konten langsung dari komponen Anda untuk i18n yang lebih cepat dan efisien di Vite, Next.js, dan lainnya.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- Compiler
|
|
9
|
+
- Internasionalisasi
|
|
10
|
+
- i18n
|
|
11
|
+
- Otomatisasi
|
|
12
|
+
- Ekstraksi
|
|
13
|
+
- Kecepatan
|
|
14
|
+
- Vite
|
|
15
|
+
- Next.js
|
|
16
|
+
- React
|
|
17
|
+
- Vue
|
|
18
|
+
- Svelte
|
|
19
|
+
slugs:
|
|
20
|
+
- doc
|
|
21
|
+
- compiler
|
|
22
|
+
history:
|
|
23
|
+
- version: 7.3.1
|
|
24
|
+
date: 2025-11-27
|
|
25
|
+
changes: Rilis Compiler
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Intlayer Compiler | Ekstraksi Konten Otomatis untuk i18n
|
|
29
|
+
|
|
30
|
+
## Apa itu Intlayer Compiler?
|
|
31
|
+
|
|
32
|
+
**Intlayer Compiler** adalah alat yang kuat yang dirancang untuk mengotomatisasi proses internasionalisasi (i18n) dalam aplikasi Anda. Alat ini memindai kode sumber Anda (JSX, TSX, Vue, Svelte) untuk deklarasi konten, mengekstraknya, dan secara otomatis menghasilkan file kamus yang diperlukan. Ini memungkinkan Anda untuk menjaga konten tetap berdekatan dengan komponen Anda sementara Intlayer menangani manajemen dan sinkronisasi kamus Anda.
|
|
33
|
+
|
|
34
|
+
## Mengapa Menggunakan Intlayer Compiler?
|
|
35
|
+
|
|
36
|
+
- **Otomatisasi**: Menghilangkan penyalinan konten secara manual ke dalam kamus.
|
|
37
|
+
- **Kecepatan**: Ekstraksi konten yang dioptimalkan memastikan proses build Anda tetap cepat.
|
|
38
|
+
- **Pengalaman Pengembang**: Menjaga deklarasi konten tepat di tempat mereka digunakan, meningkatkan pemeliharaan.
|
|
39
|
+
- **Pembaruan Langsung**: Mendukung Hot Module Replacement (HMR) untuk umpan balik instan selama pengembangan.
|
|
40
|
+
|
|
41
|
+
Lihat posting blog [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/id/compiler_vs_declarative_i18n.md) untuk perbandingan yang lebih mendalam.
|
|
42
|
+
|
|
43
|
+
## Mengapa Tidak Menggunakan Intlayer Compiler?
|
|
44
|
+
|
|
45
|
+
Meskipun compiler menawarkan pengalaman "langsung bekerja" yang sangat baik, compiler juga memperkenalkan beberapa kompromi yang harus Anda ketahui:
|
|
46
|
+
|
|
47
|
+
- **Ambiguitas heuristik**: Compiler harus menebak apa yang merupakan konten yang ditujukan untuk pengguna versus logika aplikasi (misalnya, `className="active"`, kode status, ID produk). Dalam codebase yang kompleks, ini dapat menyebabkan false positive atau string yang terlewat yang memerlukan anotasi manual dan pengecualian.
|
|
48
|
+
- **Ekstraksi hanya statis**: Ekstraksi berbasis compiler bergantung pada analisis statis. String yang hanya ada saat runtime (kode kesalahan API, field CMS, dll.) tidak dapat ditemukan atau diterjemahkan oleh compiler saja, jadi Anda masih memerlukan strategi i18n runtime yang melengkapi.
|
|
49
|
+
|
|
50
|
+
Untuk perbandingan arsitektur yang lebih mendalam, lihat posting blog [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/id/compiler_vs_declarative_i18n.md).
|
|
51
|
+
|
|
52
|
+
Sebagai alternatif, untuk mengotomatisasi proses i18n Anda sambil mempertahankan kontrol penuh atas konten Anda, Intlayer juga menyediakan perintah auto-ekstraksi `intlayer transform` (lihat [dokumentasi CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/cli/transform.md)), atau perintah `Intlayer: extract content to Dictionary` dari ekstensi Intlayer VS Code (lihat [dokumentasi ekstensi VS Code](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/vs_code_extension.md)).
|
|
53
|
+
|
|
54
|
+
## Penggunaan
|
|
55
|
+
|
|
56
|
+
### Vite
|
|
57
|
+
|
|
58
|
+
Untuk aplikasi berbasis Vite (React, Vue, Svelte, dll.), cara termudah menggunakan compiler adalah melalui plugin `vite-intlayer`.
|
|
59
|
+
|
|
60
|
+
#### Instalasi
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install vite-intlayer
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Konfigurasi
|
|
67
|
+
|
|
68
|
+
Perbarui `vite.config.ts` Anda untuk menyertakan plugin `intlayerCompiler`:
|
|
69
|
+
|
|
70
|
+
```ts fileName="vite.config.ts"
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
import { intlayer, intlayerCompiler } from "vite-intlayer";
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [
|
|
76
|
+
intlayer(),
|
|
77
|
+
intlayerCompiler(), // Menambahkan plugin compiler
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Dukungan Framework
|
|
83
|
+
|
|
84
|
+
Plugin Vite secara otomatis mendeteksi dan menangani berbagai jenis file:
|
|
85
|
+
|
|
86
|
+
- **React / JSX / TSX**: Ditangani secara native.
|
|
87
|
+
- **Vue**: Memerlukan `@intlayer/vue-compiler`.
|
|
88
|
+
- **Svelte**: Memerlukan `@intlayer/svelte-compiler`.
|
|
89
|
+
|
|
90
|
+
Pastikan untuk menginstal paket compiler yang sesuai untuk framework Anda:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Untuk Vue
|
|
94
|
+
npm install @intlayer/vue-compiler
|
|
95
|
+
|
|
96
|
+
# Untuk Svelte
|
|
97
|
+
npm install @intlayer/svelte-compiler
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Next.js (Babel)
|
|
101
|
+
|
|
102
|
+
Untuk Next.js atau aplikasi berbasis Webpack lainnya yang menggunakan Babel, Anda dapat mengonfigurasi compiler menggunakan plugin `@intlayer/babel`.
|
|
103
|
+
|
|
104
|
+
#### Instalasi
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install @intlayer/babel
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Konfigurasi
|
|
111
|
+
|
|
112
|
+
Perbarui `babel.config.js` Anda (atau `babel.config.json`) untuk menyertakan plugin ekstraksi. Kami menyediakan helper `getExtractPluginOptions` untuk memuat konfigurasi Intlayer Anda secara otomatis.
|
|
113
|
+
|
|
114
|
+
```js fileName="babel.config.js"
|
|
115
|
+
const {
|
|
116
|
+
intlayerExtractBabelPlugin,
|
|
117
|
+
intlayerOptimizeBabelPlugin,
|
|
118
|
+
getExtractPluginOptions,
|
|
119
|
+
getOptimizePluginOptions,
|
|
120
|
+
} = require("@intlayer/babel");
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
presets: ["next/babel"],
|
|
124
|
+
plugins: [
|
|
125
|
+
// Extract content from components into dictionaries
|
|
126
|
+
[intlayerExtractBabelPlugin, getExtractPluginOptions()],
|
|
127
|
+
// Optimize imports by replacing useIntlayer with direct dictionary imports
|
|
128
|
+
[intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Konfigurasi ini memastikan bahwa konten yang dideklarasikan dalam komponen Anda secara otomatis diekstraksi dan digunakan untuk menghasilkan kamus selama proses build Anda.
|
|
@@ -153,9 +153,13 @@ const content = useIntlayer("my-key");
|
|
|
153
153
|
// Codice ottimizzato (Dinamico)
|
|
154
154
|
const content = useDictionaryAsync({
|
|
155
155
|
en: () =>
|
|
156
|
-
import(".intlayer/dynamic_dictionary/en.json").then(
|
|
156
|
+
import(".intlayer/dynamic_dictionary/my-key/en.json").then(
|
|
157
|
+
(mod) => mod.default
|
|
158
|
+
),
|
|
157
159
|
fr: () =>
|
|
158
|
-
import(".intlayer/dynamic_dictionary/fr.json").then(
|
|
160
|
+
import(".intlayer/dynamic_dictionary/my-key/fr.json").then(
|
|
161
|
+
(mod) => mod.default
|
|
162
|
+
),
|
|
159
163
|
});
|
|
160
164
|
```
|
|
161
165
|
|