@intlayer/docs 7.3.11 → 7.3.13
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/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/intlayer_with_nuxt.md +294 -438
- package/docs/ar/intlayer_with_react_router_v7.md +33 -4
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/ar/intlayer_with_tanstack.md +2 -12
- package/docs/ar/intlayer_with_vite+vue.md +1 -0
- package/docs/de/intlayer_with_nuxt.md +284 -410
- package/docs/de/intlayer_with_react_router_v7.md +33 -4
- package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
- package/docs/de/intlayer_with_tanstack.md +1 -0
- package/docs/de/intlayer_with_vite+vue.md +1 -0
- package/docs/en/intlayer_with_nuxt.md +237 -341
- package/docs/en/intlayer_with_react_router_v7.md +24 -0
- package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
- package/docs/en/intlayer_with_tanstack.md +2 -12
- package/docs/en/intlayer_with_vite+vue.md +49 -48
- package/docs/en-GB/intlayer_with_nuxt.md +254 -378
- package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
- package/docs/en-GB/intlayer_with_tanstack.md +2 -12
- package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
- package/docs/es/intlayer_with_nuxt.md +271 -390
- package/docs/es/intlayer_with_react_router_v7.md +33 -4
- package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
- package/docs/es/intlayer_with_tanstack.md +1 -0
- package/docs/es/intlayer_with_vite+vue.md +1 -2
- package/docs/fr/intlayer_with_nuxt.md +278 -405
- package/docs/fr/intlayer_with_react_router_v7.md +34 -5
- package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/fr/intlayer_with_tanstack.md +1 -0
- package/docs/fr/intlayer_with_vite+vue.md +1 -0
- package/docs/hi/intlayer_with_nuxt.md +303 -447
- package/docs/hi/intlayer_with_react_router_v7.md +33 -4
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
- package/docs/hi/intlayer_with_tanstack.md +2 -12
- package/docs/hi/intlayer_with_vite+vue.md +1 -0
- package/docs/id/intlayer_with_nuxt.md +266 -395
- package/docs/id/intlayer_with_react_router_v7.md +29 -4
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
- package/docs/id/intlayer_with_tanstack.md +2 -12
- package/docs/id/intlayer_with_vite+vue.md +1 -0
- package/docs/it/intlayer_with_nuxt.md +299 -423
- package/docs/it/intlayer_with_react_router_v7.md +33 -4
- package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/it/intlayer_with_tanstack.md +1 -0
- package/docs/ja/intlayer_with_nuxt.md +309 -432
- package/docs/ja/intlayer_with_react_router_v7.md +33 -4
- package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ja/intlayer_with_tanstack.md +2 -12
- package/docs/ja/intlayer_with_vite+vue.md +1 -0
- package/docs/ko/intlayer_with_nuxt.md +295 -422
- package/docs/ko/intlayer_with_react_router_v7.md +33 -4
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
- package/docs/ko/intlayer_with_tanstack.md +2 -12
- package/docs/ko/intlayer_with_vite+vue.md +1 -0
- package/docs/pl/intlayer_with_nuxt.md +273 -476
- package/docs/pl/intlayer_with_react_router_v7.md +32 -5
- package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
- package/docs/pl/intlayer_with_tanstack.md +2 -12
- package/docs/pl/intlayer_with_vite+vue.md +1 -0
- package/docs/pt/intlayer_with_nuxt.md +277 -420
- package/docs/pt/intlayer_with_react_router_v7.md +28 -0
- package/docs/pt/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_nuxt.md +287 -425
- package/docs/ru/intlayer_with_react_router_v7.md +33 -4
- package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ru/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_vite+vue.md +1 -0
- package/docs/tr/intlayer_with_nuxt.md +313 -406
- package/docs/tr/intlayer_with_react_router_v7.md +33 -4
- package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
- package/docs/tr/intlayer_with_tanstack.md +2 -12
- package/docs/tr/intlayer_with_vite+vue.md +1 -0
- package/docs/vi/intlayer_with_nuxt.md +273 -418
- package/docs/vi/intlayer_with_react_router_v7.md +29 -4
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
- package/docs/vi/intlayer_with_tanstack.md +2 -12
- package/docs/vi/intlayer_with_vite+vue.md +1 -0
- package/docs/zh/intlayer_with_nuxt.md +300 -461
- package/docs/zh/intlayer_with_react_router_v7.md +33 -4
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/zh/intlayer_with_tanstack.md +2 -12
- package/docs/zh/intlayer_with_vite+vue.md +1 -0
- package/package.json +10 -11
- package/src/generated/docs.entry.ts +19 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-06-18
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: Cara
|
|
3
|
+
updatedAt: 2025-12-07
|
|
4
|
+
title: Cara Menerjemahkan Aplikasi Nuxt dan Vue Anda – Panduan i18n 2025
|
|
5
5
|
description: Temukan cara membuat situs web Nuxt dan Vue Anda menjadi multibahasa. Ikuti dokumentasi untuk melakukan internasionalisasi (i18n) dan menerjemahkannya.
|
|
6
6
|
keywords:
|
|
7
7
|
- Internasionalisasi
|
|
@@ -14,8 +14,12 @@ slugs:
|
|
|
14
14
|
- doc
|
|
15
15
|
- environment
|
|
16
16
|
- nuxt-and-vue
|
|
17
|
-
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-template
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-4-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=nhUcUAVQ6eQ
|
|
18
19
|
history:
|
|
20
|
+
- version: 7.3.11
|
|
21
|
+
date: 2025-12-07
|
|
22
|
+
changes: Memperbarui LocaleSwitcher, SEO, metadata
|
|
19
23
|
- version: 5.5.10
|
|
20
24
|
date: 2025-06-29
|
|
21
25
|
changes: Inisialisasi riwayat
|
|
@@ -23,38 +27,49 @@ history:
|
|
|
23
27
|
|
|
24
28
|
# Terjemahkan situs web Nuxt dan Vue Anda menggunakan Intlayer | Internasionalisasi (i18n)
|
|
25
29
|
|
|
26
|
-
Lihat [Application Template](https://github.com/aymericzip/intlayer-nuxt-template) di GitHub.
|
|
27
|
-
|
|
28
30
|
## Daftar Isi
|
|
29
31
|
|
|
30
32
|
<TOC/>
|
|
31
33
|
|
|
32
34
|
## Apa itu Intlayer?
|
|
33
35
|
|
|
34
|
-
**Intlayer** adalah pustaka internasionalisasi (i18n)
|
|
36
|
+
**Intlayer** adalah pustaka internasionalisasi (i18n) sumber terbuka yang inovatif, dirancang untuk menyederhanakan dukungan multibahasa dalam aplikasi web modern.
|
|
35
37
|
|
|
36
38
|
Dengan Intlayer, Anda dapat:
|
|
37
39
|
|
|
38
40
|
- **Mengelola terjemahan dengan mudah** menggunakan kamus deklaratif di tingkat komponen.
|
|
39
41
|
- **Melokalkan metadata**, rute, dan konten secara dinamis.
|
|
40
|
-
- **
|
|
41
|
-
- **Memanfaatkan fitur canggih**, seperti deteksi dan
|
|
42
|
+
- **Menjamin dukungan TypeScript** dengan tipe yang dihasilkan secara otomatis, meningkatkan autocompletion dan deteksi kesalahan.
|
|
43
|
+
- **Memanfaatkan fitur canggih**, seperti deteksi dan pengalihan locale secara dinamis.
|
|
42
44
|
|
|
43
45
|
---
|
|
44
46
|
|
|
45
|
-
## Panduan Langkah demi Langkah untuk Mengatur Intlayer
|
|
47
|
+
## Panduan Langkah demi Langkah untuk Mengatur Intlayer di Aplikasi Nuxt
|
|
48
|
+
|
|
49
|
+
<Tab defaultTab="video">
|
|
50
|
+
<TabItem label="Video" value="video">
|
|
51
|
+
|
|
52
|
+
<iframe title="Cara menerjemahkan aplikasi Nuxt dan Vue Anda menggunakan Intlayer? Temukan Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/nhUcUAVQ6eQ?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
53
|
+
|
|
54
|
+
</TabItem>
|
|
55
|
+
<TabItem label="Kode" value="code">
|
|
46
56
|
|
|
47
57
|
<iframe
|
|
48
|
-
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
58
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
49
59
|
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
50
60
|
title="Demo CodeSandbox - Cara Menginternasionalisasi aplikasi Anda menggunakan Intlayer"
|
|
51
61
|
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
52
62
|
loading="lazy"
|
|
53
63
|
/>
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
</TabItem>
|
|
66
|
+
</Tab>
|
|
67
|
+
|
|
68
|
+
Lihat [Template Aplikasi](https://github.com/aymericzip/intlayer-nuxt-4-template) di GitHub.
|
|
56
69
|
|
|
57
|
-
|
|
70
|
+
### Langkah 1: Pasang Dependensi
|
|
71
|
+
|
|
72
|
+
Pasang paket yang diperlukan menggunakan npm:
|
|
58
73
|
|
|
59
74
|
```bash packageManager="npm"
|
|
60
75
|
npm install intlayer vue-intlayer
|
|
@@ -73,12 +88,10 @@ yarn add --save-dev nuxt-intlayer
|
|
|
73
88
|
|
|
74
89
|
- **intlayer**
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Paket inti yang menyediakan alat internasionalisasi untuk manajemen konfigurasi, terjemahan, [deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md), transpile, dan [perintah CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_cli.md).
|
|
91
|
+
Paket inti yang menyediakan alat internasionalisasi untuk manajemen konfigurasi, terjemahan, [deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md), transpile, dan [perintah CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/cli/index.md).
|
|
79
92
|
|
|
80
93
|
- **vue-intlayer**
|
|
81
|
-
Paket yang mengintegrasikan Intlayer dengan aplikasi Vue. Ini
|
|
94
|
+
Paket yang mengintegrasikan Intlayer dengan aplikasi Vue. Ini adalah composables untuk komponen Vue.
|
|
82
95
|
|
|
83
96
|
- **nuxt-intlayer**
|
|
84
97
|
Modul Nuxt yang mengintegrasikan Intlayer dengan aplikasi Nuxt. Modul ini menyediakan pengaturan otomatis, middleware untuk deteksi locale, manajemen cookie, dan pengalihan URL.
|
|
@@ -100,9 +113,6 @@ const config: IntlayerConfig = {
|
|
|
100
113
|
],
|
|
101
114
|
defaultLocale: Locales.ENGLISH,
|
|
102
115
|
},
|
|
103
|
-
content: {
|
|
104
|
-
contentDir: ["."], // Karena secara default Intlayer akan memantau file deklarasi konten dari direktori `./src`
|
|
105
|
-
},
|
|
106
116
|
};
|
|
107
117
|
|
|
108
118
|
export default config;
|
|
@@ -111,6 +121,7 @@ export default config;
|
|
|
111
121
|
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
112
122
|
import { Locales } from "intlayer";
|
|
113
123
|
|
|
124
|
+
javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
114
125
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
115
126
|
const config = {
|
|
116
127
|
internationalization: {
|
|
@@ -122,9 +133,6 @@ const config = {
|
|
|
122
133
|
],
|
|
123
134
|
defaultLocale: Locales.ENGLISH,
|
|
124
135
|
},
|
|
125
|
-
content: {
|
|
126
|
-
contentDir: ["."],
|
|
127
|
-
},
|
|
128
136
|
};
|
|
129
137
|
|
|
130
138
|
export default config;
|
|
@@ -144,9 +152,6 @@ const config = {
|
|
|
144
152
|
],
|
|
145
153
|
defaultLocale: Locales.ENGLISH,
|
|
146
154
|
},
|
|
147
|
-
content: {
|
|
148
|
-
contentDir: ["."],
|
|
149
|
-
},
|
|
150
155
|
};
|
|
151
156
|
|
|
152
157
|
module.exports = config;
|
|
@@ -173,213 +178,40 @@ export default defineNuxtConfig({
|
|
|
173
178
|
|
|
174
179
|
Buat dan kelola deklarasi konten Anda untuk menyimpan terjemahan:
|
|
175
180
|
|
|
176
|
-
```tsx fileName="
|
|
177
|
-
import {
|
|
181
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
182
|
+
import { type Dictionary, t } from "intlayer";
|
|
178
183
|
|
|
179
|
-
const
|
|
180
|
-
key: "
|
|
184
|
+
const content = {
|
|
185
|
+
key: "home-page",
|
|
181
186
|
content: {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
187
|
-
}),
|
|
188
|
-
checkOut: t({ en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
|
|
189
|
-
nuxtIntlayer: t({
|
|
190
|
-
en: "Dokumentasi Nuxt Intlayer",
|
|
191
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
192
|
-
es: "Documentación de Nuxt Intlayer",
|
|
193
|
-
}),
|
|
194
|
-
learnMore: t({
|
|
195
|
-
en: "Pelajari lebih lanjut tentang Nuxt di ",
|
|
196
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
197
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
187
|
+
title: t({
|
|
188
|
+
en: "Hello world",
|
|
189
|
+
fr: "Bonjour le monde",
|
|
190
|
+
es: "Hola mundo",
|
|
198
191
|
}),
|
|
199
|
-
|
|
200
|
-
en: "
|
|
201
|
-
fr: "
|
|
202
|
-
es: "
|
|
192
|
+
metaTitle: t({
|
|
193
|
+
en: "Welcome | My Application",
|
|
194
|
+
fr: "Bienvenue | Mon Application",
|
|
195
|
+
es: "Bienvenido | Mi Aplicación",
|
|
203
196
|
}),
|
|
204
|
-
|
|
205
|
-
en: "
|
|
206
|
-
fr: "
|
|
207
|
-
es: "
|
|
208
|
-
id: "Klik logo Nuxt untuk mempelajari lebih lanjut",
|
|
197
|
+
metaDescription: t({
|
|
198
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
199
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
200
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
209
201
|
}),
|
|
210
202
|
},
|
|
211
203
|
} satisfies Dictionary;
|
|
212
204
|
|
|
213
|
-
export default
|
|
205
|
+
export default content;
|
|
214
206
|
```
|
|
215
207
|
|
|
216
|
-
|
|
217
|
-
import { t } from "intlayer";
|
|
208
|
+
> Deklarasi konten Anda dapat didefinisikan di mana saja dalam aplikasi Anda selama termasuk dalam direktori `contentDir` (secara default, `./src`). Dan sesuai dengan ekstensi file deklarasi konten (secara default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
218
209
|
|
|
219
|
-
|
|
220
|
-
const helloWorldContent = {
|
|
221
|
-
key: "helloworld",
|
|
222
|
-
content: {
|
|
223
|
-
count: t({
|
|
224
|
-
en: "count is ",
|
|
225
|
-
fr: "le compte est ",
|
|
226
|
-
es: "el recuento es ",
|
|
227
|
-
id: "jumlah adalah ",
|
|
228
|
-
}),
|
|
229
|
-
edit: t({
|
|
230
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
231
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
232
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
233
|
-
id: "Edit <code>components/HelloWorld.vue</code> dan simpan untuk menguji HMR",
|
|
234
|
-
}),
|
|
235
|
-
checkOut: t({
|
|
236
|
-
en: "Check out ",
|
|
237
|
-
fr: "Vérifiez ",
|
|
238
|
-
es: "Compruebe ",
|
|
239
|
-
id: "Periksa ",
|
|
240
|
-
}),
|
|
241
|
-
nuxtIntlayer: t({
|
|
242
|
-
en: "Nuxt Intlayer documentation",
|
|
243
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
244
|
-
es: "Documentación de Nuxt Intlayer",
|
|
245
|
-
id: "Dokumentasi Nuxt Intlayer",
|
|
246
|
-
}),
|
|
247
|
-
learnMore: t({
|
|
248
|
-
en: "Learn more about Nuxt in the ",
|
|
249
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
250
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
251
|
-
id: "Pelajari lebih lanjut tentang Nuxt di ",
|
|
252
|
-
}),
|
|
253
|
-
nuxtDocs: t({
|
|
254
|
-
en: "Nuxt Documentation",
|
|
255
|
-
fr: "Documentation Nuxt",
|
|
256
|
-
es: "Documentación de Nuxt",
|
|
257
|
-
id: "Dokumentasi Nuxt",
|
|
258
|
-
}),
|
|
259
|
-
readTheDocs: t({
|
|
260
|
-
en: "Click on the Nuxt logo to learn more",
|
|
261
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
262
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
263
|
-
id: "Klik logo Nuxt untuk mempelajari lebih lanjut",
|
|
264
|
-
}),
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export default helloWorldContent;
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
```javascript fileName="components/helloWorld.content.cjs" contentDeclarationFormat="commonjs"
|
|
272
|
-
const { t } = require("intlayer");
|
|
273
|
-
|
|
274
|
-
/** @type {import('intlayer').Dictionary} */
|
|
275
|
-
const helloWorldContent = {
|
|
276
|
-
key: "helloworld",
|
|
277
|
-
content: {
|
|
278
|
-
count: t({ en: "count is ", fr: "le compte est ", es: "el recuento es ", id: "jumlah adalah " }),
|
|
279
|
-
edit: t({
|
|
280
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
281
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
282
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
283
|
-
id: "Edit <code>components/HelloWorld.vue</code> dan simpan untuk menguji HMR",
|
|
284
|
-
}),
|
|
285
|
-
checkOut: t({ en: "Check out ", fr: "Vérifiez ", es: "Compruebe ", id: "Periksa " }),
|
|
286
|
-
nuxtIntlayer: t({
|
|
287
|
-
en: "Nuxt Intlayer documentation",
|
|
288
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
289
|
-
es: "Documentación de Nuxt Intlayer",
|
|
290
|
-
id: "Dokumentasi Nuxt Intlayer",
|
|
291
|
-
}),
|
|
292
|
-
es: "Dokumentasi Nuxt Intlayer",
|
|
293
|
-
}),
|
|
294
|
-
learnMore: t({
|
|
295
|
-
en: "Pelajari lebih lanjut tentang Nuxt di ",
|
|
296
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
297
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
298
|
-
}),
|
|
299
|
-
nuxtDocs: t({
|
|
300
|
-
en: "Dokumentasi Nuxt",
|
|
301
|
-
fr: "Documentation Nuxt",
|
|
302
|
-
es: "Documentación de Nuxt",
|
|
303
|
-
}),
|
|
304
|
-
readTheDocs: t({
|
|
305
|
-
en: "Klik logo Nuxt untuk mempelajari lebih lanjut",
|
|
306
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
307
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
308
|
-
}),
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
module.exports = helloWorldContent;
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
|
|
316
|
-
{
|
|
317
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
318
|
-
"key": "helloworld",
|
|
319
|
-
"content": {
|
|
320
|
-
"count": {
|
|
321
|
-
"nodeType": "translation",
|
|
322
|
-
"translation": {
|
|
323
|
-
"en": "count is ",
|
|
324
|
-
"fr": "le compte est ",
|
|
325
|
-
"es": "el recuento es ",
|
|
326
|
-
"id": "jumlahnya adalah "
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
"edit": {
|
|
330
|
-
"nodeType": "translation",
|
|
331
|
-
"translation": {
|
|
332
|
-
"en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
333
|
-
"fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
334
|
-
"es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
335
|
-
"id": "Edit <code>components/HelloWorld.vue</code> dan simpan untuk menguji HMR"
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
"checkOut": {
|
|
339
|
-
"nodeType": "translation",
|
|
340
|
-
"translation": {
|
|
341
|
-
"en": "Check out ",
|
|
342
|
-
"fr": "Vérifiez ",
|
|
343
|
-
"es": "Compruebe ",
|
|
344
|
-
"id": "Periksa "
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
"nuxtIntlayer": {
|
|
348
|
-
"nodeType": "translation",
|
|
349
|
-
"translation": {
|
|
350
|
-
"id": "Dokumentasi Nuxt Intlayer"
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
"learnMore": {
|
|
354
|
-
"nodeType": "translation",
|
|
355
|
-
"translation": {
|
|
356
|
-
"id": "Pelajari lebih lanjut tentang Nuxt di "
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
"nuxtDocs": {
|
|
360
|
-
"nodeType": "translation",
|
|
361
|
-
"translation": {
|
|
362
|
-
"id": "Dokumentasi Nuxt"
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
"readTheDocs": {
|
|
366
|
-
"nodeType": "translation",
|
|
367
|
-
"translation": {
|
|
368
|
-
"id": "Klik pada logo Nuxt untuk mempelajari lebih lanjut",
|
|
369
|
-
"id": "Klik pada logo Nuxt untuk mempelajari lebih lanjut"
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
> Deklarasi konten Anda dapat didefinisikan di mana saja dalam aplikasi Anda selama mereka termasuk dalam direktori `contentDir` (secara default, `./src`). Dan sesuai dengan ekstensi file deklarasi konten (secara default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
377
|
-
|
|
378
|
-
> Untuk detail lebih lanjut, lihat [dokumentasi deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
|
|
210
|
+
> Untuk informasi lebih lanjut, lihat [dokumentasi deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
|
|
379
211
|
|
|
380
212
|
### Langkah 5: Gunakan Intlayer dalam Kode Anda
|
|
381
213
|
|
|
382
|
-
Akses kamus konten Anda di seluruh aplikasi Nuxt
|
|
214
|
+
Akses kamus konten Anda di seluruh aplikasi Nuxt menggunakan composable `useIntlayer`:
|
|
383
215
|
|
|
384
216
|
```vue fileName="components/HelloWorld.vue"
|
|
385
217
|
<script setup lang="ts">
|
|
@@ -432,7 +264,7 @@ const countRef = ref(0);
|
|
|
432
264
|
|
|
433
265
|
Intlayer menawarkan berbagai API untuk mengakses konten Anda:
|
|
434
266
|
|
|
435
|
-
- **Sintaks berbasis komponen** (direkomendasikan):
|
|
267
|
+
- **Sintaks berbasis komponen** (direkomendasikan):
|
|
436
268
|
Gunakan sintaks `<myContent />`, atau `<Component :is="myContent" />` untuk merender konten sebagai Node Intlayer. Ini terintegrasi dengan mulus dengan [Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_visual_editor.md) dan [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_CMS.md).
|
|
437
269
|
|
|
438
270
|
- **Sintaks berbasis string**:
|
|
@@ -444,70 +276,60 @@ Intlayer menawarkan berbagai API untuk mengakses konten Anda:
|
|
|
444
276
|
- **Sintaks destrukturisasi**:
|
|
445
277
|
Composable `useIntlayer` mengembalikan sebuah Proxy dengan konten. Proxy ini dapat didestrukturisasi untuk mengakses konten sambil menjaga reaktivitas.
|
|
446
278
|
- Gunakan `const content = useIntlayer("myContent");` dan `{{ content.myContent }}` / `<content.myContent />`.
|
|
447
|
-
- Atau gunakan `const { myContent } = useIntlayer("myContent");` dan `{{ myContent}}` / `<myContent/>` untuk
|
|
279
|
+
- Atau gunakan `const { myContent } = useIntlayer("myContent");` dan `{{ myContent}}` / `<myContent/>` untuk mendestruktur konten.
|
|
448
280
|
|
|
449
281
|
### (Opsional) Langkah 6: Ubah bahasa konten Anda
|
|
450
282
|
|
|
451
|
-
Untuk mengubah bahasa konten Anda, Anda dapat menggunakan fungsi `setLocale` yang disediakan oleh composable `useLocale`. Fungsi ini memungkinkan Anda mengatur locale aplikasi dan memperbarui konten sesuai dengan
|
|
283
|
+
Untuk mengubah bahasa konten Anda, Anda dapat menggunakan fungsi `setLocale` yang disediakan oleh composable `useLocale`. Fungsi ini memungkinkan Anda untuk mengatur locale aplikasi dan memperbarui konten sesuai dengan itu.
|
|
452
284
|
|
|
453
|
-
Buat
|
|
285
|
+
Buat komponen untuk beralih antar bahasa menggunakan `NuxtLink`. **Menggunakan tautan daripada tombol untuk pergantian locale adalah praktik terbaik untuk SEO dan keterlihatan halaman**, karena memungkinkan mesin pencari untuk merayapi dan mengindeks semua versi terlokalisasi dari halaman Anda:
|
|
454
286
|
|
|
455
287
|
```vue fileName="components/LocaleSwitcher.vue"
|
|
456
|
-
<template>
|
|
457
|
-
<div class="locale-switcher">
|
|
458
|
-
<select v-model="selectedLocale" @change="changeLocale">
|
|
459
|
-
<option v-for="loc in availableLocales" :key="loc" :value="loc">
|
|
460
|
-
{{ getLocaleName(loc) }}
|
|
461
|
-
</option>
|
|
462
|
-
</select>
|
|
463
|
-
</div>
|
|
464
|
-
</template>
|
|
465
|
-
|
|
466
288
|
<script setup lang="ts">
|
|
467
|
-
import {
|
|
468
|
-
import { getLocaleName } from "intlayer";
|
|
289
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
469
290
|
import { useLocale } from "vue-intlayer";
|
|
470
291
|
|
|
471
|
-
//
|
|
292
|
+
// Nuxt secara otomatis mengimpor useRoute
|
|
293
|
+
const route = useRoute();
|
|
472
294
|
const { locale, availableLocales, setLocale } = useLocale();
|
|
473
|
-
|
|
474
|
-
// Melacak locale yang dipilih dengan ref
|
|
475
|
-
const selectedLocale = ref(locale.value);
|
|
476
|
-
|
|
477
|
-
// Memperbarui locale saat pilihan berubah
|
|
478
|
-
const changeLocale = () => setLocale(selectedLocale.value);
|
|
479
|
-
|
|
480
|
-
// Menjaga selectedLocale tetap sinkron dengan locale global
|
|
481
|
-
watch(
|
|
482
|
-
() => locale.value,
|
|
483
|
-
(newLocale) => {
|
|
484
|
-
selectedLocale.value = newLocale;
|
|
485
|
-
}
|
|
486
|
-
);
|
|
487
295
|
</script>
|
|
296
|
+
|
|
297
|
+
<template>
|
|
298
|
+
<nav class="locale-switcher">
|
|
299
|
+
<NuxtLink
|
|
300
|
+
v-for="localeEl in availableLocales"
|
|
301
|
+
:key="localeEl"
|
|
302
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
303
|
+
class="locale-link"
|
|
304
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
305
|
+
@click="setLocale(localeEl)"
|
|
306
|
+
>
|
|
307
|
+
{{ getLocaleName(localeEl) }}
|
|
308
|
+
</NuxtLink>
|
|
309
|
+
</nav>
|
|
488
310
|
</template>
|
|
311
|
+
```
|
|
489
312
|
|
|
490
|
-
|
|
491
|
-
.locale-switcher {
|
|
492
|
-
margin: 1rem 0;
|
|
493
|
-
}
|
|
313
|
+
> Menggunakan `NuxtLink` dengan atribut `href` yang tepat (melalui `getLocalizedUrl`) memastikan bahwa mesin pencari dapat menemukan semua varian bahasa dari halaman Anda. Ini lebih disukai dibandingkan dengan pengalihan locale hanya menggunakan JavaScript, yang mungkin tidak diikuti oleh perayap mesin pencari.
|
|
494
314
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
315
|
+
Kemudian, atur `app.vue` Anda untuk menggunakan layout:
|
|
316
|
+
|
|
317
|
+
```vue fileName="app.vue"
|
|
318
|
+
<template>
|
|
319
|
+
<NuxtLayout>
|
|
320
|
+
<NuxtPage />
|
|
321
|
+
</NuxtLayout>
|
|
322
|
+
</template>
|
|
501
323
|
```
|
|
502
324
|
|
|
503
|
-
|
|
325
|
+
### (Opsional) Langkah 6b: Buat Layout dengan Navigasi
|
|
504
326
|
|
|
505
|
-
|
|
327
|
+
Layout Nuxt memungkinkan Anda mendefinisikan struktur umum untuk halaman Anda. Buat layout default yang mencakup locale switcher dan navigasi:
|
|
328
|
+
|
|
329
|
+
```vue fileName="layouts/default.vue"
|
|
506
330
|
<script setup lang="ts">
|
|
507
|
-
import
|
|
331
|
+
import Links from "~/components/Links.vue";
|
|
508
332
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
509
|
-
|
|
510
|
-
const content = useIntlayer("app"); // Buat file deklarasi intlayer terkait
|
|
511
333
|
</script>
|
|
512
334
|
|
|
513
335
|
<template>
|
|
@@ -516,13 +338,18 @@ const content = useIntlayer("app"); // Buat file deklarasi intlayer terkait
|
|
|
516
338
|
<LocaleSwitcher />
|
|
517
339
|
</header>
|
|
518
340
|
<main>
|
|
519
|
-
<
|
|
341
|
+
<slot />
|
|
520
342
|
</main>
|
|
343
|
+
|
|
344
|
+
<Links href="/">Beranda</Links>
|
|
345
|
+
<Links href="/about">Tentang</Links>
|
|
521
346
|
</div>
|
|
522
347
|
</template>
|
|
523
348
|
```
|
|
524
349
|
|
|
525
|
-
|
|
350
|
+
Komponen `Links` (ditunjukkan di bawah) memastikan bahwa tautan navigasi internal secara otomatis dilokalkan.
|
|
351
|
+
|
|
352
|
+
### (Opsional) Langkah 7: Tambahkan Routing yang Dilokalkan ke aplikasi Anda
|
|
526
353
|
|
|
527
354
|
Nuxt secara otomatis menangani routing yang dilokalkan saat menggunakan modul `nuxt-intlayer`. Ini membuat rute untuk setiap bahasa secara otomatis berdasarkan struktur direktori halaman Anda.
|
|
528
355
|
|
|
@@ -536,246 +363,292 @@ pages/
|
|
|
536
363
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
537
364
|
```
|
|
538
365
|
|
|
539
|
-
Untuk membuat halaman yang dilokalkan, cukup buat file Vue Anda di direktori `pages
|
|
366
|
+
Untuk membuat halaman yang dilokalkan, cukup buat file Vue Anda di direktori `pages/`. Berikut adalah dua contoh halaman:
|
|
367
|
+
|
|
368
|
+
**Halaman Beranda (`pages/index.vue`):**
|
|
369
|
+
|
|
370
|
+
```vue fileName="pages/index.vue"
|
|
371
|
+
<script setup lang="ts">
|
|
372
|
+
import { useIntlayer } from "vue-intlayer";
|
|
373
|
+
|
|
374
|
+
const content = useIntlayer("home-page");
|
|
375
|
+
|
|
376
|
+
useHead({
|
|
377
|
+
title: content.metaTitle.value,
|
|
378
|
+
meta: [
|
|
379
|
+
{
|
|
380
|
+
name: "description",
|
|
381
|
+
content: content.metaDescription.value,
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
});
|
|
385
|
+
</script>
|
|
386
|
+
|
|
387
|
+
<template>
|
|
388
|
+
<h1><content.title /></h1>
|
|
389
|
+
</template>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**Halaman Tentang (`pages/about.vue`):**
|
|
540
393
|
|
|
541
394
|
```vue fileName="pages/about.vue"
|
|
542
395
|
<script setup lang="ts">
|
|
543
396
|
import { useIntlayer } from "vue-intlayer";
|
|
544
397
|
|
|
545
|
-
const content = useIntlayer("about");
|
|
398
|
+
const content = useIntlayer("about-page");
|
|
399
|
+
|
|
400
|
+
useHead({
|
|
401
|
+
title: content.metaTitle.raw, // Gunakan .raw untuk akses string primitif
|
|
402
|
+
meta: [
|
|
403
|
+
{
|
|
404
|
+
name: "description",
|
|
405
|
+
content: content.metaDescription.raw, // Gunakan .raw untuk akses string primitif
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
});
|
|
546
409
|
</script>
|
|
547
410
|
|
|
548
411
|
<template>
|
|
549
|
-
<
|
|
550
|
-
<h1>{{ content.title }}</h1>
|
|
551
|
-
<p>{{ content.description }}</p>
|
|
552
|
-
</div>
|
|
412
|
+
<h1><content.title /></h1>
|
|
553
413
|
</template>
|
|
554
414
|
```
|
|
555
415
|
|
|
416
|
+
> Catatan: `useHead` diimpor secara otomatis di Nuxt. Anda dapat mengakses nilai konten menggunakan `.value` (reaktif) atau `.raw` (string primitif) sesuai kebutuhan Anda.
|
|
417
|
+
|
|
556
418
|
Modul `nuxt-intlayer` secara otomatis akan:
|
|
557
419
|
|
|
558
420
|
- Mendeteksi locale yang dipilih pengguna
|
|
559
421
|
- Menangani pergantian locale melalui URL
|
|
560
422
|
- Mengatur atribut `<html lang="">` yang sesuai
|
|
561
423
|
- Mengelola cookie locale
|
|
562
|
-
- Mengarahkan pengguna ke URL yang
|
|
424
|
+
- Mengarahkan pengguna ke URL lokal yang sesuai
|
|
563
425
|
|
|
564
|
-
### (Opsional) Langkah 8: Membuat Komponen
|
|
426
|
+
### (Opsional) Langkah 8: Membuat Komponen Link yang Dilokalkan
|
|
565
427
|
|
|
566
|
-
Untuk memastikan navigasi aplikasi Anda menghormati locale saat ini, Anda dapat membuat komponen `
|
|
567
|
-
|
|
568
|
-
```vue fileName="components/LocalizedLink.vue"
|
|
569
|
-
<template>
|
|
570
|
-
<NuxtLink :to="localizedHref" v-bind="$attrs">
|
|
571
|
-
<slot />
|
|
572
|
-
</NuxtLink>
|
|
573
|
-
</template>
|
|
428
|
+
Untuk memastikan navigasi aplikasi Anda menghormati locale saat ini, Anda dapat membuat komponen `Links` kustom. Komponen ini secara otomatis menambahkan prefix bahasa saat ini pada URL internal, yang sangat penting untuk **SEO dan keterlihatan halaman**.
|
|
574
429
|
|
|
430
|
+
```vue fileName="components/Links.vue"
|
|
575
431
|
<script setup lang="ts">
|
|
576
|
-
import { computed } from "vue";
|
|
577
432
|
import { getLocalizedUrl } from "intlayer";
|
|
578
433
|
import { useLocale } from "vue-intlayer";
|
|
579
434
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
435
|
+
interface Props {
|
|
436
|
+
href: string;
|
|
437
|
+
locale?: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const props = defineProps<Props>();
|
|
441
|
+
|
|
442
|
+
const { locale: currentLocale } = useLocale();
|
|
586
443
|
|
|
587
|
-
|
|
444
|
+
// Hitung path akhir
|
|
445
|
+
const finalPath = computed(() => {
|
|
446
|
+
// 1. Periksa apakah link bersifat eksternal
|
|
447
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
588
448
|
|
|
589
|
-
//
|
|
590
|
-
|
|
449
|
+
// 2. Jika eksternal, kembalikan apa adanya (NuxtLink menangani pembuatan tag <a>)
|
|
450
|
+
if (isExternal) return props.href;
|
|
591
451
|
|
|
592
|
-
//
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
);
|
|
452
|
+
// 3. Jika internal, lokalize URL-nya
|
|
453
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
454
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
455
|
+
});
|
|
596
456
|
</script>
|
|
457
|
+
|
|
458
|
+
<template>
|
|
459
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
460
|
+
<slot />
|
|
461
|
+
</NuxtLink>
|
|
462
|
+
</template>
|
|
597
463
|
```
|
|
598
464
|
|
|
599
465
|
Kemudian gunakan komponen ini di seluruh aplikasi Anda:
|
|
600
466
|
|
|
601
|
-
```vue fileName="
|
|
467
|
+
```vue fileName="layouts/default.vue"
|
|
468
|
+
<script setup lang="ts">
|
|
469
|
+
import Links from "~/components/Links.vue";
|
|
470
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
471
|
+
</script>
|
|
472
|
+
|
|
602
473
|
<template>
|
|
603
474
|
<div>
|
|
604
|
-
<
|
|
605
|
-
|
|
606
|
-
</
|
|
607
|
-
<
|
|
608
|
-
|
|
609
|
-
</
|
|
475
|
+
<header>
|
|
476
|
+
<LocaleSwitcher />
|
|
477
|
+
</header>
|
|
478
|
+
<main>
|
|
479
|
+
<slot />
|
|
480
|
+
</main>
|
|
481
|
+
|
|
482
|
+
<Links href="/">Beranda</Links>
|
|
483
|
+
<Links href="/about">Tentang</Links>
|
|
610
484
|
</div>
|
|
611
485
|
</template>
|
|
612
|
-
|
|
613
|
-
<script setup lang="ts">
|
|
614
|
-
import { useIntlayer } from "vue-intlayer";
|
|
615
|
-
import LocalizedLink from "~/components/LocalizedLink.vue";
|
|
616
|
-
|
|
617
|
-
const content = useIntlayer("home");
|
|
618
|
-
</script>
|
|
619
486
|
```
|
|
620
487
|
|
|
488
|
+
> Dengan menggunakan `NuxtLink` dengan path yang dilokalkan, Anda memastikan bahwa:
|
|
489
|
+
>
|
|
490
|
+
> - Mesin pencari dapat merayapi dan mengindeks semua versi bahasa dari halaman Anda
|
|
491
|
+
> - Pengguna dapat membagikan URL yang dilokalkan secara langsung
|
|
492
|
+
> - Riwayat browser berfungsi dengan benar dengan URL yang diawali locale
|
|
493
|
+
|
|
621
494
|
### (Opsional) Langkah 9: Menangani Metadata dan SEO
|
|
622
495
|
|
|
623
|
-
Nuxt menyediakan kemampuan SEO yang sangat baik. Anda dapat menggunakan Intlayer untuk menangani metadata yang
|
|
496
|
+
Nuxt menyediakan kemampuan SEO yang sangat baik melalui composable `useHead` (diimpor otomatis). Anda dapat menggunakan Intlayer untuk menangani metadata yang dilokalkan menggunakan accessor `.raw` atau `.value` untuk mendapatkan nilai string primitif:
|
|
624
497
|
|
|
625
498
|
```vue fileName="pages/about.vue"
|
|
626
499
|
<script setup lang="ts">
|
|
627
|
-
import {
|
|
628
|
-
import { getIntlayer } from "intlayer";
|
|
629
|
-
import { useLocale } from "vue-intlayer";
|
|
500
|
+
import { useIntlayer } from "vue-intlayer";
|
|
630
501
|
|
|
631
|
-
|
|
632
|
-
const content =
|
|
502
|
+
// useHead diimpor otomatis di Nuxt
|
|
503
|
+
const content = useIntlayer("about-page");
|
|
633
504
|
|
|
634
|
-
|
|
635
|
-
title: content.
|
|
636
|
-
|
|
505
|
+
useHead({
|
|
506
|
+
title: content.metaTitle.raw, // Gunakan .raw untuk akses string primitif
|
|
507
|
+
meta: [
|
|
508
|
+
{
|
|
509
|
+
name: "description",
|
|
510
|
+
content: content.metaDescription.raw, // Gunakan .raw untuk akses string primitif
|
|
511
|
+
},
|
|
512
|
+
],
|
|
637
513
|
});
|
|
638
514
|
</script>
|
|
639
515
|
|
|
640
516
|
<template>
|
|
641
|
-
<
|
|
642
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
643
|
-
<p>{{ content.pageContent }}</p>
|
|
644
|
-
</div>
|
|
517
|
+
<h1><content.title /></h1>
|
|
645
518
|
</template>
|
|
646
519
|
```
|
|
647
520
|
|
|
521
|
+
> Sebagai alternatif, Anda dapat menggunakan fungsi `import { getIntlayer } from "intlayer"` untuk mendapatkan konten tanpa reaktivitas Vue.
|
|
522
|
+
|
|
523
|
+
> **Mengakses nilai konten:**
|
|
524
|
+
>
|
|
525
|
+
> - Gunakan `.raw` untuk mendapatkan nilai string primitif (non-reaktif)
|
|
526
|
+
> - Gunakan `.value` untuk mendapatkan nilai reaktif
|
|
527
|
+
> - Gunakan sintaks komponen `<content.key />` untuk dukungan Visual Editor
|
|
528
|
+
|
|
648
529
|
Buat deklarasi konten yang sesuai:
|
|
649
530
|
|
|
650
|
-
```ts fileName="pages/about-
|
|
531
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
651
532
|
import { t, type Dictionary } from "intlayer";
|
|
652
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
653
533
|
|
|
654
|
-
const
|
|
655
|
-
key: "about-
|
|
534
|
+
const aboutPageContent = {
|
|
535
|
+
key: "about-page",
|
|
656
536
|
content: {
|
|
657
|
-
|
|
658
|
-
en: "
|
|
537
|
+
metaTitle: t({
|
|
538
|
+
en: "Tentang Kami - Perusahaan Saya",
|
|
659
539
|
fr: "À Propos - Ma Société",
|
|
660
540
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
661
|
-
id: "Tentang Kami - Perusahaan Saya",
|
|
662
541
|
}),
|
|
663
|
-
|
|
664
|
-
en: "
|
|
542
|
+
metaDescription: t({
|
|
543
|
+
en: "Pelajari lebih lanjut tentang perusahaan kami dan misi kami",
|
|
665
544
|
fr: "En savoir plus sur notre société et notre mission",
|
|
666
545
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
667
|
-
|
|
546
|
+
}),
|
|
547
|
+
title: t({
|
|
548
|
+
en: "Tentang Kami",
|
|
549
|
+
fr: "À Propos",
|
|
550
|
+
es: "Acerca de Nosotros",
|
|
668
551
|
}),
|
|
669
552
|
},
|
|
670
|
-
} satisfies Dictionary
|
|
553
|
+
} satisfies Dictionary;
|
|
671
554
|
|
|
672
|
-
export default
|
|
555
|
+
export default aboutPageContent;
|
|
673
556
|
```
|
|
674
557
|
|
|
675
|
-
```
|
|
558
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
676
559
|
import { t } from "intlayer";
|
|
677
560
|
|
|
678
561
|
/** @type {import('intlayer').Dictionary} */
|
|
679
|
-
const
|
|
680
|
-
key: "about-
|
|
562
|
+
const aboutPageContent = {
|
|
563
|
+
key: "about-page",
|
|
681
564
|
content: {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
zh: "关于我们 - 我的公司",
|
|
685
|
-
en: "About Us - My Company",
|
|
565
|
+
metaTitle: t({
|
|
566
|
+
en: "Tentang Kami - Perusahaan Saya",
|
|
686
567
|
fr: "À Propos - Ma Société",
|
|
687
568
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
688
569
|
}),
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
692
|
-
en: "Learn more about our company and our mission",
|
|
570
|
+
metaDescription: t({
|
|
571
|
+
en: "Pelajari lebih lanjut tentang perusahaan kami dan misi kami",
|
|
693
572
|
fr: "En savoir plus sur notre société et notre mission",
|
|
694
573
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
695
574
|
}),
|
|
575
|
+
title: t({
|
|
576
|
+
en: "Tentang Kami",
|
|
577
|
+
fr: "À Propos",
|
|
578
|
+
es: "Acerca de Nosotros",
|
|
579
|
+
}),
|
|
696
580
|
},
|
|
697
581
|
};
|
|
698
582
|
|
|
699
|
-
export default
|
|
583
|
+
export default aboutPageContent;
|
|
700
584
|
```
|
|
701
585
|
|
|
702
|
-
```
|
|
586
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
703
587
|
const { t } = require("intlayer");
|
|
704
588
|
|
|
705
589
|
/** @type {import('intlayer').Dictionary} */
|
|
706
|
-
const
|
|
707
|
-
key: "about-
|
|
590
|
+
const aboutPageContent = {
|
|
591
|
+
key: "about-page",
|
|
708
592
|
content: {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
zh: "关于我们 - 我的公司",
|
|
712
|
-
en: "About Us - My Company",
|
|
593
|
+
metaTitle: t({
|
|
594
|
+
en: "Tentang Kami - Perusahaan Saya",
|
|
713
595
|
fr: "À Propos - Ma Société",
|
|
714
596
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
715
597
|
}),
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
en: "Learn more about our company and our mission",
|
|
598
|
+
metaDescription: t({
|
|
599
|
+
en: "Pelajari lebih lanjut tentang perusahaan kami dan misi kami",
|
|
719
600
|
fr: "En savoir plus sur notre société et notre mission",
|
|
720
601
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
721
|
-
|
|
602
|
+
}),
|
|
603
|
+
title: t({
|
|
604
|
+
en: "Tentang Kami",
|
|
605
|
+
fr: "À Propos",
|
|
606
|
+
es: "Acerca de Nosotros",
|
|
722
607
|
}),
|
|
723
608
|
},
|
|
724
609
|
};
|
|
725
610
|
|
|
726
|
-
module.exports =
|
|
611
|
+
module.exports = aboutPageContent;
|
|
727
612
|
```
|
|
728
613
|
|
|
729
|
-
```json fileName="pages/about-
|
|
614
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
730
615
|
{
|
|
731
|
-
"
|
|
616
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
617
|
+
"key": "about-page",
|
|
732
618
|
"content": {
|
|
733
|
-
"
|
|
619
|
+
"metaTitle": {
|
|
734
620
|
"nodeType": "translation",
|
|
735
|
-
"
|
|
736
|
-
"
|
|
737
|
-
"en": "About Us - My Company",
|
|
621
|
+
"translation": {
|
|
622
|
+
"en": "Tentang Kami - Perusahaan Saya",
|
|
738
623
|
"fr": "À Propos - Ma Société",
|
|
739
|
-
"es": "Acerca de Nosotros - Mi Empresa"
|
|
740
|
-
"id": "Tentang Kami - Perusahaan Saya"
|
|
624
|
+
"es": "Acerca de Nosotros - Mi Empresa"
|
|
741
625
|
}
|
|
742
626
|
},
|
|
743
|
-
"
|
|
627
|
+
"metaDescription": {
|
|
744
628
|
"nodeType": "translation",
|
|
745
|
-
"
|
|
746
|
-
"zh": "了解更多关于我们公司和我们的使命",
|
|
629
|
+
"translation": {
|
|
747
630
|
"en": "Learn more about our company and our mission",
|
|
748
631
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
749
|
-
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
632
|
+
"es": "Conozca más sobre nuestra empresa y nuestra misión",
|
|
633
|
+
"id": "Pelajari lebih lanjut tentang perusahaan kami dan misi kami"
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
"title": {
|
|
637
|
+
"nodeType": "translation",
|
|
638
|
+
"translation": {
|
|
639
|
+
"en": "About Us",
|
|
640
|
+
"fr": "À Propos",
|
|
641
|
+
"es": "Acerca de Nosotros",
|
|
642
|
+
"id": "Tentang Kami"
|
|
750
643
|
}
|
|
751
644
|
}
|
|
752
645
|
}
|
|
753
646
|
}
|
|
754
647
|
```
|
|
755
648
|
|
|
756
|
-
### Konfigurasi TypeScript
|
|
757
|
-
|
|
758
|
-
Intlayer menggunakan module augmentation untuk mendapatkan manfaat dari TypeScript dan membuat codebase Anda lebih kuat.
|
|
759
|
-
|
|
760
|
-

|
|
761
|
-
|
|
762
|
-

|
|
763
|
-
|
|
764
|
-
Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara otomatis.
|
|
765
|
-
|
|
766
|
-
```json5 fileName="tsconfig.json"
|
|
767
|
-
{
|
|
768
|
-
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
769
|
-
"include": [
|
|
770
|
-
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
771
|
-
".intlayer/**/*.ts", // Sertakan tipe yang dihasilkan secara otomatis
|
|
772
|
-
],
|
|
773
|
-
}
|
|
774
|
-
```
|
|
775
|
-
|
|
776
649
|
### Konfigurasi Git
|
|
777
650
|
|
|
778
|
-
Disarankan untuk mengabaikan file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda
|
|
651
|
+
Disarankan untuk mengabaikan file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda menghindari meng-commit file tersebut ke repositori Git Anda.
|
|
779
652
|
|
|
780
653
|
Untuk melakukannya, Anda dapat menambahkan instruksi berikut ke file `.gitignore` Anda:
|
|
781
654
|
|
|
@@ -793,7 +666,7 @@ Untuk meningkatkan pengalaman pengembangan Anda dengan Intlayer, Anda dapat meng
|
|
|
793
666
|
Ekstensi ini menyediakan:
|
|
794
667
|
|
|
795
668
|
- **Autocompletion** untuk kunci terjemahan.
|
|
796
|
-
- **Deteksi kesalahan
|
|
669
|
+
- **Deteksi kesalahan waktu nyata** untuk terjemahan yang hilang.
|
|
797
670
|
- **Pratinjau inline** dari konten yang diterjemahkan.
|
|
798
671
|
- **Aksi cepat** untuk dengan mudah membuat dan memperbarui terjemahan.
|
|
799
672
|
|
|
@@ -804,5 +677,3 @@ Untuk detail lebih lanjut tentang cara menggunakan ekstensi ini, lihat [dokument
|
|
|
804
677
|
### Melangkah Lebih Jauh
|
|
805
678
|
|
|
806
679
|
Untuk melangkah lebih jauh, Anda dapat mengimplementasikan [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_visual_editor.md) atau mengeksternalisasi konten Anda menggunakan [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_CMS.md).
|
|
807
|
-
|
|
808
|
-
---
|