@intlayer/docs 8.7.8 → 8.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -56,36 +56,6 @@ history:
56
56
  export default myInsertionContent;
57
57
  ```
58
58
 
59
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
60
- import { insert } from "intlayer";
61
-
62
- /** @type {import('intlayer').Dictionary} */
63
- const myInsertionContent = {
64
- key: "my_key",
65
- content: {
66
- myInsertion: insert(
67
- "你好,我的名字是 {{name}},我今年 {{age}} 岁!"
68
- ),
69
- },
70
- };
71
-
72
- export default myInsertionContent;
73
- ```
74
-
75
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
76
- const { insert } = require("intlayer");
77
-
78
- /** @type {import('intlayer').Dictionary} */
79
- const myInsertionContent = {
80
- key: "my_key",
81
- content: {
82
- myInsertion: insert("你好,我的名字是 {{name}},我今年 {{age}} 岁!"),
83
- },
84
- };
85
-
86
- module.exports = myInsertionContent;
87
- ```
88
-
89
59
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
90
60
  {
91
61
  "$schema": "https://intlayer.org/schema.json",
@@ -116,30 +86,6 @@ history:
116
86
  export default myInsertionContent;
117
87
  ```
118
88
 
119
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
120
- /** @type {import('intlayer').Dictionary} */
121
- const myInsertionContent = {
122
- key: "my_key",
123
- content: {
124
- myInsertion: "你好,我的名字是 {{name}},我今年 {{age}} 岁!",
125
- },
126
- };
127
-
128
- export default myInsertionContent;
129
- ```
130
-
131
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
132
- /** @type {import('intlayer').Dictionary} */
133
- const myInsertionContent = {
134
- key: "my_key",
135
- content: {
136
- myInsertion: "你好,我的名字是 {{name}},我今年 {{age}} 岁!",
137
- },
138
- };
139
-
140
- module.exports = myInsertionContent;
141
- ```
142
-
143
89
  ```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
144
90
  {
145
91
  "$schema": "https://intlayer.org/schema.json",
@@ -176,22 +176,70 @@ export default appContent;
176
176
  您可以使用 `intlayer` 导出的核心辅助函数直接在 `.astro` 文件中消费词典。
177
177
 
178
178
  ```astro fileName="src/pages/index.astro"
179
- <!-- astro -->
180
179
  ---
181
- import { getIntlayer } from "intlayer";
182
- import appContent from "../app.content";
183
-
184
- const { title } = getIntlayer('app');
180
+ import {
181
+ getIntlayer,
182
+ getLocaleFromPath,
183
+ getLocalizedUrl,
184
+ defaultLocale,
185
+ localeMap,
186
+ getHTMLTextDir,
187
+ type LocalesValues,
188
+ } from "intlayer";
189
+ import LocaleSwitcher from "../components/LocaleSwitcher.astro";
190
+
191
+ // Get the current locale from the URL (e.g. /es/about -> 'es')
192
+ const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
193
+
194
+ // Get the content for the 'app' dictionary
195
+ const { title } = getIntlayer("app", locale);
185
196
  ---
186
197
 
187
- <html lang="zh">
198
+ <!doctype html>
199
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
188
200
  <head>
189
201
  <meta charset="utf-8" />
190
202
  <meta name="viewport" content="width=device-width" />
203
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
191
204
  <title>{title}</title>
205
+
206
+ <!-- Canonical link: Tells search engines which is the primary version of this page -->
207
+ <link
208
+ rel="canonical"
209
+ href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
210
+ />
211
+
212
+ <!-- Hreflang: Tell Google about all localized versions -->
213
+ {
214
+ localeMap(({ locale: mapLocale }) => (
215
+ <link
216
+ rel="alternate"
217
+ hreflang={mapLocale}
218
+ href={new URL(
219
+ getLocalizedUrl(Astro.url.pathname, mapLocale),
220
+ Astro.site
221
+ )}
222
+ />
223
+ ))
224
+ }
225
+
226
+ <!-- x-default: Fallback for users in unmatched languages -->
227
+ <link
228
+ rel="alternate"
229
+ hreflang="x-default"
230
+ href={new URL(
231
+ getLocalizedUrl(Astro.url.pathname, defaultLocale),
232
+ Astro.site
233
+ )}
234
+ />
192
235
  </head>
193
236
  <body>
194
- <h1>{title}</h1>
237
+ <header>
238
+ <LocaleSwitcher />
239
+ </header>
240
+ <main>
241
+ <h1>{title}</h1>
242
+ </main>
195
243
  </body>
196
244
  </html>
197
245
  ```
@@ -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: "我的组件标题",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/docs",
3
- "version": "8.7.8",
3
+ "version": "8.7.10",
4
4
  "private": false,
5
5
  "description": "Intlayer documentation",
6
6
  "keywords": [
@@ -72,13 +72,13 @@
72
72
  "watch": "webpack --config ./webpack.config.ts --watch"
73
73
  },
74
74
  "dependencies": {
75
- "@intlayer/config": "8.7.8",
76
- "@intlayer/core": "8.7.8",
77
- "@intlayer/types": "8.7.8"
75
+ "@intlayer/config": "8.7.10",
76
+ "@intlayer/core": "8.7.10",
77
+ "@intlayer/types": "8.7.10"
78
78
  },
79
79
  "devDependencies": {
80
- "@intlayer/api": "8.7.8",
81
- "@intlayer/cli": "8.7.8",
80
+ "@intlayer/api": "8.7.10",
81
+ "@intlayer/cli": "8.7.10",
82
82
  "@types/node": "25.6.0",
83
83
  "@utils/ts-config": "1.0.4",
84
84
  "@utils/ts-config-types": "1.0.4",