@intlayer/docs 8.10.1 → 8.11.2

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 (198) hide show
  1. package/blog/en/i18n_using_next-i18next.md +3 -3
  2. package/blog/en/i18n_using_next-intl.md +3 -3
  3. package/blog/en/list_i18n_technologies/frameworks/angular.md +3 -3
  4. package/blog/en/list_i18n_technologies/frameworks/react-native.md +3 -3
  5. package/blog/en/list_i18n_technologies/frameworks/react.md +3 -3
  6. package/blog/en/list_i18n_technologies/frameworks/svelte.md +3 -3
  7. package/blog/en/list_i18n_technologies/frameworks/vue.md +3 -3
  8. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +3 -3
  9. package/dist/cjs/common.cjs +3 -1
  10. package/dist/cjs/common.cjs.map +1 -1
  11. package/dist/cjs/generated/blog.entry.cjs +0 -1
  12. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  13. package/dist/cjs/generated/docs.entry.cjs +39 -20
  14. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  15. package/dist/cjs/generated/frequentQuestions.entry.cjs +0 -1
  16. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  17. package/dist/cjs/generated/legal.entry.cjs +0 -1
  18. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  19. package/dist/esm/common.mjs +3 -1
  20. package/dist/esm/common.mjs.map +1 -1
  21. package/dist/esm/generated/docs.entry.mjs +39 -19
  22. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  23. package/dist/types/common.d.ts.map +1 -1
  24. package/dist/types/generated/docs.entry.d.ts +2 -1
  25. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  26. package/docs/ar/benchmark/nextjs.md +1 -1
  27. package/docs/ar/benchmark/solid.md +1 -1
  28. package/docs/ar/benchmark/svelte.md +1 -1
  29. package/docs/ar/benchmark/tanstack.md +1 -1
  30. package/docs/ar/dictionary/markdown.md +165 -7
  31. package/docs/ar/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  32. package/docs/ar/intlayer_with_angular_21.md +412 -0
  33. package/docs/bn/intlayer_with_angular_21.md +412 -0
  34. package/docs/cs/intlayer_with_angular_21.md +412 -0
  35. package/docs/de/benchmark/nextjs.md +1 -1
  36. package/docs/de/benchmark/solid.md +1 -1
  37. package/docs/de/benchmark/svelte.md +1 -1
  38. package/docs/de/benchmark/tanstack.md +1 -1
  39. package/docs/de/dictionary/markdown.md +165 -7
  40. package/docs/de/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  41. package/docs/de/intlayer_with_angular_21.md +412 -0
  42. package/docs/en/benchmark/nextjs.md +1 -1
  43. package/docs/en/benchmark/solid.md +1 -1
  44. package/docs/en/benchmark/svelte.md +1 -1
  45. package/docs/en/benchmark/tanstack.md +1 -1
  46. package/docs/en/dictionary/markdown.md +167 -7
  47. package/docs/en/intlayer_with_adonisjs.md +3 -3
  48. package/docs/en/intlayer_with_analog.md +3 -3
  49. package/docs/en/{intlayer_with_angular.md → intlayer_with_angular_19.md} +10 -9
  50. package/docs/en/intlayer_with_angular_21.md +412 -0
  51. package/docs/en/intlayer_with_astro.md +3 -3
  52. package/docs/en/intlayer_with_astro_lit.md +3 -3
  53. package/docs/en/intlayer_with_astro_preact.md +3 -3
  54. package/docs/en/intlayer_with_astro_react.md +3 -3
  55. package/docs/en/intlayer_with_astro_solid.md +3 -3
  56. package/docs/en/intlayer_with_astro_svelte.md +3 -3
  57. package/docs/en/intlayer_with_astro_vanilla.md +3 -3
  58. package/docs/en/intlayer_with_astro_vue.md +3 -3
  59. package/docs/en/intlayer_with_create_react_app.md +3 -3
  60. package/docs/en/intlayer_with_express.md +3 -3
  61. package/docs/en/intlayer_with_fastify.md +3 -3
  62. package/docs/en/intlayer_with_hono.md +3 -3
  63. package/docs/en/intlayer_with_lynx+react.md +3 -3
  64. package/docs/en/intlayer_with_nestjs.md +3 -3
  65. package/docs/en/intlayer_with_next-i18next.md +3 -3
  66. package/docs/en/intlayer_with_next-intl.md +3 -3
  67. package/docs/en/intlayer_with_nextjs_14.md +3 -3
  68. package/docs/en/intlayer_with_nextjs_15.md +3 -3
  69. package/docs/en/intlayer_with_nextjs_16.md +3 -3
  70. package/docs/en/intlayer_with_nextjs_compiler.md +3 -3
  71. package/docs/en/intlayer_with_nextjs_no_locale_path.md +3 -3
  72. package/docs/en/intlayer_with_nextjs_page_router.md +3 -3
  73. package/docs/en/intlayer_with_nuxt.md +3 -3
  74. package/docs/en/intlayer_with_react_native+expo.md +3 -3
  75. package/docs/en/intlayer_with_react_router_v7.md +3 -3
  76. package/docs/en/intlayer_with_react_router_v7_fs_routes.md +3 -3
  77. package/docs/en/intlayer_with_svelte_kit.md +3 -3
  78. package/docs/en/intlayer_with_tanstack+solid.md +3 -3
  79. package/docs/en/intlayer_with_tanstack.md +3 -3
  80. package/docs/en/intlayer_with_vanilla.md +3 -3
  81. package/docs/en/intlayer_with_vite+lit.md +3 -3
  82. package/docs/en/intlayer_with_vite+preact.md +3 -3
  83. package/docs/en/intlayer_with_vite+react.md +3 -3
  84. package/docs/en/intlayer_with_vite+react_compiler.md +3 -3
  85. package/docs/en/intlayer_with_vite+solid.md +3 -3
  86. package/docs/en/intlayer_with_vite+svelte.md +3 -3
  87. package/docs/en/intlayer_with_vite+vanilla.md +3 -3
  88. package/docs/en/intlayer_with_vite+vue.md +3 -3
  89. package/docs/en-GB/benchmark/nextjs.md +1 -1
  90. package/docs/en-GB/benchmark/solid.md +1 -1
  91. package/docs/en-GB/benchmark/svelte.md +1 -1
  92. package/docs/en-GB/benchmark/tanstack.md +1 -1
  93. package/docs/en-GB/dictionary/markdown.md +161 -0
  94. package/docs/en-GB/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  95. package/docs/en-GB/intlayer_with_angular_21.md +412 -0
  96. package/docs/es/benchmark/nextjs.md +1 -1
  97. package/docs/es/benchmark/solid.md +1 -1
  98. package/docs/es/benchmark/svelte.md +1 -1
  99. package/docs/es/benchmark/tanstack.md +1 -1
  100. package/docs/es/dictionary/markdown.md +165 -7
  101. package/docs/es/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  102. package/docs/es/intlayer_with_angular_21.md +412 -0
  103. package/docs/fr/benchmark/nextjs.md +1 -1
  104. package/docs/fr/benchmark/solid.md +1 -1
  105. package/docs/fr/benchmark/svelte.md +1 -1
  106. package/docs/fr/benchmark/tanstack.md +1 -1
  107. package/docs/fr/dictionary/markdown.md +165 -7
  108. package/docs/fr/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  109. package/docs/fr/intlayer_with_angular_21.md +412 -0
  110. package/docs/hi/benchmark/nextjs.md +1 -1
  111. package/docs/hi/benchmark/solid.md +1 -1
  112. package/docs/hi/benchmark/svelte.md +1 -1
  113. package/docs/hi/benchmark/tanstack.md +1 -1
  114. package/docs/hi/dictionary/markdown.md +165 -7
  115. package/docs/hi/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  116. package/docs/hi/intlayer_with_angular_21.md +412 -0
  117. package/docs/id/benchmark/nextjs.md +1 -1
  118. package/docs/id/benchmark/solid.md +1 -1
  119. package/docs/id/benchmark/svelte.md +1 -1
  120. package/docs/id/benchmark/tanstack.md +1 -1
  121. package/docs/id/dictionary/markdown.md +165 -7
  122. package/docs/id/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  123. package/docs/id/intlayer_with_angular_21.md +412 -0
  124. package/docs/it/benchmark/nextjs.md +1 -1
  125. package/docs/it/benchmark/solid.md +1 -1
  126. package/docs/it/benchmark/svelte.md +1 -1
  127. package/docs/it/benchmark/tanstack.md +1 -1
  128. package/docs/it/dictionary/markdown.md +165 -7
  129. package/docs/it/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  130. package/docs/it/intlayer_with_angular_21.md +412 -0
  131. package/docs/ja/benchmark/nextjs.md +1 -1
  132. package/docs/ja/benchmark/solid.md +1 -1
  133. package/docs/ja/benchmark/svelte.md +1 -1
  134. package/docs/ja/benchmark/tanstack.md +1 -1
  135. package/docs/ja/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  136. package/docs/ja/intlayer_with_angular_21.md +412 -0
  137. package/docs/ko/benchmark/nextjs.md +1 -1
  138. package/docs/ko/benchmark/solid.md +1 -1
  139. package/docs/ko/benchmark/svelte.md +1 -1
  140. package/docs/ko/benchmark/tanstack.md +1 -1
  141. package/docs/ko/dictionary/markdown.md +165 -7
  142. package/docs/ko/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  143. package/docs/ko/intlayer_with_angular_21.md +412 -0
  144. package/docs/nl/intlayer_with_angular_21.md +412 -0
  145. package/docs/pl/benchmark/nextjs.md +1 -1
  146. package/docs/pl/benchmark/solid.md +1 -1
  147. package/docs/pl/benchmark/svelte.md +1 -1
  148. package/docs/pl/benchmark/tanstack.md +1 -1
  149. package/docs/pl/dictionary/markdown.md +165 -7
  150. package/docs/pl/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  151. package/docs/pl/intlayer_with_angular_21.md +412 -0
  152. package/docs/pt/benchmark/nextjs.md +1 -1
  153. package/docs/pt/benchmark/solid.md +1 -1
  154. package/docs/pt/benchmark/svelte.md +1 -1
  155. package/docs/pt/benchmark/tanstack.md +1 -1
  156. package/docs/pt/dictionary/markdown.md +165 -7
  157. package/docs/pt/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  158. package/docs/pt/intlayer_with_angular_21.md +412 -0
  159. package/docs/ru/benchmark/nextjs.md +1 -1
  160. package/docs/ru/benchmark/solid.md +1 -1
  161. package/docs/ru/benchmark/svelte.md +1 -1
  162. package/docs/ru/benchmark/tanstack.md +1 -1
  163. package/docs/ru/dictionary/markdown.md +161 -0
  164. package/docs/ru/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  165. package/docs/ru/intlayer_with_angular_21.md +412 -0
  166. package/docs/tr/benchmark/nextjs.md +1 -1
  167. package/docs/tr/benchmark/solid.md +1 -1
  168. package/docs/tr/benchmark/svelte.md +1 -1
  169. package/docs/tr/benchmark/tanstack.md +1 -1
  170. package/docs/tr/dictionary/markdown.md +165 -7
  171. package/docs/tr/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  172. package/docs/tr/intlayer_with_angular_21.md +412 -0
  173. package/docs/uk/benchmark/nextjs.md +1 -1
  174. package/docs/uk/benchmark/solid.md +1 -1
  175. package/docs/uk/benchmark/svelte.md +1 -1
  176. package/docs/uk/benchmark/tanstack.md +1 -1
  177. package/docs/uk/dictionary/markdown.md +165 -7
  178. package/docs/uk/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  179. package/docs/uk/intlayer_with_angular_21.md +412 -0
  180. package/docs/ur/intlayer_with_angular_21.md +412 -0
  181. package/docs/vi/benchmark/nextjs.md +1 -1
  182. package/docs/vi/benchmark/solid.md +1 -1
  183. package/docs/vi/benchmark/svelte.md +1 -1
  184. package/docs/vi/benchmark/tanstack.md +1 -1
  185. package/docs/vi/dictionary/markdown.md +165 -7
  186. package/docs/vi/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  187. package/docs/vi/intlayer_with_angular_21.md +412 -0
  188. package/docs/zh/benchmark/nextjs.md +1 -1
  189. package/docs/zh/benchmark/solid.md +1 -1
  190. package/docs/zh/benchmark/svelte.md +1 -1
  191. package/docs/zh/benchmark/tanstack.md +1 -1
  192. package/docs/zh/dictionary/markdown.md +165 -7
  193. package/docs/zh/{intlayer_with_angular.md → intlayer_with_angular_19.md} +8 -7
  194. package/docs/zh/intlayer_with_angular_21.md +412 -0
  195. package/docs/zh-TW/intlayer_with_angular_21.md +412 -0
  196. package/package.json +7 -7
  197. package/src/common.ts +12 -6
  198. package/src/generated/docs.entry.ts +39 -19
@@ -0,0 +1,412 @@
1
+ ---
2
+ createdAt: 2025-04-18
3
+ updatedAt: 2026-05-06
4
+ title: Angular i18n - 2026年如何翻譯一個Angular 21應用程式(Vite)
5
+ description: 了解如何使您的Angular網站支援多語言。按照文件進行國際化(i18n)和翻譯。
6
+ keywords:
7
+ - 國際化
8
+ - 文件
9
+ - Intlayer
10
+ - Angular
11
+ - JavaScript
12
+ slugs:
13
+ - doc
14
+ - environment
15
+ - angular
16
+ applicationTemplate: https://github.com/aymericzip/intlayer-angular-21-template
17
+ applicationShowcase: https://intlayer-angular-21-template.vercel.app/
18
+ history:
19
+ - version: 8.9.0
20
+ date: 2026-05-04
21
+ changes: "更新Solid useIntlayer API的用法以直接存取屬性"
22
+ - version: 8.0.0
23
+ date: 2026-01-26
24
+ changes: "發布穩定版"
25
+ - version: 8.0.0
26
+ date: 2025-12-30
27
+ changes: "增加init命令"
28
+ - version: 5.5.10
29
+ date: 2025-06-29
30
+ changes: "初始版本"
31
+ ---
32
+
33
+ # 使用Intlayer翻譯您的Angular 21(Vite)網站 | 國際化 (i18n)
34
+
35
+ ## 目錄
36
+
37
+ <TOC/>
38
+
39
+ ## 什麼是 Intlayer?
40
+
41
+ **Intlayer** 是一個創新的開源國際化(i18n)庫,旨在簡化現代Web應用程式中的多語言支援。
42
+
43
+ 藉助Intlayer,您可以:
44
+
45
+ - **輕鬆管理翻譯**:使用組件層級的宣告式字典。
46
+ - **動態在地化**:元資料、路由和內容。
47
+ - **確保TypeScript支援**:使用自動生成的型別,改善自動補全和錯誤檢測。
48
+ - **受益於進階功能**:如動態區域設定檢測和切換。
49
+
50
+ ---
51
+
52
+ ## 在Angular應用程式中設定Intlayer的逐步指南
53
+
54
+ <Tabs defaultTab="code">
55
+ <Tab label="程式碼" value="code">
56
+
57
+ <iframe
58
+ src="https://ide.intlayer.org/aymericzip/intlayer-angular-21-template?file=intlayer.config.ts"
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"
60
+ title="Demo CodeSandbox - 如何使用Intlayer進行應用程式國際化"
61
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
62
+ loading="lazy"
63
+ />
64
+
65
+ </Tab>
66
+ <Tab label="展示" value="demo">
67
+
68
+ <iframe
69
+ src="https://intlayer-angular-21-template.vercel.app/"
70
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
71
+ title="Demo - intlayer-angular-template"
72
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
73
+ loading="lazy"
74
+ />
75
+
76
+ </Tab>
77
+ </Tabs>
78
+
79
+ 在GitHub上查看 [應用程式模板](https://github.com/aymericzip/intlayer-angular-21-template)。
80
+
81
+ ### 步驟 1:安裝依賴項
82
+
83
+ 使用npm安裝必要的套件:
84
+
85
+ ```bash packageManager="npm"
86
+ npm install intlayer angular-intlayer
87
+ npm install @angular-builders/custom-esbuild --save-dev
88
+ npx intlayer init
89
+ ```
90
+
91
+ ```bash packageManager="pnpm"
92
+ pnpm add intlayer angular-intlayer
93
+ pnpm add @angular-builders/custom-esbuild --save-dev
94
+ pnpm intlayer init
95
+ ```
96
+
97
+ ```bash packageManager="yarn"
98
+ yarn add intlayer angular-intlayer
99
+ yarn add @angular-builders/custom-esbuild --save-dev
100
+ yarn intlayer init
101
+ ```
102
+
103
+ ```bash packageManager="bun"
104
+ bun add intlayer angular-intlayer
105
+ bun add @angular-builders/custom-esbuild --dev
106
+ bun x intlayer init
107
+ ```
108
+
109
+ - **intlayer**
110
+
111
+ 核心套件,提供了配置管理、翻譯、[內容宣告](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh-TW/dictionary/content_file.md)、轉譯和[CLI命令](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh-TW/cli/index.md)等國際化工具。
112
+
113
+ - **angular-intlayer**
114
+ 將Intlayer與Angular應用程式整合的套件。它為Angular的國際化提供了上下文提供者(Providers)和Hooks。
115
+
116
+ - **@angular-builders/custom-esbuild**
117
+ 需要它來自定義Angular CLI的esbuild配置。
118
+
119
+ ### 步驟 2:配置您的專案
120
+
121
+ 創建一個配置文件以配置您應用程式的語言:
122
+
123
+ ```typescript fileName="intlayer.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
124
+ import { Locales, type IntlayerConfig } from "intlayer";
125
+
126
+ const config: IntlayerConfig = {
127
+ internationalization: {
128
+ locales: [
129
+ Locales.ENGLISH,
130
+ Locales.FRENCH,
131
+ Locales.SPANISH,
132
+ // 您支援的其他語言
133
+ ],
134
+ defaultLocale: Locales.ENGLISH,
135
+ },
136
+ };
137
+
138
+ export default config;
139
+ ```
140
+
141
+ > 透過此配置文件,您可以設定在地化的URL、中間件重定向、Cookie名稱、內容宣告的位置和副檔名、禁用控制台中的Intlayer日誌等。獲取所有可用參數的完整列表,請參考[配置文件](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh-TW/configuration.md)。
142
+
143
+ ### 步驟 3:在Angular配置中整合Intlayer
144
+
145
+ 要將Intlayer與Angular CLI整合,您需要使用自定義構建器。本指南假設您使用的是 Vite/esbuild(Angular 21專案的預設設定)。
146
+
147
+ 首先,修改您的 `angular.json`,使用自定義的esbuild構建器。更新 `build` 和 `serve` 配置:
148
+
149
+ ```json5 fileName="angular.json"
150
+ {
151
+ "projects": {
152
+ "your-app-name": {
153
+ "architect": {
154
+ "build": {
155
+ "builder": "@angular-builders/custom-esbuild:application", // replace "@angular/build:application"
156
+ "options": {
157
+ "define": {
158
+ "process.env": "{}",
159
+ },
160
+ "plugins": ["./esbuild.plugins.ts"],
161
+ "browser": "src/main.ts",
162
+ // ...
163
+ },
164
+ },
165
+ "serve": {
166
+ "builder": "@angular-builders/custom-esbuild:dev-server", // replace "@angular/build:dev-server"
167
+ "options": {
168
+ "prebundle": {
169
+ "exclude": [
170
+ "intlayer",
171
+ "angular-intlayer",
172
+ "@intlayer/config/built",
173
+ "@intlayer/core"
174
+ ]
175
+ },
176
+ },
177
+ },
178
+ },
179
+ },
180
+ }
181
+ ```
182
+
183
+ > 請確保將 `angular.json` 中的 `your-app-name` 替換為您專案的實際名稱。
184
+
185
+ 接下來,在專案的根目錄中創建一個 `esbuild.plugins.ts` 文件:
186
+
187
+ ```typescript fileName="esbuild.plugins.ts"
188
+ import { intlayerEsbuildPlugin } from "angular-intlayer/esbuild";
189
+
190
+ export default [intlayerEsbuildPlugin()];
191
+ ```
192
+
193
+ > `intlayerEsbuildPlugin` 函數負責使用Intlayer配置esbuild。它注入插件來處理內容宣告文件,並針對最佳性能進行了設置。
194
+
195
+ > **NX 用戶**:NX 的 Angular 建構器透過 Node 的原生 ESM 解析載入外掛程式檔案,且不會即時編譯 TypeScript 外掛程式檔案。請改用 `.mjs` 檔案,並相應地更新 `angular.json` 中的 `plugins` 參照:
196
+ >
197
+ > ```javascript fileName="esbuild.plugins.mjs"
198
+ > import { intlayerEsbuildPlugin } from "angular-intlayer/esbuild";
199
+ >
200
+ > export default [intlayerEsbuildPlugin()];
201
+ > ```
202
+ >
203
+ > 然後在 `angular.json` 中指向 `"./esbuild.plugins.mjs"`,而不是 `"./esbuild.plugins.ts"`。
204
+
205
+ ### 步驟 4:宣告您的內容
206
+
207
+ 創建並管理您的內容宣告文件以存儲翻譯:
208
+
209
+ ```tsx fileName="src/app/app.content.ts" contentDeclarationFormat=["typescript", "esm", "cjs"]
210
+ import { t, type Dictionary } from "intlayer";
211
+
212
+ const appContent = {
213
+ key: "app",
214
+ content: {
215
+ title: t({
216
+ en: "Hello",
217
+ fr: "Bonjour",
218
+ es: "Hola",
219
+ }),
220
+ congratulations: t({
221
+ en: "Congratulations! Your app is running. 🎉",
222
+ fr: "Félicitations! Votre application est en cours d'exécution. 🎉",
223
+ es: "¡Felicidades! Tu aplicación está en ejecución. 🎉",
224
+ }),
225
+ exploreDocs: t({
226
+ en: "Explore the Docs",
227
+ fr: "Explorer les Docs",
228
+ es: "Explorar los Docs",
229
+ }),
230
+ learnWithTutorials: t({
231
+ en: "Learn with Tutorials",
232
+ fr: "Apprendre avec les Tutoriels",
233
+ es: "Aprender con los Tutorios",
234
+ }),
235
+ cliDocs: "CLI Docs",
236
+ angularLanguageService: t({
237
+ en: "Angular Language Service",
238
+ fr: "Service de Langage Angular",
239
+ es: "Servicio de Lenguaje Angular",
240
+ }),
241
+ angularDevTools: "Angular DevTools",
242
+ github: "Github",
243
+ twitter: "Twitter",
244
+ youtube: "Youtube",
245
+ },
246
+ } satisfies Dictionary;
247
+
248
+ export default appContent;
249
+ ```
250
+
251
+ > 您的內容宣告可以定義在應用程式的任何位置,只需將其包含在 `contentDir` 目錄(預設為 `./src`)中,並且符合內容宣告的文件副檔名(預設為 `.content.{json,ts,tsx,js,jsx,mjs,cjs}`)。
252
+
253
+ > 詳細資訊請參考 [內容宣告文件](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh-TW/dictionary/content_file.md)。
254
+
255
+ ### 步驟 5:在程式碼中使用Intlayer
256
+
257
+ 要在整個Angular應用程式中利用Intlayer的國際化功能,您需要在應用程式配置中提供Intlayer。
258
+
259
+ ```typescript fileName="src/app/app.config.ts"
260
+ import { ApplicationConfig } from "@angular/core";
261
+ import { provideRouter } from "@angular/router";
262
+ import { provideIntlayer } from "angular-intlayer";
263
+ import { routes } from "./app.routes";
264
+
265
+ export const appConfig: ApplicationConfig = {
266
+ providers: [
267
+ provideRouter(routes),
268
+ provideIntlayer(), // 在此添加Intlayer提供者
269
+ ],
270
+ };
271
+ ```
272
+
273
+ 然後,您可以在任何組件中使用 `useIntlayer` 功能。
274
+
275
+ ```typescript fileName="src/app/app.component.ts"
276
+ import { Component } from "@angular/core";
277
+ import { RouterOutlet } from "@angular/router";
278
+ import { useIntlayer } from "angular-intlayer";
279
+
280
+ @Component({
281
+ selector: "app-root",
282
+ standalone: true,
283
+ imports: [RouterOutlet],
284
+ templateUrl: "./app.component.html",
285
+ styleUrl: "./app.component.css",
286
+ })
287
+ export class AppComponent {
288
+ content = useIntlayer("app");
289
+ }
290
+ ```
291
+
292
+ 在您的模板中:
293
+
294
+ ```html fileName="src/app/app.component.html"
295
+ <div class="content">
296
+ <h1>{{ content().title }}</h1>
297
+ <p>{{ content().congratulations }}</p>
298
+ </div>
299
+ ```
300
+
301
+ Intlayer 內容將作為 `Signal` 返回,因此您可以透過呼叫信號來訪問值:`content().title`。
302
+
303
+ ### (可選)步驟 6:更改內容的語言
304
+
305
+ 要更改內容的語言,您可以使用 `useLocale` 函數提供的 `setLocale` 函數。這允許您設定應用程式的區域設定,並相應更新內容。
306
+
307
+ 創建一個用於切換語言的組件:
308
+
309
+ ```typescript fileName="src/app/locale-switcher.component.ts"
310
+ import { Component } from "@angular/core";
311
+ import { CommonModule } from "@angular/common";
312
+ import { useLocale } from "angular-intlayer";
313
+
314
+ @Component({
315
+ selector: "app-locale-switcher",
316
+ standalone: true,
317
+ imports: [CommonModule],
318
+ template: `
319
+ <div class="locale-switcher">
320
+ <select
321
+ [value]="locale()"
322
+ (change)="setLocale($any($event.target).value)"
323
+ >
324
+ @for (loc of availableLocales; track loc) {
325
+ <option [value]="loc">{{ loc }}</option>
326
+ }
327
+ </select>
328
+ </div>
329
+ `,
330
+ })
331
+ export class LocaleSwitcherComponent {
332
+ localeCtx = useLocale();
333
+
334
+ locale = this.localeCtx.locale;
335
+ availableLocales = this.localeCtx.availableLocales;
336
+ setLocale = this.localeCtx.setLocale;
337
+ }
338
+ ```
339
+
340
+ 然後,在 `app.component.ts` 中使用此組件:
341
+
342
+ ```typescript fileName="src/app/app.component.ts"
343
+ import { Component } from "@angular/core";
344
+ import { RouterOutlet } from "@angular/router";
345
+ import { useIntlayer } from "angular-intlayer";
346
+ import { LocaleSwitcherComponent } from "./locale-switcher.component";
347
+
348
+ @Component({
349
+ selector: "app-root",
350
+ standalone: true,
351
+ imports: [RouterOutlet, LocaleSwitcherComponent],
352
+ templateUrl: "./app.component.html",
353
+ styleUrl: "./app.component.css",
354
+ })
355
+ export class AppComponent {
356
+ content = useIntlayer("app");
357
+ }
358
+ ```
359
+
360
+ ### 配置TypeScript
361
+
362
+ Intlayer使用模組擴充(Module Augmentation)來獲得TypeScript的好處,並使您的程式碼庫更健壯。
363
+
364
+ ![自動補全](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
365
+
366
+ ![翻譯錯誤](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
367
+
368
+ 請確保您的TypeScript配置包含了自動生成的類型。
369
+
370
+ ```json5 fileName="tsconfig.json"
371
+ {
372
+ // ... 您現有的TypeScript配置
373
+ "include": [
374
+ // ... 您現有的TypeScript配置
375
+ ".intlayer/**/*.ts", // 包含自動生成的類型
376
+ ],
377
+ }
378
+ ```
379
+
380
+ ### Git配置
381
+
382
+ 建議忽略由Intlayer生成的文件。這可以避免將它們提交到您的Git存儲庫。
383
+
384
+ 為此,您可以將以下說明添加到您的 `.gitignore` 文件中:
385
+
386
+ ```bash
387
+ # 忽略由Intlayer生成的文件
388
+ .intlayer
389
+ ```
390
+
391
+ ### VS Code 擴展
392
+
393
+ 為了提升您在Intlayer中的開發體驗,您可以安裝官方的 **Intlayer VS Code 擴展**。
394
+
395
+ [從VS Code應用市場安裝](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
396
+
397
+ 該擴展提供:
398
+
399
+ - 翻譯鍵的**自動補全**。
400
+ - 缺失翻譯的**即時錯誤檢測**。
401
+ - 已翻譯內容的**內聯預覽**。
402
+ - 輕鬆創建和更新翻譯的**快速操作**。
403
+
404
+ 有關如何使用該擴展的更多詳細資訊,請參閱 [Intlayer VS Code 擴展範例文件](https://intlayer.org/doc/vs-code-extension)。
405
+
406
+ ---
407
+
408
+ ### 深入了解
409
+
410
+ 想要深入了解,您可以實現[視覺化編輯器](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh-TW/intlayer_visual_editor.md)或使用[CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh-TW/intlayer_CMS.md)外部化您的內容。
411
+
412
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/docs",
3
- "version": "8.10.1",
3
+ "version": "8.11.2",
4
4
  "private": false,
5
5
  "description": "Intlayer documentation",
6
6
  "keywords": [
@@ -72,20 +72,20 @@
72
72
  "watch": "webpack --config ./webpack.config.ts --watch"
73
73
  },
74
74
  "dependencies": {
75
- "@intlayer/config": "8.10.1",
76
- "@intlayer/core": "8.10.1",
77
- "@intlayer/types": "8.10.1"
75
+ "@intlayer/config": "8.11.2",
76
+ "@intlayer/core": "8.11.2",
77
+ "@intlayer/types": "8.11.2"
78
78
  },
79
79
  "devDependencies": {
80
- "@intlayer/api": "8.10.1",
81
- "@intlayer/cli": "8.10.1",
80
+ "@intlayer/api": "8.11.2",
81
+ "@intlayer/cli": "8.11.2",
82
82
  "@types/node": "25.9.1",
83
83
  "@utils/ts-config": "1.0.4",
84
84
  "@utils/ts-config-types": "1.0.4",
85
85
  "@utils/tsdown-config": "1.0.4",
86
86
  "fast-glob": "3.3.3",
87
87
  "rimraf": "6.1.3",
88
- "tsdown": "0.22.00",
88
+ "tsdown": "0.22.1",
89
89
  "typescript": "6.0.3",
90
90
  "vitest": "4.1.7"
91
91
  },
package/src/common.ts CHANGED
@@ -125,14 +125,20 @@ export const getFileMetadataRecord = async <
125
125
  files: F,
126
126
  locale: LocalesValues = defaultLocale as LocalesValues
127
127
  ): Promise<Record<keyof F, FileMetadata>> => {
128
- const filesEntries = await Promise.all(
129
- Object.entries(files).map(async ([key]) => [
130
- key,
131
- await getFileMetadata(files, key as keyof F, locale),
132
- ])
128
+ const results = await Promise.allSettled(
129
+ Object.entries(files).map(async ([key]) => {
130
+ const metadata = await getFileMetadata(files, key as keyof F, locale);
131
+ return [key, metadata] as [string, FileMetadata];
132
+ })
133
133
  );
134
+ const filesEntries = results
135
+ .filter(
136
+ (r): r is PromiseFulfilledResult<[string, FileMetadata]> =>
137
+ r.status === 'fulfilled'
138
+ )
139
+ .map((r) => r.value);
134
140
  const filesResult = Object.fromEntries(filesEntries);
135
- return filesResult;
141
+ return filesResult as Record<keyof F, FileMetadata>;
136
142
  };
137
143
 
138
144
  export const getFileMetadataBySlug = async <
@@ -1193,25 +1193,45 @@ export const docsEntry = {
1193
1193
  vi: readLocale('intlayer_with_analog.md', 'vi'),
1194
1194
  uk: readLocale('intlayer_with_analog.md', 'uk'),
1195
1195
  } as unknown as Record<LocalesValues, Promise<string>>,
1196
- './docs/en/intlayer_with_angular.md': {
1197
- en: readLocale('intlayer_with_angular.md', 'en'),
1198
- ru: readLocale('intlayer_with_angular.md', 'ru'),
1199
- ja: readLocale('intlayer_with_angular.md', 'ja'),
1200
- fr: readLocale('intlayer_with_angular.md', 'fr'),
1201
- ko: readLocale('intlayer_with_angular.md', 'ko'),
1202
- zh: readLocale('intlayer_with_angular.md', 'zh'),
1203
- es: readLocale('intlayer_with_angular.md', 'es'),
1204
- de: readLocale('intlayer_with_angular.md', 'de'),
1205
- ar: readLocale('intlayer_with_angular.md', 'ar'),
1206
- it: readLocale('intlayer_with_angular.md', 'it'),
1207
- 'en-GB': readLocale('intlayer_with_angular.md', 'en-GB'),
1208
- pt: readLocale('intlayer_with_angular.md', 'pt'),
1209
- hi: readLocale('intlayer_with_angular.md', 'hi'),
1210
- tr: readLocale('intlayer_with_angular.md', 'tr'),
1211
- pl: readLocale('intlayer_with_angular.md', 'pl'),
1212
- id: readLocale('intlayer_with_angular.md', 'id'),
1213
- vi: readLocale('intlayer_with_angular.md', 'vi'),
1214
- uk: readLocale('intlayer_with_angular.md', 'uk'),
1196
+ './docs/en/intlayer_with_angular_19.md': {
1197
+ en: readLocale('intlayer_with_angular_19.md', 'en'),
1198
+ ru: readLocale('intlayer_with_angular_19.md', 'ru'),
1199
+ ja: readLocale('intlayer_with_angular_19.md', 'ja'),
1200
+ fr: readLocale('intlayer_with_angular_19.md', 'fr'),
1201
+ ko: readLocale('intlayer_with_angular_19.md', 'ko'),
1202
+ zh: readLocale('intlayer_with_angular_19.md', 'zh'),
1203
+ es: readLocale('intlayer_with_angular_19.md', 'es'),
1204
+ de: readLocale('intlayer_with_angular_19.md', 'de'),
1205
+ ar: readLocale('intlayer_with_angular_19.md', 'ar'),
1206
+ it: readLocale('intlayer_with_angular_19.md', 'it'),
1207
+ 'en-GB': readLocale('intlayer_with_angular_19.md', 'en-GB'),
1208
+ pt: readLocale('intlayer_with_angular_19.md', 'pt'),
1209
+ hi: readLocale('intlayer_with_angular_19.md', 'hi'),
1210
+ tr: readLocale('intlayer_with_angular_19.md', 'tr'),
1211
+ pl: readLocale('intlayer_with_angular_19.md', 'pl'),
1212
+ id: readLocale('intlayer_with_angular_19.md', 'id'),
1213
+ vi: readLocale('intlayer_with_angular_19.md', 'vi'),
1214
+ uk: readLocale('intlayer_with_angular_19.md', 'uk'),
1215
+ } as unknown as Record<LocalesValues, Promise<string>>,
1216
+ './docs/en/intlayer_with_angular_21.md': {
1217
+ en: readLocale('intlayer_with_angular_21.md', 'en'),
1218
+ ru: readLocale('intlayer_with_angular_21.md', 'ru'),
1219
+ ja: readLocale('intlayer_with_angular_21.md', 'ja'),
1220
+ fr: readLocale('intlayer_with_angular_21.md', 'fr'),
1221
+ ko: readLocale('intlayer_with_angular_21.md', 'ko'),
1222
+ zh: readLocale('intlayer_with_angular_21.md', 'zh'),
1223
+ es: readLocale('intlayer_with_angular_21.md', 'es'),
1224
+ de: readLocale('intlayer_with_angular_21.md', 'de'),
1225
+ ar: readLocale('intlayer_with_angular_21.md', 'ar'),
1226
+ it: readLocale('intlayer_with_angular_21.md', 'it'),
1227
+ 'en-GB': readLocale('intlayer_with_angular_21.md', 'en-GB'),
1228
+ pt: readLocale('intlayer_with_angular_21.md', 'pt'),
1229
+ hi: readLocale('intlayer_with_angular_21.md', 'hi'),
1230
+ tr: readLocale('intlayer_with_angular_21.md', 'tr'),
1231
+ pl: readLocale('intlayer_with_angular_21.md', 'pl'),
1232
+ id: readLocale('intlayer_with_angular_21.md', 'id'),
1233
+ vi: readLocale('intlayer_with_angular_21.md', 'vi'),
1234
+ uk: readLocale('intlayer_with_angular_21.md', 'uk'),
1215
1235
  } as unknown as Record<LocalesValues, Promise<string>>,
1216
1236
  './docs/en/intlayer_with_astro.md': {
1217
1237
  en: readLocale('intlayer_with_astro.md', 'en'),