@intlayer/docs 7.5.9 → 7.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/cjs/generated/docs.entry.cjs +57 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +57 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +3 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/cli/ci.md +137 -0
- package/docs/ar/cli/index.md +7 -1
- package/docs/ar/cli/list.md +39 -2
- package/docs/ar/cli/list_projects.md +131 -0
- package/docs/ar/cli/push.md +1 -1
- package/docs/ar/configuration.md +3 -3
- package/docs/ar/interest_of_intlayer.md +1 -1
- package/docs/ar/intlayer_CMS.md +25 -5
- package/docs/ar/intlayer_with_express.md +1 -0
- package/docs/ar/intlayer_with_fastify.md +516 -0
- package/docs/ar/readme.md +1 -1
- package/docs/de/cli/ci.md +137 -0
- package/docs/de/cli/index.md +7 -1
- package/docs/de/cli/list.md +39 -2
- package/docs/de/cli/list_projects.md +130 -0
- package/docs/de/cli/push.md +1 -1
- package/docs/de/configuration.md +3 -3
- package/docs/de/interest_of_intlayer.md +1 -1
- package/docs/de/intlayer_CMS.md +25 -5
- package/docs/de/intlayer_with_express.md +1 -0
- package/docs/de/intlayer_with_fastify.md +449 -0
- package/docs/de/readme.md +1 -1
- package/docs/en/cli/ci.md +137 -0
- package/docs/en/cli/index.md +14 -1
- package/docs/en/cli/list.md +39 -2
- package/docs/en/cli/list_projects.md +128 -0
- package/docs/en/cli/push.md +1 -1
- package/docs/en/configuration.md +3 -3
- package/docs/en/interest_of_intlayer.md +2 -2
- package/docs/en/intlayer_CMS.md +25 -5
- package/docs/en/intlayer_with_express.md +1 -0
- package/docs/en/intlayer_with_fastify.md +439 -0
- package/docs/en/readme.md +3 -1
- package/docs/en-GB/cli/ci.md +137 -0
- package/docs/en-GB/cli/index.md +7 -1
- package/docs/en-GB/cli/list.md +39 -2
- package/docs/en-GB/cli/list_projects.md +130 -0
- package/docs/en-GB/cli/push.md +1 -1
- package/docs/en-GB/configuration.md +3 -3
- package/docs/en-GB/interest_of_intlayer.md +1 -1
- package/docs/en-GB/intlayer_CMS.md +25 -5
- package/docs/en-GB/intlayer_with_express.md +1 -0
- package/docs/en-GB/intlayer_with_fastify.md +445 -0
- package/docs/en-GB/readme.md +3 -1
- package/docs/es/cli/ci.md +137 -0
- package/docs/es/cli/index.md +7 -1
- package/docs/es/cli/list.md +39 -2
- package/docs/es/cli/list_projects.md +130 -0
- package/docs/es/cli/push.md +1 -1
- package/docs/es/configuration.md +3 -3
- package/docs/es/interest_of_intlayer.md +1 -1
- package/docs/es/intlayer_CMS.md +25 -5
- package/docs/es/intlayer_with_express.md +1 -0
- package/docs/es/intlayer_with_fastify.md +480 -0
- package/docs/es/readme.md +1 -1
- package/docs/fr/cli/ci.md +137 -0
- package/docs/fr/cli/index.md +7 -1
- package/docs/fr/cli/list.md +39 -2
- package/docs/fr/cli/list_projects.md +131 -0
- package/docs/fr/cli/push.md +1 -1
- package/docs/fr/configuration.md +3 -3
- package/docs/fr/interest_of_intlayer.md +1 -1
- package/docs/fr/intlayer_CMS.md +25 -5
- package/docs/fr/intlayer_with_express.md +1 -0
- package/docs/fr/intlayer_with_fastify.md +439 -0
- package/docs/fr/readme.md +1 -1
- package/docs/hi/cli/ci.md +137 -0
- package/docs/hi/cli/index.md +7 -1
- package/docs/hi/cli/list.md +38 -1
- package/docs/hi/cli/list_projects.md +130 -0
- package/docs/hi/cli/push.md +1 -1
- package/docs/hi/configuration.md +3 -3
- package/docs/hi/interest_of_intlayer.md +1 -1
- package/docs/hi/intlayer_CMS.md +25 -5
- package/docs/hi/intlayer_with_express.md +1 -0
- package/docs/hi/intlayer_with_fastify.md +540 -0
- package/docs/hi/readme.md +1 -1
- package/docs/id/cli/ci.md +137 -0
- package/docs/id/cli/index.md +7 -1
- package/docs/id/cli/list.md +38 -1
- package/docs/id/cli/list_projects.md +128 -0
- package/docs/id/cli/push.md +1 -1
- package/docs/id/configuration.md +3 -3
- package/docs/id/interest_of_intlayer.md +1 -1
- package/docs/id/intlayer_CMS.md +25 -5
- package/docs/id/intlayer_with_express.md +1 -0
- package/docs/id/intlayer_with_fastify.md +470 -0
- package/docs/id/readme.md +1 -1
- package/docs/it/cli/ci.md +137 -0
- package/docs/it/cli/index.md +7 -1
- package/docs/it/cli/list.md +39 -2
- package/docs/it/cli/list_projects.md +130 -0
- package/docs/it/cli/push.md +1 -1
- package/docs/it/configuration.md +3 -3
- package/docs/it/interest_of_intlayer.md +1 -1
- package/docs/it/intlayer_CMS.md +25 -5
- package/docs/it/intlayer_with_express.md +1 -0
- package/docs/it/intlayer_with_fastify.md +445 -0
- package/docs/it/readme.md +1 -1
- package/docs/ja/cli/ci.md +137 -0
- package/docs/ja/cli/index.md +7 -1
- package/docs/ja/cli/list.md +38 -1
- package/docs/ja/cli/list_projects.md +136 -0
- package/docs/ja/cli/push.md +1 -1
- package/docs/ja/configuration.md +3 -3
- package/docs/ja/interest_of_intlayer.md +1 -1
- package/docs/ja/intlayer_CMS.md +25 -5
- package/docs/ja/intlayer_with_express.md +1 -0
- package/docs/ja/intlayer_with_fastify.md +516 -0
- package/docs/ja/readme.md +1 -1
- package/docs/ko/cli/ci.md +137 -0
- package/docs/ko/cli/index.md +7 -1
- package/docs/ko/cli/list.md +38 -1
- package/docs/ko/cli/list_projects.md +128 -0
- package/docs/ko/cli/push.md +1 -1
- package/docs/ko/configuration.md +3 -3
- package/docs/ko/interest_of_intlayer.md +1 -1
- package/docs/ko/intlayer_CMS.md +25 -5
- package/docs/ko/intlayer_with_express.md +1 -0
- package/docs/ko/intlayer_with_fastify.md +463 -0
- package/docs/ko/readme.md +1 -1
- package/docs/pl/cli/ci.md +137 -0
- package/docs/pl/cli/index.md +7 -1
- package/docs/pl/cli/list.md +39 -2
- package/docs/pl/cli/list_projects.md +130 -0
- package/docs/pl/cli/push.md +1 -1
- package/docs/pl/configuration.md +3 -3
- package/docs/pl/interest_of_intlayer.md +1 -1
- package/docs/pl/intlayer_CMS.md +25 -5
- package/docs/pl/intlayer_with_express.md +1 -0
- package/docs/pl/intlayer_with_fastify.md +457 -0
- package/docs/pl/readme.md +1 -1
- package/docs/pt/cli/ci.md +137 -0
- package/docs/pt/cli/index.md +7 -1
- package/docs/pt/cli/list.md +39 -2
- package/docs/pt/cli/list_projects.md +134 -0
- package/docs/pt/cli/push.md +1 -1
- package/docs/pt/configuration.md +3 -3
- package/docs/pt/interest_of_intlayer.md +1 -1
- package/docs/pt/intlayer_CMS.md +25 -5
- package/docs/pt/intlayer_with_express.md +1 -0
- package/docs/pt/intlayer_with_fastify.md +502 -0
- package/docs/pt/readme.md +1 -1
- package/docs/ru/cli/ci.md +137 -0
- package/docs/ru/cli/index.md +7 -1
- package/docs/ru/cli/list.md +39 -2
- package/docs/ru/cli/list_projects.md +130 -0
- package/docs/ru/cli/push.md +1 -1
- package/docs/ru/configuration.md +3 -3
- package/docs/ru/interest_of_intlayer.md +1 -1
- package/docs/ru/intlayer_CMS.md +25 -5
- package/docs/ru/intlayer_with_express.md +1 -0
- package/docs/ru/intlayer_with_fastify.md +468 -0
- package/docs/ru/readme.md +1 -1
- package/docs/tr/cli/ci.md +137 -0
- package/docs/tr/cli/index.md +7 -1
- package/docs/tr/cli/list.md +39 -2
- package/docs/tr/cli/list_projects.md +134 -0
- package/docs/tr/cli/push.md +1 -1
- package/docs/tr/configuration.md +3 -3
- package/docs/tr/interest_of_intlayer.md +1 -1
- package/docs/tr/intlayer_CMS.md +25 -5
- package/docs/tr/intlayer_with_express.md +1 -0
- package/docs/tr/intlayer_with_fastify.md +471 -0
- package/docs/tr/readme.md +1 -1
- package/docs/vi/cli/ci.md +137 -0
- package/docs/vi/cli/index.md +7 -1
- package/docs/vi/cli/list.md +38 -1
- package/docs/vi/cli/list_projects.md +130 -0
- package/docs/vi/cli/push.md +1 -1
- package/docs/vi/configuration.md +3 -3
- package/docs/vi/interest_of_intlayer.md +1 -1
- package/docs/vi/intlayer_CMS.md +25 -5
- package/docs/vi/intlayer_with_express.md +1 -0
- package/docs/vi/intlayer_with_fastify.md +490 -0
- package/docs/vi/readme.md +1 -1
- package/docs/zh/cli/ci.md +137 -0
- package/docs/zh/cli/index.md +7 -1
- package/docs/zh/cli/list.md +38 -1
- package/docs/zh/cli/list_projects.md +130 -0
- package/docs/zh/cli/push.md +1 -1
- package/docs/zh/configuration.md +3 -3
- package/docs/zh/interest_of_intlayer.md +1 -1
- package/docs/zh/intlayer_CMS.md +25 -5
- package/docs/zh/intlayer_with_express.md +1 -0
- package/docs/zh/intlayer_with_fastify.md +451 -0
- package/docs/zh/readme.md +1 -1
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +57 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-12-30
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: Cách dịch backend Fastify của bạn – Hướng dẫn i18n 2026
|
|
5
|
+
description: Tìm hiểu cách làm cho backend Fastify của bạn hỗ trợ đa ngôn ngữ. Thực hiện theo tài liệu để internationalize (i18n) và dịch nội dung.
|
|
6
|
+
keywords:
|
|
7
|
+
- Quốc tế hóa (i18n)
|
|
8
|
+
- Tài liệu
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Fastify
|
|
11
|
+
- JavaScript
|
|
12
|
+
- Backend
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- fastify
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-fastify-template
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.6.0
|
|
20
|
+
date: 2025-12-31
|
|
21
|
+
changes: Thêm lệnh init
|
|
22
|
+
- version: 7.6.0
|
|
23
|
+
date: 2025-12-31
|
|
24
|
+
changes: Khởi tạo lịch sử
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Dịch backend Fastify của bạn bằng Intlayer | Quốc tế hóa (i18n)
|
|
28
|
+
|
|
29
|
+
`fastify-intlayer` là một plugin quốc tế hóa (i18n) mạnh mẽ cho các ứng dụng Fastify, được thiết kế để làm cho dịch vụ backend của bạn có thể truy cập trên toàn cầu bằng cách cung cấp phản hồi được địa phương hóa dựa trên sở thích của client.
|
|
30
|
+
|
|
31
|
+
### Các trường hợp sử dụng thực tế
|
|
32
|
+
|
|
33
|
+
- **Hiển thị lỗi Backend bằng ngôn ngữ của người dùng**: Khi xảy ra lỗi, hiển thị thông điệp bằng ngôn ngữ mẹ đẻ của người dùng sẽ cải thiện khả năng hiểu và giảm sự bực bội. Điều này đặc biệt hữu ích cho các thông báo lỗi động có thể được hiển thị trong các thành phần front-end như toast hoặc modal.
|
|
34
|
+
|
|
35
|
+
`fastify-intlayer` là một plugin quốc tế hóa (i18n) mạnh mẽ cho các ứng dụng Fastify, được thiết kế để giúp các dịch vụ backend của bạn có thể truy cập toàn cầu bằng cách cung cấp các phản hồi địa phương hóa dựa trên sở thích của khách hàng.
|
|
36
|
+
|
|
37
|
+
### Trường hợp sử dụng thực tế
|
|
38
|
+
|
|
39
|
+
- **Hiển thị lỗi backend bằng ngôn ngữ của người dùng**: Khi xảy ra lỗi, hiển thị thông điệp bằng ngôn ngữ mẹ đẻ của người dùng giúp họ hiểu tốt hơn và giảm bực bội. Điều này đặc biệt hữu ích cho các thông báo lỗi động có thể được hiển thị trong các thành phần front-end như toasts hoặc modals.
|
|
40
|
+
- **Truy xuất nội dung đa ngôn ngữ**: Đối với các ứng dụng lấy nội dung từ cơ sở dữ liệu, quốc tế hóa đảm bảo rằng bạn có thể phục vụ nội dung này bằng nhiều ngôn ngữ. Điều này rất quan trọng cho các nền tảng như trang thương mại điện tử (e-commerce) hoặc hệ thống quản lý nội dung (CMS) cần hiển thị mô tả sản phẩm, bài viết và các nội dung khác theo ngôn ngữ mà người dùng ưu tiên.
|
|
41
|
+
- **Gửi email đa ngôn ngữ**: Dù là email giao dịch, chiến dịch marketing hay thông báo, gửi email bằng ngôn ngữ của người nhận có thể tăng đáng kể mức độ tương tác và hiệu quả.
|
|
42
|
+
- **Thông báo đẩy đa ngôn ngữ**: Đối với ứng dụng di động, gửi thông báo đẩy bằng ngôn ngữ ưa thích của người dùng có thể tăng tương tác và giữ chân người dùng. Sự chăm chút cá nhân này khiến thông báo trở nên phù hợp và dễ hành động hơn.
|
|
43
|
+
- **Các hình thức liên lạc khác**: Bất kỳ hình thức liên lạc nào từ backend, như tin nhắn SMS, cảnh báo hệ thống hoặc cập nhật giao diện người dùng, đều hưởng lợi khi được gửi bằng ngôn ngữ của người dùng, đảm bảo sự rõ ràng và nâng cao trải nghiệm tổng thể.
|
|
44
|
+
|
|
45
|
+
Bằng cách quốc tế hóa backend, ứng dụng của bạn không chỉ tôn trọng khác biệt văn hóa mà còn phù hợp hơn với nhu cầu thị trường toàn cầu, trở thành bước then chốt để mở rộng dịch vụ ra toàn thế giới.
|
|
46
|
+
|
|
47
|
+
## Bắt đầu
|
|
48
|
+
|
|
49
|
+
### Cài đặt
|
|
50
|
+
|
|
51
|
+
Để bắt đầu sử dụng `fastify-intlayer`, cài gói bằng npm:
|
|
52
|
+
|
|
53
|
+
```bash packageManager="npm"
|
|
54
|
+
npm install intlayer fastify-intlayer
|
|
55
|
+
npx intlayer init
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash packageManager="pnpm"
|
|
60
|
+
pnpm add intlayer fastify-intlayer
|
|
61
|
+
pnpm intlayer init
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```bash packageManager="yarn"
|
|
66
|
+
yarn add intlayer fastify-intlayer
|
|
67
|
+
yarn intlayer init
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```bash packageManager="bun"
|
|
72
|
+
bun add intlayer fastify-intlayer
|
|
73
|
+
bunx intlayer init
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Thiết lập
|
|
78
|
+
|
|
79
|
+
Cấu hình các thiết lập quốc tế hóa bằng cách tạo một tệp `intlayer.config.ts` ở thư mục gốc của dự án:
|
|
80
|
+
|
|
81
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
82
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
83
|
+
|
|
84
|
+
const config: IntlayerConfig = {
|
|
85
|
+
internationalization: {
|
|
86
|
+
locales: [
|
|
87
|
+
Locales.ENGLISH,
|
|
88
|
+
Locales.FRENCH,
|
|
89
|
+
Locales.SPANISH_MEXICO,
|
|
90
|
+
Locales.SPANISH_SPAIN,
|
|
91
|
+
],
|
|
92
|
+
defaultLocale: Locales.ENGLISH,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default config;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
100
|
+
import { Locales } from "intlayer";
|
|
101
|
+
|
|
102
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
103
|
+
const config = {
|
|
104
|
+
internationalization: {
|
|
105
|
+
locales: [
|
|
106
|
+
Locales.ENGLISH,
|
|
107
|
+
Locales.FRENCH,
|
|
108
|
+
Locales.SPANISH_MEXICO,
|
|
109
|
+
Locales.SPANISH_SPAIN,
|
|
110
|
+
],
|
|
111
|
+
defaultLocale: Locales.ENGLISH,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default config;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
119
|
+
const { Locales } = require("intlayer");
|
|
120
|
+
|
|
121
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
122
|
+
const config = {
|
|
123
|
+
internationalization: {
|
|
124
|
+
locales: [
|
|
125
|
+
Locales.ENGLISH,
|
|
126
|
+
Locales.FRENCH,
|
|
127
|
+
Locales.SPANISH_MEXICO,
|
|
128
|
+
Locales.SPANISH_SPAIN,
|
|
129
|
+
],
|
|
130
|
+
defaultLocale: Locales.ENGLISH,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
module.exports = config;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Khai báo Nội dung của bạn
|
|
138
|
+
|
|
139
|
+
Tạo và quản lý các khai báo nội dung của bạn để lưu trữ bản dịch:
|
|
140
|
+
|
|
141
|
+
```typescript fileName="src/index.content.ts" contentDeclarationFormat="typescript"
|
|
142
|
+
import { t, type Dictionary } from "intlayer";
|
|
143
|
+
|
|
144
|
+
const indexContent = {
|
|
145
|
+
key: "index",
|
|
146
|
+
content: {
|
|
147
|
+
exampleOfContent: t({
|
|
148
|
+
vi: "Ví dụ về nội dung trả về bằng tiếng Việt",
|
|
149
|
+
en: "Example of returned content in English",
|
|
150
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
151
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
152
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
153
|
+
}),
|
|
154
|
+
},
|
|
155
|
+
} satisfies Dictionary;
|
|
156
|
+
|
|
157
|
+
export default indexContent;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```javascript fileName="src/index.content.mjs" contentDeclarationFormat="esm"
|
|
161
|
+
import { t } from "intlayer";
|
|
162
|
+
|
|
163
|
+
/** Danh sách từ điển. @type {import('intlayer').Dictionary} */
|
|
164
|
+
const indexContent = {
|
|
165
|
+
key: "index",
|
|
166
|
+
content: {
|
|
167
|
+
exampleOfContent: t({
|
|
168
|
+
vi: "Ví dụ về nội dung trả về bằng tiếng Anh",
|
|
169
|
+
en: "Example of returned content in English",
|
|
170
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
171
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
172
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export default indexContent;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
```javascript fileName="src/index.content.cjs" contentDeclarationFormat="commonjs"
|
|
181
|
+
const { t } = require("intlayer");
|
|
182
|
+
|
|
183
|
+
/** Danh sách từ điển. @type {import('intlayer').Dictionary} */
|
|
184
|
+
const indexContent = {
|
|
185
|
+
key: "index",
|
|
186
|
+
content: {
|
|
187
|
+
exampleOfContent: t({
|
|
188
|
+
vi: "Ví dụ về nội dung trả về bằng tiếng Anh",
|
|
189
|
+
en: "Example of returned content in English",
|
|
190
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
191
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
192
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
193
|
+
}),
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
module.exports = indexContent;
|
|
198
|
+
vi: "Ví dụ về nội dung được trả về bằng tiếng Việt",
|
|
199
|
+
en: "Example of returned content in English",
|
|
200
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
201
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
202
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
module.exports = indexContent;
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```json fileName="src/index.content.json" contentDeclarationFormat="json"
|
|
211
|
+
{
|
|
212
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
213
|
+
"key": "index",
|
|
214
|
+
"content": {
|
|
215
|
+
"exampleOfContent": {
|
|
216
|
+
"nodeType": "translation",
|
|
217
|
+
"translation": {
|
|
218
|
+
"vi": "Ví dụ về nội dung được trả về bằng tiếng Việt",
|
|
219
|
+
"en": "Example of returned content in English",
|
|
220
|
+
"fr": "Exemple de contenu renvoyé en français",
|
|
221
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
222
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
> Các khai báo nội dung của bạn có thể được định nghĩa ở bất kỳ đâu trong ứng dụng miễn là chúng được đưa vào thư mục `contentDir` (mặc định là `./src`). Và khớp với phần mở rộng tệp khai báo nội dung (mặc định là `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
230
|
+
|
|
231
|
+
> Để biết thêm chi tiết, tham khảo [tài liệu khai báo nội dung](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/dictionary/content_file.md).
|
|
232
|
+
|
|
233
|
+
### Thiết lập Ứng dụng Fastify
|
|
234
|
+
|
|
235
|
+
Thiết lập ứng dụng Fastify của bạn để sử dụng `fastify-intlayer`:
|
|
236
|
+
|
|
237
|
+
```typescript fileName="src/index.ts" codeFormat="typescript"
|
|
238
|
+
import Fastify from "fastify";
|
|
239
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
240
|
+
import dictionaryExample from "./index.content";
|
|
241
|
+
|
|
242
|
+
const fastify = Fastify({ logger: true });
|
|
243
|
+
|
|
244
|
+
// Tải plugin quốc tế hóa
|
|
245
|
+
await fastify.register(intlayer);
|
|
246
|
+
|
|
247
|
+
// Định tuyến
|
|
248
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
249
|
+
return t({
|
|
250
|
+
vi: "Ví dụ nội dung trả về bằng tiếng Việt",
|
|
251
|
+
en: "Example of returned content in English",
|
|
252
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
253
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
254
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
259
|
+
return getIntlayer("index").exampleOfContent;
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
263
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// Khởi động server
|
|
267
|
+
const start = async () => {
|
|
268
|
+
try {
|
|
269
|
+
await fastify.listen({ port: 3000 });
|
|
270
|
+
} catch (err) {
|
|
271
|
+
fastify.log.error(err);
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
start();
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
```javascript fileName="src/index.mjs" codeFormat="esm"
|
|
280
|
+
import Fastify from "fastify";
|
|
281
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
282
|
+
import dictionaryExample from "./index.content";
|
|
283
|
+
|
|
284
|
+
const fastify = Fastify({ logger: true });
|
|
285
|
+
|
|
286
|
+
// Đăng ký plugin quốc tế hóa
|
|
287
|
+
await fastify.register(intlayer);
|
|
288
|
+
|
|
289
|
+
// Các route
|
|
290
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
291
|
+
return t({
|
|
292
|
+
vi: "Ví dụ nội dung trả về bằng tiếng Việt",
|
|
293
|
+
en: "Example of returned content in English",
|
|
294
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
295
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
296
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
301
|
+
return getIntlayer("index").exampleOfContent;
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
305
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// Bắt đầu server
|
|
309
|
+
const start = async () => {
|
|
310
|
+
try {
|
|
311
|
+
await fastify.listen({ port: 3000 });
|
|
312
|
+
} catch (err) {
|
|
313
|
+
fastify.log.error(err);
|
|
314
|
+
process.exit(1);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
start();
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
```javascript fileName="src/index.cjs" codeFormat="commonjs"
|
|
322
|
+
const Fastify = require("fastify");
|
|
323
|
+
const { intlayer, t, getDictionary, getIntlayer } = require("fastify-intlayer");
|
|
324
|
+
const dictionaryExample = require("./index.content");
|
|
325
|
+
|
|
326
|
+
const fastify = Fastify({ logger: true });
|
|
327
|
+
|
|
328
|
+
// Wrapper khởi động server để hỗ trợ async/await
|
|
329
|
+
const start = async () => {
|
|
330
|
+
try {
|
|
331
|
+
// Đăng ký plugin quốc tế hóa
|
|
332
|
+
await fastify.register(intlayer);
|
|
333
|
+
|
|
334
|
+
// Các routes
|
|
335
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
336
|
+
return t({
|
|
337
|
+
vi: "Ví dụ về nội dung trả về bằng tiếng Việt",
|
|
338
|
+
en: "Example of returned content in English",
|
|
339
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
340
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
341
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
346
|
+
return getIntlayer("index").exampleOfContent;
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
350
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
await fastify.listen({ port: 3000 });
|
|
354
|
+
} catch (err) {
|
|
355
|
+
fastify.log.error(err);
|
|
356
|
+
process.exit(1);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
start();
|
|
361
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
362
|
+
return t({
|
|
363
|
+
vi: "Ví dụ về nội dung trả về bằng tiếng Việt",
|
|
364
|
+
en: "Example of returned content in English",
|
|
365
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
366
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
367
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
372
|
+
return getIntlayer("index").exampleOfContent;
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
376
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
await fastify.listen({ port: 3000 });
|
|
380
|
+
} catch (err) {
|
|
381
|
+
fastify.log.error(err);
|
|
382
|
+
process.exit(1);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
start();
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Tương thích
|
|
390
|
+
|
|
391
|
+
`fastify-intlayer` tương thích hoàn toàn với:
|
|
392
|
+
|
|
393
|
+
- [`react-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/index.md)>) cho các ứng dụng React
|
|
394
|
+
- [`next-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/next-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/next-intlayer/index.md)>) cho các ứng dụng Next.js
|
|
395
|
+
|
|
396
|
+
- [`react-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/index.md)>) cho ứng dụng React
|
|
397
|
+
- [`next-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/next-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/next-intlayer/index.md)>) cho ứng dụng Next.js
|
|
398
|
+
- [`vite-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/vite-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/vite-intlayer/index.md)>) cho ứng dụng Vite
|
|
399
|
+
|
|
400
|
+
Nó cũng hoạt động mượt mà với bất kỳ giải pháp quốc tế hóa nào trên nhiều môi trường khác nhau, bao gồm trình duyệt và các yêu cầu API. Bạn có thể tùy chỉnh middleware để phát hiện locale thông qua headers hoặc cookies:
|
|
401
|
+
|
|
402
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
403
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
404
|
+
|
|
405
|
+
const config: IntlayerConfig = {
|
|
406
|
+
// ... Các tùy chọn cấu hình khác
|
|
407
|
+
middleware: {
|
|
408
|
+
headerName: "my-locale-header",
|
|
409
|
+
cookieName: "my-locale-cookie",
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
export default config;
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
417
|
+
import { Locales } from "intlayer";
|
|
418
|
+
|
|
419
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
420
|
+
const config = {
|
|
421
|
+
// ... Các tuỳ chọn cấu hình khác
|
|
422
|
+
middleware: {
|
|
423
|
+
headerName: "my-locale-header",
|
|
424
|
+
cookieName: "my-locale-cookie",
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
export default config;
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
432
|
+
const { Locales } = require("intlayer");
|
|
433
|
+
|
|
434
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
435
|
+
const config = {
|
|
436
|
+
// ... Các tuỳ chọn cấu hình khác
|
|
437
|
+
middleware: {
|
|
438
|
+
headerName: "my-locale-header",
|
|
439
|
+
cookieName: "my-locale-cookie",
|
|
440
|
+
},
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
module.exports = config;
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Mặc định, `fastify-intlayer` sẽ sử dụng header `Accept-Language` để xác định ngôn ngữ ưu tiên của client.
|
|
447
|
+
|
|
448
|
+
> Để biết thêm thông tin về cấu hình và các chủ đề nâng cao, hãy xem [tài liệu của chúng tôi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/configuration.md).
|
|
449
|
+
|
|
450
|
+
### Cấu hình TypeScript
|
|
451
|
+
|
|
452
|
+
`fastify-intlayer` tận dụng khả năng mạnh mẽ của TypeScript để cải thiện quá trình quốc tế hóa. Hệ thống kiểu tĩnh của TypeScript đảm bảo mọi translation key đều được kiểm kê, giảm nguy cơ thiếu bản dịch và cải thiện khả năng bảo trì.
|
|
453
|
+
|
|
454
|
+
Đảm bảo các kiểu được tự động sinh (mặc định tại ./types/intlayer.d.ts) được bao gồm trong file tsconfig.json của bạn.
|
|
455
|
+
|
|
456
|
+
```json5 fileName="tsconfig.json"
|
|
457
|
+
{
|
|
458
|
+
// ... Cấu hình TypeScript hiện có của bạn
|
|
459
|
+
"include": [
|
|
460
|
+
// ... Cấu hình TypeScript hiện có của bạn
|
|
461
|
+
".intlayer/**/*.ts", // Bao gồm các kiểu được tự động sinh
|
|
462
|
+
],
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Tiện ích mở rộng VS Code
|
|
467
|
+
|
|
468
|
+
Để cải thiện trải nghiệm phát triển với Intlayer, bạn có thể cài đặt **Tiện ích mở rộng Intlayer cho VS Code** chính thức.
|
|
469
|
+
|
|
470
|
+
[Cài đặt từ VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
471
|
+
|
|
472
|
+
Tiện ích mở rộng này cung cấp:
|
|
473
|
+
|
|
474
|
+
- **Tự động hoàn thành** cho các khóa dịch.
|
|
475
|
+
- **Phát hiện lỗi thời gian thực** cho các bản dịch bị thiếu.
|
|
476
|
+
- **Xem trước trực tiếp** nội dung đã dịch ngay trong trình soạn thảo.
|
|
477
|
+
- **Hành động nhanh** để dễ dàng tạo và cập nhật bản dịch.
|
|
478
|
+
|
|
479
|
+
Để biết thêm chi tiết về cách sử dụng tiện ích mở rộng, tham khảo [tài liệu Tiện ích mở rộng Intlayer cho VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
480
|
+
|
|
481
|
+
### Cấu hình Git
|
|
482
|
+
|
|
483
|
+
Nên bỏ qua các tệp do Intlayer tạo ra. Điều này giúp bạn tránh commit chúng vào kho Git của mình.
|
|
484
|
+
|
|
485
|
+
Để làm điều này, bạn có thể thêm các hướng dẫn sau vào tệp `.gitignore` của mình:
|
|
486
|
+
|
|
487
|
+
```plaintext fileName=".gitignore"
|
|
488
|
+
# Bỏ qua các tệp được Intlayer tạo ra
|
|
489
|
+
.intlayer
|
|
490
|
+
```
|
package/docs/vi/readme.md
CHANGED
|
@@ -50,7 +50,7 @@ Với **các tệp nội dung theo từng locale**, **tự động hoàn thành
|
|
|
50
50
|
| Tính năng | Mô tả |
|
|
51
51
|
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Tính năng" width="700"> | **Hỗ trợ đa Framework**<br><br>Intlayer tương thích với tất cả các framework và thư viện lớn, bao gồm Next.js, React, Vite, Vue.js, Nuxt, Preact, Express và nhiều hơn nữa. |
|
|
53
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Tính năng" width="700"> | **Quản lý Nội dung bằng JavaScript**<br><br>Khai thác sự linh hoạt của JavaScript để định nghĩa và quản lý nội dung của bạn một cách hiệu quả. <br><br> - [Khai báo nội dung](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Tính năng" width="700"> | **Tệp Khai Báo Nội Dung Theo Mỗi Locale**<br><br>Tăng tốc phát triển của bạn bằng cách khai báo nội dung một lần, trước khi tự động sinh.<br><br> - [Tệp Khai Báo Nội Dung Theo Mỗi Locale](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
55
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Tính năng" width="700"> | **Môi Trường An Toàn Kiểu**<br><br>Tận dụng TypeScript để đảm bảo định nghĩa nội dung và mã của bạn không có lỗi, đồng thời hưởng lợi từ tính năng tự động hoàn thành trong IDE.<br><br> - [Cấu hình TypeScript](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Tính năng" width="700"> | **Cài Đặt Đơn Giản Hóa**<br><br>Bắt đầu nhanh chóng với cấu hình tối thiểu. Dễ dàng điều chỉnh các thiết lập cho quốc tế hóa, định tuyến, AI, build và xử lý nội dung.<br><br> - [Khám phá tích hợp Next.js](https://intlayer.org/doc/environment/nextjs) |
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2026-01-06
|
|
3
|
+
updatedAt: 2026-01-06
|
|
4
|
+
title: CI 命令
|
|
5
|
+
description: 了解如何在 CI/CD 管道和 monorepo 中使用自动注入的凭据运行 Intlayer 命令。
|
|
6
|
+
keywords:
|
|
7
|
+
- CI
|
|
8
|
+
- CI/CD
|
|
9
|
+
- 自动化
|
|
10
|
+
- Monorepo
|
|
11
|
+
- 凭据
|
|
12
|
+
- CLI
|
|
13
|
+
- Intlayer
|
|
14
|
+
slugs:
|
|
15
|
+
- doc
|
|
16
|
+
- concept
|
|
17
|
+
- cli
|
|
18
|
+
- ci
|
|
19
|
+
history:
|
|
20
|
+
- version: 7.5.11
|
|
21
|
+
date: 2026-01-06
|
|
22
|
+
changes: 添加 CI 命令
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# CI 命令
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx intlayer ci <command...>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
CI 命令专为自动化和 CI/CD 管道而设计。它会自动从 `INTLAYER_PROJECT_CREDENTIALS` 环境变量注入凭据,并可以在 monorepo 中的多个项目上运行 Intlayer 命令。
|
|
32
|
+
|
|
33
|
+
## 工作原理
|
|
34
|
+
|
|
35
|
+
CI 命令以两种模式运行:
|
|
36
|
+
|
|
37
|
+
1. **单项目模式**:如果当前工作目录与 `INTLAYER_PROJECT_CREDENTIALS` 中的项目路径之一匹配,则仅针对该特定项目运行命令。
|
|
38
|
+
|
|
39
|
+
2. **迭代模式**:如果未检测到特定的项目上下文,它会遍历所有已配置的项目并为每个项目运行命令。
|
|
40
|
+
|
|
41
|
+
## 环境变量
|
|
42
|
+
|
|
43
|
+
该命令需要设置 `INTLAYER_PROJECT_CREDENTIALS` 环境变量。此变量应包含一个 JSON 对象,将项目路径映射到其凭据:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"packages/app": {
|
|
48
|
+
"clientId": "your-client-id-1",
|
|
49
|
+
"clientSecret": "your-client-secret-1"
|
|
50
|
+
},
|
|
51
|
+
"packages/admin": {
|
|
52
|
+
"clientId": "your-client-id-2",
|
|
53
|
+
"clientSecret": "your-client-secret-2"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 包管理器检测
|
|
59
|
+
|
|
60
|
+
CI 命令会根据 `npm_config_user_agent` 环境变量自动检测正在使用的包管理器(npm、yarn、pnpm 或 bun),并使用适当的命令来执行 Intlayer。
|
|
61
|
+
|
|
62
|
+
## 参数
|
|
63
|
+
|
|
64
|
+
- **`<command...>`**:要执行的 Intlayer 命令(例如,`fill`、`push`、`build`)。您可以传递任何 Intlayer 命令及其参数。
|
|
65
|
+
|
|
66
|
+
> 示例: `npx intlayer ci fill --verbose`
|
|
67
|
+
>
|
|
68
|
+
> 示例: `npx intlayer ci push`
|
|
69
|
+
>
|
|
70
|
+
> 示例: `npx intlayer ci build`
|
|
71
|
+
|
|
72
|
+
## 示例
|
|
73
|
+
|
|
74
|
+
### 在单项目模式下运行命令
|
|
75
|
+
|
|
76
|
+
如果您在匹配 `INTLAYER_PROJECT_CREDENTIALS` 中路径之一的项目目录中:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd packages/app
|
|
80
|
+
npx intlayer ci fill
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
这将为 `packages/app` 项目自动注入凭据并运行 `fill` 命令。
|
|
84
|
+
|
|
85
|
+
### 在所有项目上运行命令
|
|
86
|
+
|
|
87
|
+
如果您在未匹配任何项目路径的目录中,该命令将遍历所有已配置的项目:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
cd /path/to/monorepo
|
|
91
|
+
npx intlayer ci push
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
这将为 `INTLAYER_PROJECT_CREDENTIALS` 中配置的每个项目运行 `push` 命令。
|
|
95
|
+
|
|
96
|
+
### 传递额外标志
|
|
97
|
+
|
|
98
|
+
您可以将任何标志传递给底层 Intlayer 命令:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx intlayer ci fill --verbose --mode complete
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 在 CI/CD 管道中使用
|
|
105
|
+
|
|
106
|
+
在您的 CI/CD 配置中(例如,GitHub Actions、GitLab CI),将 `INTLAYER_PROJECT_CREDENTIALS` 设置为密钥:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
# GitHub Actions 示例
|
|
110
|
+
env:
|
|
111
|
+
INTLAYER_PROJECT_CREDENTIALS: ${{ secrets.INTLAYER_PROJECT_CREDENTIALS }}
|
|
112
|
+
|
|
113
|
+
steps:
|
|
114
|
+
- name: 填充字典
|
|
115
|
+
run: npx intlayer ci fill
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## 错误处理
|
|
119
|
+
|
|
120
|
+
- 如果未设置 `INTLAYER_PROJECT_CREDENTIALS`,命令将以错误退出。
|
|
121
|
+
- 如果 `INTLAYER_PROJECT_CREDENTIALS` 不是有效的 JSON,命令将以错误退出。
|
|
122
|
+
- 如果项目路径不存在,将跳过并显示警告。
|
|
123
|
+
- 如果任何项目失败,命令将以非零状态代码退出。
|
|
124
|
+
|
|
125
|
+
## 使用场景
|
|
126
|
+
|
|
127
|
+
- **Monorepo 自动化**:在 monorepo 中的多个项目上运行 Intlayer 命令
|
|
128
|
+
- **CI/CD 管道**:在持续集成工作流中自动化字典管理
|
|
129
|
+
- **批量操作**:同时对多个 Intlayer 项目执行相同操作
|
|
130
|
+
- **密钥管理**:使用环境变量安全地管理多个项目的凭据
|
|
131
|
+
|
|
132
|
+
## 安全最佳实践
|
|
133
|
+
|
|
134
|
+
- 在 CI/CD 平台中将 `INTLAYER_PROJECT_CREDENTIALS` 存储为加密密钥
|
|
135
|
+
- 永远不要将凭据提交到版本控制
|
|
136
|
+
- 为不同的部署环境使用特定于环境的凭据
|
|
137
|
+
- 定期轮换凭据
|
package/docs/zh/cli/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2024-08-11
|
|
3
|
-
updatedAt:
|
|
3
|
+
updatedAt: 2026-01-06
|
|
4
4
|
title: CLI
|
|
5
5
|
description: 了解如何使用 Intlayer CLI 来管理您的多语言网站。按照本在线文档中的步骤,几分钟内即可设置您的项目。
|
|
6
6
|
keywords:
|
|
@@ -17,6 +17,9 @@ slugs:
|
|
|
17
17
|
- concept
|
|
18
18
|
- cli
|
|
19
19
|
history:
|
|
20
|
+
- version: 7.5.11
|
|
21
|
+
date: 2026-01-06
|
|
22
|
+
changes: 添加 projects list 命令
|
|
20
23
|
- version: 7.5.9
|
|
21
24
|
date: 2025-12-30
|
|
22
25
|
changes: 添加 init 命令
|
|
@@ -119,6 +122,7 @@ Intlayer 支持多种配置文件格式:
|
|
|
119
122
|
- **[构建字典](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/cli/build.md)** - 从内容声明文件构建字典
|
|
120
123
|
- **[监视字典](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/cli/watch.md)** - 监视更改并自动构建字典
|
|
121
124
|
- **[检查 CLI 版本](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/cli/version.md)** - 检查已安装的 Intlayer CLI 版本
|
|
125
|
+
- **[列出项目](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/cli/list_projects.md)** - 列出目录或 git 存储库中的所有 Intlayer 项目
|
|
122
126
|
|
|
123
127
|
### 字典管理
|
|
124
128
|
|
|
@@ -171,6 +175,7 @@ Intlayer 支持多种配置文件格式:
|
|
|
171
175
|
"intlayer:list": "npx intlayer content list",
|
|
172
176
|
"intlayer:test": "npx intlayer content test",
|
|
173
177
|
"intlayer:transform": "npx intlayer transform",
|
|
178
|
+
"intlayer:projects": "npx intlayer projects list",
|
|
174
179
|
"intlayer:doc:translate": "npx intlayer doc translate",
|
|
175
180
|
"intlayer:doc:review": "npx intlayer doc review"
|
|
176
181
|
}
|
|
@@ -180,3 +185,4 @@ Intlayer 支持多种配置文件格式:
|
|
|
180
185
|
>
|
|
181
186
|
> - 使用 `npx intlayer list` 替代 `npx intlayer content list`
|
|
182
187
|
> - 使用 `npx intlayer test` 替代 `npx intlayer content test`
|
|
188
|
+
> - 使用 `npx intlayer projects-list` 或 `npx intlayer pl` 替代 `npx intlayer projects list`
|