@intlayer/docs 8.7.9 → 8.7.11-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.
Files changed (65) hide show
  1. package/docs/ar/dictionary/insertion.md +0 -52
  2. package/docs/ar/intlayer_with_astro.md +55 -6
  3. package/docs/ar/per_locale_file.md +0 -46
  4. package/docs/de/dictionary/insertion.md +0 -92
  5. package/docs/de/intlayer_with_astro.md +55 -6
  6. package/docs/de/intlayer_with_nextjs_16.md +0 -23
  7. package/docs/de/per_locale_file.md +0 -44
  8. package/docs/en/dictionary/insertion.md +0 -55
  9. package/docs/en/intlayer_with_astro.md +2 -1
  10. package/docs/en/per_locale_file.md +0 -43
  11. package/docs/en-GB/dictionary/insertion.md +0 -56
  12. package/docs/en-GB/intlayer_with_astro.md +55 -6
  13. package/docs/en-GB/per_locale_file.md +0 -43
  14. package/docs/es/dictionary/insertion.md +0 -52
  15. package/docs/es/intlayer_with_astro.md +55 -7
  16. package/docs/es/intlayer_with_nextjs_14.md +0 -23
  17. package/docs/es/intlayer_with_nextjs_16.md +0 -23
  18. package/docs/es/packages/next-intlayer/index.md +0 -52
  19. package/docs/es/packages/react-intlayer/index.md +0 -52
  20. package/docs/es/per_locale_file.md +0 -43
  21. package/docs/fr/dictionary/insertion.md +0 -52
  22. package/docs/fr/intlayer_with_astro.md +55 -7
  23. package/docs/fr/packages/react-intlayer/index.md +0 -52
  24. package/docs/fr/per_locale_file.md +0 -46
  25. package/docs/hi/dictionary/insertion.md +0 -91
  26. package/docs/hi/intlayer_with_astro.md +55 -6
  27. package/docs/hi/packages/intlayer/index.md +0 -52
  28. package/docs/hi/per_locale_file.md +0 -43
  29. package/docs/id/dictionary/insertion.md +0 -91
  30. package/docs/id/intlayer_with_astro.md +55 -6
  31. package/docs/id/intlayer_with_nextjs_14.md +0 -24
  32. package/docs/id/per_locale_file.md +0 -44
  33. package/docs/it/dictionary/insertion.md +0 -52
  34. package/docs/it/intlayer_with_astro.md +55 -6
  35. package/docs/it/per_locale_file.md +0 -44
  36. package/docs/ja/dictionary/insertion.md +0 -56
  37. package/docs/ja/intlayer_with_astro.md +55 -7
  38. package/docs/ja/intlayer_with_nextjs_14.md +0 -23
  39. package/docs/ja/per_locale_file.md +0 -43
  40. package/docs/ko/dictionary/insertion.md +0 -56
  41. package/docs/ko/intlayer_with_astro.md +55 -7
  42. package/docs/ko/per_locale_file.md +0 -43
  43. package/docs/pl/dictionary/insertion.md +0 -85
  44. package/docs/pl/intlayer_with_astro.md +55 -6
  45. package/docs/pl/per_locale_file.md +0 -44
  46. package/docs/pt/dictionary/insertion.md +0 -93
  47. package/docs/pt/intlayer_with_astro.md +55 -6
  48. package/docs/pt/intlayer_with_nextjs_page_router.md +0 -23
  49. package/docs/pt/per_locale_file.md +0 -44
  50. package/docs/ru/dictionary/insertion.md +0 -52
  51. package/docs/ru/intlayer_with_astro.md +55 -7
  52. package/docs/ru/per_locale_file.md +0 -44
  53. package/docs/tr/dictionary/insertion.md +0 -52
  54. package/docs/tr/intlayer_with_astro.md +55 -6
  55. package/docs/tr/per_locale_file.md +0 -43
  56. package/docs/uk/dictionary/insertion.md +0 -52
  57. package/docs/uk/intlayer_with_astro.md +55 -6
  58. package/docs/uk/per_locale_file.md +0 -43
  59. package/docs/vi/dictionary/insertion.md +0 -85
  60. package/docs/vi/intlayer_with_astro.md +55 -6
  61. package/docs/vi/per_locale_file.md +0 -46
  62. package/docs/zh/dictionary/insertion.md +0 -54
  63. package/docs/zh/intlayer_with_astro.md +55 -7
  64. package/docs/zh/per_locale_file.md +0 -44
  65. package/package.json +6 -6
@@ -145,50 +145,6 @@ const helloWorldContent = {
145
145
  export default helloWorldContent;
146
146
  ```
147
147
 
148
- ```tsx fileName="hello-world.es.content.mjs" contentDeclarationFormat="esm"
149
- import { t, Locales } from "intlayer";
150
-
151
- /** @type {import('intlayer').Dictionary} */
152
- // Контент для испанской локали
153
- const helloWorldContent = {
154
- key: "hello-world",
155
- locale: Locales.SPANISH, // Важно
156
- content: { multilingualContent: "Título de mi componente" },
157
- };
158
-
159
- export default helloWorldContent;
160
- ```
161
-
162
- ```js fileName="hello-world.en.content.cjs" contentDeclarationFormat="commonjs"
163
- const { t, Locales } = require("intlayer");
164
-
165
- /** @type {import('intlayer').Dictionary} */
166
- const helloWorldContent = {
167
- key: "hello-world",
168
- locale: Locales.ENGLISH, // Важно
169
- content: {
170
- multilingualContent: "Название моего компонента",
171
- },
172
- };
173
-
174
- module.exports = helloWorldContent;
175
- ```
176
-
177
- ```tsx fileName="hello-world.es.content.cjs" contentDeclarationFormat="commonjs"
178
- const { t, Locales } = require("intlayer");
179
-
180
- /** @type {import('intlayer').Dictionary} */
181
- const helloWorldContent = {
182
- key: "hello-world",
183
- locale: Locales.SPANISH, // Важно
184
- content: {
185
- multilingualContent: "Título de mi componente",
186
- },
187
- };
188
-
189
- module.exports = helloWorldContent;
190
- ```
191
-
192
148
  ```json5 fileName="hello-world.en.content.json" contentDeclarationFormat="json"
193
149
  {
194
150
  "$schema": "https://intlayer.org/schema.json",
@@ -54,34 +54,6 @@ Intlayer projenizde ekleme içeriğini ayarlamak için, ekleme tanımlarınızı
54
54
  export default myInsertionContent;
55
55
  ```
56
56
 
57
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
58
- import { insert } from "intlayer";
59
-
60
- /** @type {import('intlayer').Dictionary} */
61
- const myInsertionContent = {
62
- key: "my_key",
63
- content: {
64
- myInsertion: insert("Merhaba, adım {{name}} ve {{age}} yaşındayım!"),
65
- },
66
- };
67
-
68
- export default myInsertionContent;
69
- ```
70
-
71
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
72
- const { insert } = require("intlayer");
73
-
74
- /** @type {import('intlayer').Dictionary} */
75
- const myInsertionContent = {
76
- key: "my_key",
77
- content: {
78
- myInsertion: insert("Merhaba, adım {{name}} ve {{age}} yaşındayım!"),
79
- },
80
- };
81
-
82
- module.exports = myInsertionContent;
83
- ```
84
-
85
57
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
86
58
  {
87
59
  "$schema": "https://intlayer.org/schema.json",
@@ -112,30 +84,6 @@ Intlayer projenizde ekleme içeriğini ayarlamak için, ekleme tanımlarınızı
112
84
  export default myInsertionContent;
113
85
  ```
114
86
 
115
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
116
- /** @type {import('intlayer').Dictionary} */
117
- const myInsertionContent = {
118
- key: "my_key",
119
- content: {
120
- myInsertion: "Merhaba, adım {{name}} ve {{age}} yaşındayım!",
121
- },
122
- };
123
-
124
- export default myInsertionContent;
125
- ```
126
-
127
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
128
- /** @type {import('intlayer').Dictionary} */
129
- const myInsertionContent = {
130
- key: "my_key",
131
- content: {
132
- myInsertion: "Merhaba, adım {{name}} ve {{age}} yaşındayım!",
133
- },
134
- };
135
-
136
- module.exports = myInsertionContent;
137
- ```
138
-
139
87
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
140
88
  {
141
89
  "$schema": "https://intlayer.org/schema.json",
@@ -178,20 +178,69 @@ Sözlükleri doğrudan `.astro` dosyalarınızda, `intlayer`'dan dışa aktarıl
178
178
 
179
179
  ```astro fileName="src/pages/index.astro"
180
180
  ---
181
- import { getIntlayer } from "intlayer";
182
- import appContent from "../app.content";
183
-
184
- const { title } = getIntlayer('app');
181
+ import {
182
+ getIntlayer,
183
+ getLocaleFromPath,
184
+ getLocalizedUrl,
185
+ defaultLocale,
186
+ localeMap,
187
+ getHTMLTextDir,
188
+ type LocalesValues,
189
+ } from "intlayer";
190
+ import LocaleSwitcher from "../components/LocaleSwitcher.astro";
191
+
192
+ // Get the current locale from the URL (e.g. /es/about -> 'es')
193
+ const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
194
+
195
+ // Get the content for the 'app' dictionary
196
+ const { title } = getIntlayer("app", locale);
185
197
  ---
186
198
 
187
- <html lang="tr">
199
+ <!doctype html>
200
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
188
201
  <head>
189
202
  <meta charset="utf-8" />
190
203
  <meta name="viewport" content="width=device-width" />
204
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
191
205
  <title>{title}</title>
206
+
207
+ <!-- Canonical link: Tells search engines which is the primary version of this page -->
208
+ <link
209
+ rel="canonical"
210
+ href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
211
+ />
212
+
213
+ <!-- Hreflang: Tell Google about all localized versions -->
214
+ {
215
+ localeMap(({ locale: mapLocale }) => (
216
+ <link
217
+ rel="alternate"
218
+ hreflang={mapLocale}
219
+ href={new URL(
220
+ getLocalizedUrl(Astro.url.pathname, mapLocale),
221
+ Astro.site
222
+ )}
223
+ />
224
+ ))
225
+ }
226
+
227
+ <!-- x-default: Fallback for users in unmatched languages -->
228
+ <link
229
+ rel="alternate"
230
+ hreflang="x-default"
231
+ href={new URL(
232
+ getLocalizedUrl(Astro.url.pathname, defaultLocale),
233
+ Astro.site
234
+ )}
235
+ />
192
236
  </head>
193
237
  <body>
194
- <h1>{title}</h1>
238
+ <header>
239
+ <LocaleSwitcher />
240
+ </header>
241
+ <main>
242
+ <h1>{title}</h1>
243
+ </main>
195
244
  </body>
196
245
  </html>
197
246
  ```
@@ -144,49 +144,6 @@ const helloWorldContent = {
144
144
  export default helloWorldContent;
145
145
  ```
146
146
 
147
- ```tsx fileName="hello-world.es.content.mjs" contentDeclarationFormat="esm"
148
- import { t, Locales } from "intlayer";
149
-
150
- /** @type {import('intlayer').Dictionary} */
151
- const helloWorldContent = {
152
- key: "hello-world",
153
- locale: Locales.SPANISH, // Önemli
154
- content: { multilingualContent: "Título de mi componente" },
155
- };
156
-
157
- export default helloWorldContent;
158
- ```
159
-
160
- ```js fileName="hello-world.en.content.cjs" contentDeclarationFormat="commonjs"
161
- const { t, Locales } = require("intlayer");
162
-
163
- /** @type {import('intlayer').Dictionary} */
164
- const helloWorldContent = {
165
- key: "hello-world",
166
- locale: Locales.ENGLISH, // Önemli
167
- content: {
168
- multilingualContent: "Title of my component",
169
- },
170
- };
171
-
172
- module.exports = helloWorldContent;
173
- ```
174
-
175
- ```tsx fileName="hello-world.es.content.cjs" contentDeclarationFormat="commonjs"
176
- const { t, Locales } from "intlayer";
177
-
178
- /** @type {import('intlayer').Dictionary} */
179
- const helloWorldContent = {
180
- key: "hello-world",
181
- locale: Locales.SPANISH, // Önemli
182
- content: {
183
- multilingualContent: "Título de mi componente",
184
- },
185
- };
186
-
187
- module.exports = helloWorldContent;
188
- ```
189
-
190
147
  ```json5 fileName="hello-world.en.content.json" contentDeclarationFormat="json"
191
148
  {
192
149
  "$schema": "https://intlayer.org/schema.json",
@@ -54,34 +54,6 @@ history:
54
54
  export default myInsertionContent;
55
55
  ```
56
56
 
57
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
58
- import { insert } from "intlayer";
59
-
60
- /** @type {import('intlayer').Dictionary} */
61
- const myInsertionContent = {
62
- key: "my_key",
63
- content: {
64
- myInsertion: insert("Привіт, мене звати {{name}} і мені {{age}} років!"),
65
- },
66
- };
67
-
68
- export default myInsertionContent;
69
- ```
70
-
71
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
72
- const { insert } = require("intlayer");
73
-
74
- /** @type {import('intlayer').Dictionary} */
75
- const myInsertionContent = {
76
- key: "my_key",
77
- content: {
78
- myInsertion: insert("Привіт, мене звати {{name}} і мені {{age}} років!"),
79
- },
80
- };
81
-
82
- module.exports = myInsertionContent;
83
- ```
84
-
85
57
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
86
58
  {
87
59
  "$schema": "https://intlayer.org/schema.json",
@@ -112,30 +84,6 @@ history:
112
84
  export default myInsertionContent;
113
85
  ```
114
86
 
115
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
116
- /** @type {import('intlayer').Dictionary} */
117
- const myInsertionContent = {
118
- key: "my_key",
119
- content: {
120
- myInsertion: "Привіт, мене звати {{name}} і мені {{age}} років!",
121
- },
122
- };
123
-
124
- export default myInsertionContent;
125
- ```
126
-
127
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
128
- /** @type {import('intlayer').Dictionary} */
129
- const myInsertionContent = {
130
- key: "my_key",
131
- content: {
132
- myInsertion: "Привіт, мене звати {{name}} і мені {{age}} років!",
133
- },
134
- };
135
-
136
- module.exports = myInsertionContent;
137
- ```
138
-
139
87
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
140
88
  {
141
89
  "$schema": "https://intlayer.org/schema.json",
@@ -178,20 +178,69 @@ export default appContent;
178
178
 
179
179
  ```astro fileName="src/pages/index.astro"
180
180
  ---
181
- import { getIntlayer } from "intlayer";
182
- import appContent from "../app.content";
183
-
184
- const { title } = getIntlayer('app');
181
+ import {
182
+ getIntlayer,
183
+ getLocaleFromPath,
184
+ getLocalizedUrl,
185
+ defaultLocale,
186
+ localeMap,
187
+ getHTMLTextDir,
188
+ type LocalesValues,
189
+ } from "intlayer";
190
+ import LocaleSwitcher from "../components/LocaleSwitcher.astro";
191
+
192
+ // Get the current locale from the URL (e.g. /es/about -> 'es')
193
+ const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
194
+
195
+ // Get the content for the 'app' dictionary
196
+ const { title } = getIntlayer("app", locale);
185
197
  ---
186
198
 
187
- <html lang="uk">
199
+ <!doctype html>
200
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
188
201
  <head>
189
202
  <meta charset="utf-8" />
190
203
  <meta name="viewport" content="width=device-width" />
204
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
191
205
  <title>{title}</title>
206
+
207
+ <!-- Canonical link: Tells search engines which is the primary version of this page -->
208
+ <link
209
+ rel="canonical"
210
+ href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
211
+ />
212
+
213
+ <!-- Hreflang: Tell Google about all localized versions -->
214
+ {
215
+ localeMap(({ locale: mapLocale }) => (
216
+ <link
217
+ rel="alternate"
218
+ hreflang={mapLocale}
219
+ href={new URL(
220
+ getLocalizedUrl(Astro.url.pathname, mapLocale),
221
+ Astro.site
222
+ )}
223
+ />
224
+ ))
225
+ }
226
+
227
+ <!-- x-default: Fallback for users in unmatched languages -->
228
+ <link
229
+ rel="alternate"
230
+ hreflang="x-default"
231
+ href={new URL(
232
+ getLocalizedUrl(Astro.url.pathname, defaultLocale),
233
+ Astro.site
234
+ )}
235
+ />
192
236
  </head>
193
237
  <body>
194
- <h1>{title}</h1>
238
+ <header>
239
+ <LocaleSwitcher />
240
+ </header>
241
+ <main>
242
+ <h1>{title}</h1>
243
+ </main>
195
244
  </body>
196
245
  </html>
197
246
  ```
@@ -69,49 +69,6 @@ const helloWorldContent = {
69
69
  export default helloWorldContent;
70
70
  ```
71
71
 
72
- ```tsx fileName="hello-world.es.content.mjs" contentDeclarationFormat="esm"
73
- import { t, Locales } from "intlayer";
74
-
75
- /** @type {import('intlayer').Dictionary} */
76
- const helloWorldContent = {
77
- key: "hello-world",
78
- locale: Locales.SPANISH, // Важливо
79
- content: { multilingualContent: "Заголовок мого компонента" },
80
- };
81
-
82
- export default helloWorldContent;
83
- ```
84
-
85
- ```js fileName="hello-world.en.content.cjs" contentDeclarationFormat="commonjs"
86
- const { t, Locales } = require("intlayer");
87
-
88
- /** @type {import('intlayer').Dictionary} */
89
- const helloWorldContent = {
90
- key: "hello-world",
91
- locale: Locales.ENGLISH, // Важливо
92
- content: {
93
- multilingualContent: "Заголовок мого компонента",
94
- },
95
- };
96
-
97
- module.exports = helloWorldContent;
98
- ```
99
-
100
- ```tsx fileName="hello-world.es.content.cjs" contentDeclarationFormat="commonjs"
101
- const { t, Locales } = require("intlayer");
102
-
103
- /** @type {import('intlayer').Dictionary} */
104
- const helloWorldContent = {
105
- key: "hello-world",
106
- locale: Locales.SPANISH, // Важливо
107
- content: {
108
- multilingualContent: "Заголовок мого компонента",
109
- },
110
- };
111
-
112
- module.exports = helloWorldContent;
113
- ```
114
-
115
72
  ```json5 fileName="hello-world.en.content.json" contentDeclarationFormat="json"
116
73
  {
117
74
  "$schema": "https://intlayer.org/schema.json",
@@ -54,34 +54,6 @@ Khi tích hợp với React Intlayer hoặc Next Intlayer, bạn chỉ cần cun
54
54
  export default myInsertionContent;
55
55
  ```
56
56
 
57
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
58
- import { insert } from "intlayer";
59
-
60
- /** @type {import('intlayer').Dictionary} */
61
- const myInsertionContent = {
62
- key: "my_key",
63
- content: {
64
- myInsertion: insert("Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!"),
65
- },
66
- };
67
-
68
- export default myInsertionContent;
69
- ```
70
-
71
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
72
- const { insert } = require("intlayer");
73
-
74
- /** @type {import('intlayer').Dictionary} */
75
- const myInsertionContent = {
76
- key: "my_key",
77
- content: {
78
- myInsertion: insert("Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!"),
79
- },
80
- };
81
-
82
- module.exports = myInsertionContent;
83
- ```
84
-
85
57
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
86
58
  {
87
59
  "$schema": "https://intlayer.org/schema.json",
@@ -112,30 +84,6 @@ Khi tích hợp với React Intlayer hoặc Next Intlayer, bạn chỉ cần cun
112
84
  export default myInsertionContent;
113
85
  ```
114
86
 
115
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
116
- /** @type {import('intlayer').Dictionary} */
117
- const myInsertionContent = {
118
- key: "my_key",
119
- content: {
120
- myInsertion: "Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!",
121
- },
122
- };
123
-
124
- export default myInsertionContent;
125
- ```
126
-
127
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
128
- /** @type {import('intlayer').Dictionary} */
129
- const myInsertionContent = {
130
- key: "my_key",
131
- content: {
132
- myInsertion: "Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!",
133
- },
134
- };
135
-
136
- module.exports = myInsertionContent;
137
- ```
138
-
139
87
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
140
88
  {
141
89
  "$schema": "https://intlayer.org/schema.json",
@@ -149,39 +97,6 @@ Khi tích hợp với React Intlayer hoặc Next Intlayer, bạn chỉ cần cun
149
97
  </Tab>
150
98
  </Tabs>
151
99
 
152
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
153
- import { insert } from "intlayer";
154
-
155
- /** @type {import('intlayer').Dictionary} */
156
- const myInsertionContent = {
157
- key: "my_key",
158
- content: {
159
- myInsertion: insert("Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!"),
160
- },
161
- };
162
-
163
- export default myInsertionContent;
164
- ```
165
-
166
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
167
- javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
168
- const { insert } = require("intlayer");
169
-
170
- /** @type {import('intlayer').Dictionary} */
171
- // Nội dung chèn với các biến động
172
- const myInsertionContent = {
173
- key: "my_key",
174
- content: {
175
- myInsertion: insert(
176
- "Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!"
177
- ),
178
- myInsertion2: "Xin chào, tôi tên là {{name}} và tôi {{age}} tuổi!", // Since intlayer v8, insertion function is not required anymore. The content will be automatically decorated.
179
- },
180
- };
181
-
182
- module.exports = myInsertionContent;
183
- ```
184
-
185
100
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
186
101
  {
187
102
  "$schema": "https://intlayer.org/schema.json",
@@ -178,20 +178,69 @@ Bạn có thể sử dụng các từ điển trực tiếp trong các file `.as
178
178
 
179
179
  ```astro fileName="src/pages/index.astro"
180
180
  ---
181
- import { getIntlayer } from "intlayer";
182
- import appContent from "../app.content";
183
-
184
- const { title } = getIntlayer('app');
181
+ import {
182
+ getIntlayer,
183
+ getLocaleFromPath,
184
+ getLocalizedUrl,
185
+ defaultLocale,
186
+ localeMap,
187
+ getHTMLTextDir,
188
+ type LocalesValues,
189
+ } from "intlayer";
190
+ import LocaleSwitcher from "../components/LocaleSwitcher.astro";
191
+
192
+ // Get the current locale from the URL (e.g. /es/about -> 'es')
193
+ const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
194
+
195
+ // Get the content for the 'app' dictionary
196
+ const { title } = getIntlayer("app", locale);
185
197
  ---
186
198
 
187
- <html lang="vi">
199
+ <!doctype html>
200
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
188
201
  <head>
189
202
  <meta charset="utf-8" />
190
203
  <meta name="viewport" content="width=device-width" />
204
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
191
205
  <title>{title}</title>
206
+
207
+ <!-- Canonical link: Tells search engines which is the primary version of this page -->
208
+ <link
209
+ rel="canonical"
210
+ href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
211
+ />
212
+
213
+ <!-- Hreflang: Tell Google about all localized versions -->
214
+ {
215
+ localeMap(({ locale: mapLocale }) => (
216
+ <link
217
+ rel="alternate"
218
+ hreflang={mapLocale}
219
+ href={new URL(
220
+ getLocalizedUrl(Astro.url.pathname, mapLocale),
221
+ Astro.site
222
+ )}
223
+ />
224
+ ))
225
+ }
226
+
227
+ <!-- x-default: Fallback for users in unmatched languages -->
228
+ <link
229
+ rel="alternate"
230
+ hreflang="x-default"
231
+ href={new URL(
232
+ getLocalizedUrl(Astro.url.pathname, defaultLocale),
233
+ Astro.site
234
+ )}
235
+ />
192
236
  </head>
193
237
  <body>
194
- <h1>{title}</h1>
238
+ <header>
239
+ <LocaleSwitcher />
240
+ </header>
241
+ <main>
242
+ <h1>{title}</h1>
243
+ </main>
195
244
  </body>
196
245
  </html>
197
246
  ```
@@ -145,52 +145,6 @@ const helloWorldContent = {
145
145
  export default helloWorldContent;
146
146
  ```
147
147
 
148
- ```tsx fileName="hello-world.es.content.mjs" contentDeclarationFormat="esm"
149
- import { t, Locales } from "intlayer";
150
-
151
- /** @type {import('intlayer').Dictionary} */
152
- // Định nghĩa nội dung cho bản dịch "hello-world" với locale tiếng Tây Ban Nha
153
- const helloWorldContent = {
154
- key: "hello-world",
155
- locale: Locales.SPANISH, // Quan trọng
156
- content: { multilingualContent: "Título de mi componente" },
157
- };
158
-
159
- export default helloWorldContent;
160
- ```
161
-
162
- ```js fileName="hello-world.en.content.cjs" contentDeclarationFormat="commonjs"
163
- const { t, Locales } = require("intlayer");
164
-
165
- /** @type {import('intlayer').Dictionary} */
166
- // Định nghĩa nội dung cho bản dịch "hello-world" với locale tiếng Anh
167
- const helloWorldContent = {
168
- key: "hello-world",
169
- locale: Locales.ENGLISH, // Quan trọng
170
- content: {
171
- multilingualContent: "Title of my component",
172
- },
173
- };
174
-
175
- module.exports = helloWorldContent;
176
- ```
177
-
178
- ```tsx fileName="hello-world.es.content.cjs" contentDeclarationFormat="commonjs"
179
- const { t, Locales } = require("intlayer");
180
-
181
- /** @type {import('intlayer').Dictionary} */
182
- // Định nghĩa nội dung cho bản dịch "hello-world" với locale tiếng Tây Ban Nha
183
- const helloWorldContent = {
184
- key: "hello-world",
185
- locale: Locales.SPANISH, // Quan trọng
186
- content: {
187
- multilingualContent: "Título de mi componente",
188
- },
189
- };
190
-
191
- module.exports = helloWorldContent;
192
- ```
193
-
194
148
  ```json5 fileName="hello-world.en.content.json" contentDeclarationFormat="json"
195
149
  {
196
150
  "$schema": "https://intlayer.org/schema.json",