@campus-admin/locale 1.0.0 → 2.0.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.
- package/README.md +2 -67
- package/dist/en-US.d.ts +3 -0
- package/dist/index.d.ts +342 -50
- package/dist/index.js +312 -309
- package/dist/zh-CN.d.ts +167 -0
- package/package.json +10 -37
- package/dist/format.d.ts +0 -22
- package/dist/index.umd.cjs +0 -1
- package/dist/lang/en-US.d.ts +0 -9
- package/dist/lang/zh-CN.d.ts +0 -13
- package/dist/types.d.ts +0 -54
package/README.md
CHANGED
|
@@ -1,70 +1,5 @@
|
|
|
1
1
|
# @campus-admin/locale
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Campus Admin locale package. Install the framework with `npm install @campus-admin/core vue`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
业务词条放自己的根键(示例里是 `app.*` / `menu.*` / `page.*`)。
|
|
7
|
-
|
|
8
|
-
## 安装
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
pnpm add @campus-admin/locale
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## 用法
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
import { createLocale, installLocale, useLocale, setLocale } from '@campus-admin/locale'
|
|
18
|
-
import { createApp } from 'vue'
|
|
19
|
-
|
|
20
|
-
const app = createApp(App)
|
|
21
|
-
|
|
22
|
-
const locale = createLocale({
|
|
23
|
-
locale: 'zh-CN',
|
|
24
|
-
fallbackLocale: 'zh-CN',
|
|
25
|
-
messages: { 'zh-CN': zhCN, 'en-US': enUS }, // 业务词条,与内置 ca.* 深合并
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
installLocale(app, locale) // 之后 setLocale / useLocale 都指向这个实例
|
|
29
|
-
setLocale('en-US') // 切换:组件文案与业务文案一起变
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
组件内取词:
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
const { t, te } = useLocale()
|
|
36
|
-
|
|
37
|
-
t('ca.pagination.total', { total: 12 }) // 组件词条
|
|
38
|
-
t('page.home.count', { total: 12 }) // 业务词条
|
|
39
|
-
te('menu.school-student') // 判断词条是否存在(后端文案兜底用)
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
日期与数字统一走 `Intl` 封装,不要在业务里拼「年 / 月 / 日」:
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
import { formatDay, formatMonth, formatNumber, weekdayLabels } from '@campus-admin/locale'
|
|
46
|
-
|
|
47
|
-
formatMonth(new Date(2026, 8, 11), 'en-US') // September 2026
|
|
48
|
-
weekdayLabels('zh-CN') // ['周一', ...]
|
|
49
|
-
formatNumber(3286, 'en-US') // 3,286
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## 约定
|
|
53
|
-
|
|
54
|
-
- `ca.*` 由组件库保留;业务要改写组件文案时只覆盖 `ca` 下的**叶子键**,不要覆盖父级路径(会整段静默失效)。
|
|
55
|
-
- 词条结构就是 vue-i18n 的 messages,已经用 vue-i18n 的项目不要再装第二个实例,把 `caMessages` 合并进自己的实例即可。
|
|
56
|
-
- 找不到词条时原样返回 key,开发环境会打一次 `[@campus-admin/locale] 缺少词条:xxx`。
|
|
57
|
-
|
|
58
|
-
完整说明见仓库文档《Campus Admin 国际化使用指南》。
|
|
59
|
-
|
|
60
|
-
## 版权
|
|
61
|
-
|
|
62
|
-
使用本项目时请保留版权信息(MIT 许可要求随副本保留版权声明):
|
|
63
|
-
|
|
64
|
-
- 保留包内的 `LICENSE` 文件与版权声明;
|
|
65
|
-
- 保留页面页脚中的「Powered By 众校通 ®」与联系方式(示例用 `Copyright` 组件统一渲染);
|
|
66
|
-
- 二次分发或修改后的版本,请在显著位置保留同样的版权声明。
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
Powered By 众校通 ®
|
|
5
|
+
License: MIT.
|
package/dist/en-US.d.ts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,342 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import { enUS } from './en-US.js';
|
|
2
|
+
import { zhCN } from './zh-CN.js';
|
|
3
|
+
export type LocaleCode = 'zh-CN' | 'en-US';
|
|
4
|
+
export declare const LOCALES: {
|
|
5
|
+
code: LocaleCode;
|
|
6
|
+
label: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const frameworkMessages: {
|
|
9
|
+
'zh-CN': {
|
|
10
|
+
campus: {
|
|
11
|
+
notify: {
|
|
12
|
+
success: string;
|
|
13
|
+
info: string;
|
|
14
|
+
warning: string;
|
|
15
|
+
error: string;
|
|
16
|
+
};
|
|
17
|
+
common: {
|
|
18
|
+
ok: string;
|
|
19
|
+
cancel: string;
|
|
20
|
+
confirm: string;
|
|
21
|
+
tip: string;
|
|
22
|
+
loading: string;
|
|
23
|
+
};
|
|
24
|
+
login: {
|
|
25
|
+
title: string;
|
|
26
|
+
username: string;
|
|
27
|
+
password: string;
|
|
28
|
+
submit: string;
|
|
29
|
+
failed: string;
|
|
30
|
+
required: string;
|
|
31
|
+
};
|
|
32
|
+
auth: {
|
|
33
|
+
tabAccount: string;
|
|
34
|
+
tabWechat: string;
|
|
35
|
+
tabRegister: string;
|
|
36
|
+
tabForgot: string;
|
|
37
|
+
backLogin: string;
|
|
38
|
+
accountPlaceholder: string;
|
|
39
|
+
passwordPlaceholder: string;
|
|
40
|
+
captcha: string;
|
|
41
|
+
captchaPlaceholder: string;
|
|
42
|
+
captchaRefresh: string;
|
|
43
|
+
captchaFailed: string;
|
|
44
|
+
captchaRequired: string;
|
|
45
|
+
wechatHint: string;
|
|
46
|
+
wechatNote: string;
|
|
47
|
+
wechatMountFailed: string;
|
|
48
|
+
wechatRetry: string;
|
|
49
|
+
qrcodeAlt: string;
|
|
50
|
+
helpTitle: string;
|
|
51
|
+
help1: string;
|
|
52
|
+
help2: string;
|
|
53
|
+
help3: string;
|
|
54
|
+
help4: string;
|
|
55
|
+
findPassword: string;
|
|
56
|
+
forgotLink: string;
|
|
57
|
+
registerLink: string;
|
|
58
|
+
phone: string;
|
|
59
|
+
phonePlaceholder: string;
|
|
60
|
+
phoneInvalid: string;
|
|
61
|
+
account: string;
|
|
62
|
+
accountRequired: string;
|
|
63
|
+
smsCode: string;
|
|
64
|
+
smsPlaceholder: string;
|
|
65
|
+
getCode: string;
|
|
66
|
+
resend: string;
|
|
67
|
+
smsSent: string;
|
|
68
|
+
smsNeedPhone: string;
|
|
69
|
+
smsNeedAccount: string;
|
|
70
|
+
registerPassword: string;
|
|
71
|
+
registerPasswordPlaceholder: string;
|
|
72
|
+
newPasswordPlaceholder: string;
|
|
73
|
+
confirmPlaceholder: string;
|
|
74
|
+
passwordPolicy: string;
|
|
75
|
+
sessionExpired: string;
|
|
76
|
+
passwordMismatch: string;
|
|
77
|
+
agreePrefix: string;
|
|
78
|
+
agreeRequired: string;
|
|
79
|
+
registerOk: string;
|
|
80
|
+
resetOk: string;
|
|
81
|
+
previewNote: string;
|
|
82
|
+
unavailableTitle: string;
|
|
83
|
+
unavailableDesc: string;
|
|
84
|
+
};
|
|
85
|
+
header: {
|
|
86
|
+
language: string;
|
|
87
|
+
theme: string;
|
|
88
|
+
logout: string;
|
|
89
|
+
myAccount: string;
|
|
90
|
+
search: string;
|
|
91
|
+
shortcuts: string;
|
|
92
|
+
fullscreen: string;
|
|
93
|
+
exitFullscreen: string;
|
|
94
|
+
notifications: string;
|
|
95
|
+
assistant: string;
|
|
96
|
+
appearance: string;
|
|
97
|
+
settings: string;
|
|
98
|
+
account: string;
|
|
99
|
+
};
|
|
100
|
+
settings: {
|
|
101
|
+
title: string;
|
|
102
|
+
themeMode: string;
|
|
103
|
+
themeColor: string;
|
|
104
|
+
themeColorCustom: string;
|
|
105
|
+
themeColorReset: string;
|
|
106
|
+
boxStyle: string;
|
|
107
|
+
boxBorder: string;
|
|
108
|
+
boxShadow: string;
|
|
109
|
+
close: string;
|
|
110
|
+
};
|
|
111
|
+
mode: {
|
|
112
|
+
light: string;
|
|
113
|
+
dark: string;
|
|
114
|
+
auto: string;
|
|
115
|
+
};
|
|
116
|
+
side: {
|
|
117
|
+
home: string;
|
|
118
|
+
collapse: string;
|
|
119
|
+
expand: string;
|
|
120
|
+
hideText: string;
|
|
121
|
+
showText: string;
|
|
122
|
+
openMenu: string;
|
|
123
|
+
closeMenu: string;
|
|
124
|
+
};
|
|
125
|
+
breadcrumb: {
|
|
126
|
+
current: string;
|
|
127
|
+
};
|
|
128
|
+
tabs: {
|
|
129
|
+
refresh: string;
|
|
130
|
+
close: string;
|
|
131
|
+
closeLeft: string;
|
|
132
|
+
closeRight: string;
|
|
133
|
+
closeOthers: string;
|
|
134
|
+
closeAll: string;
|
|
135
|
+
fullscreen: string;
|
|
136
|
+
exitFullscreen: string;
|
|
137
|
+
};
|
|
138
|
+
table: {
|
|
139
|
+
search: string;
|
|
140
|
+
reset: string;
|
|
141
|
+
empty: string;
|
|
142
|
+
loadFailed: string;
|
|
143
|
+
retry: string;
|
|
144
|
+
total: string;
|
|
145
|
+
refresh: string;
|
|
146
|
+
};
|
|
147
|
+
form: {
|
|
148
|
+
required: string;
|
|
149
|
+
submit: string;
|
|
150
|
+
reset: string;
|
|
151
|
+
};
|
|
152
|
+
chart: {
|
|
153
|
+
compact: string;
|
|
154
|
+
empty: string;
|
|
155
|
+
loading: string;
|
|
156
|
+
total: string;
|
|
157
|
+
category: string;
|
|
158
|
+
value: string;
|
|
159
|
+
percent: string;
|
|
160
|
+
summaryLine: string;
|
|
161
|
+
summaryBar: string;
|
|
162
|
+
summarySeries: string;
|
|
163
|
+
summaryPie: string;
|
|
164
|
+
summaryPieItem: string;
|
|
165
|
+
summarySpark: string;
|
|
166
|
+
summaryGauge: string;
|
|
167
|
+
};
|
|
168
|
+
error: {
|
|
169
|
+
forbidden: string;
|
|
170
|
+
notFound: string;
|
|
171
|
+
backHome: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
'en-US': {
|
|
176
|
+
campus: {
|
|
177
|
+
notify: {
|
|
178
|
+
success: string;
|
|
179
|
+
info: string;
|
|
180
|
+
warning: string;
|
|
181
|
+
error: string;
|
|
182
|
+
};
|
|
183
|
+
common: {
|
|
184
|
+
ok: string;
|
|
185
|
+
cancel: string;
|
|
186
|
+
confirm: string;
|
|
187
|
+
tip: string;
|
|
188
|
+
loading: string;
|
|
189
|
+
};
|
|
190
|
+
login: {
|
|
191
|
+
title: string;
|
|
192
|
+
username: string;
|
|
193
|
+
password: string;
|
|
194
|
+
submit: string;
|
|
195
|
+
failed: string;
|
|
196
|
+
required: string;
|
|
197
|
+
};
|
|
198
|
+
auth: {
|
|
199
|
+
tabAccount: string;
|
|
200
|
+
tabWechat: string;
|
|
201
|
+
tabRegister: string;
|
|
202
|
+
tabForgot: string;
|
|
203
|
+
backLogin: string;
|
|
204
|
+
accountPlaceholder: string;
|
|
205
|
+
passwordPlaceholder: string;
|
|
206
|
+
captcha: string;
|
|
207
|
+
captchaPlaceholder: string;
|
|
208
|
+
captchaRefresh: string;
|
|
209
|
+
captchaFailed: string;
|
|
210
|
+
captchaRequired: string;
|
|
211
|
+
wechatHint: string;
|
|
212
|
+
wechatNote: string;
|
|
213
|
+
wechatMountFailed: string;
|
|
214
|
+
wechatRetry: string;
|
|
215
|
+
qrcodeAlt: string;
|
|
216
|
+
helpTitle: string;
|
|
217
|
+
help1: string;
|
|
218
|
+
help2: string;
|
|
219
|
+
help3: string;
|
|
220
|
+
help4: string;
|
|
221
|
+
findPassword: string;
|
|
222
|
+
forgotLink: string;
|
|
223
|
+
registerLink: string;
|
|
224
|
+
phone: string;
|
|
225
|
+
phonePlaceholder: string;
|
|
226
|
+
phoneInvalid: string;
|
|
227
|
+
account: string;
|
|
228
|
+
accountRequired: string;
|
|
229
|
+
smsCode: string;
|
|
230
|
+
smsPlaceholder: string;
|
|
231
|
+
getCode: string;
|
|
232
|
+
resend: string;
|
|
233
|
+
smsSent: string;
|
|
234
|
+
smsNeedPhone: string;
|
|
235
|
+
smsNeedAccount: string;
|
|
236
|
+
registerPassword: string;
|
|
237
|
+
registerPasswordPlaceholder: string;
|
|
238
|
+
newPasswordPlaceholder: string;
|
|
239
|
+
confirmPlaceholder: string;
|
|
240
|
+
passwordPolicy: string;
|
|
241
|
+
sessionExpired: string;
|
|
242
|
+
passwordMismatch: string;
|
|
243
|
+
agreePrefix: string;
|
|
244
|
+
agreeRequired: string;
|
|
245
|
+
registerOk: string;
|
|
246
|
+
resetOk: string;
|
|
247
|
+
previewNote: string;
|
|
248
|
+
unavailableTitle: string;
|
|
249
|
+
unavailableDesc: string;
|
|
250
|
+
};
|
|
251
|
+
header: {
|
|
252
|
+
language: string;
|
|
253
|
+
theme: string;
|
|
254
|
+
logout: string;
|
|
255
|
+
myAccount: string;
|
|
256
|
+
search: string;
|
|
257
|
+
shortcuts: string;
|
|
258
|
+
fullscreen: string;
|
|
259
|
+
exitFullscreen: string;
|
|
260
|
+
notifications: string;
|
|
261
|
+
assistant: string;
|
|
262
|
+
appearance: string;
|
|
263
|
+
settings: string;
|
|
264
|
+
account: string;
|
|
265
|
+
};
|
|
266
|
+
settings: {
|
|
267
|
+
title: string;
|
|
268
|
+
themeMode: string;
|
|
269
|
+
themeColor: string;
|
|
270
|
+
themeColorCustom: string;
|
|
271
|
+
themeColorReset: string;
|
|
272
|
+
boxStyle: string;
|
|
273
|
+
boxBorder: string;
|
|
274
|
+
boxShadow: string;
|
|
275
|
+
close: string;
|
|
276
|
+
};
|
|
277
|
+
mode: {
|
|
278
|
+
light: string;
|
|
279
|
+
dark: string;
|
|
280
|
+
auto: string;
|
|
281
|
+
};
|
|
282
|
+
side: {
|
|
283
|
+
home: string;
|
|
284
|
+
collapse: string;
|
|
285
|
+
expand: string;
|
|
286
|
+
hideText: string;
|
|
287
|
+
showText: string;
|
|
288
|
+
openMenu: string;
|
|
289
|
+
closeMenu: string;
|
|
290
|
+
};
|
|
291
|
+
breadcrumb: {
|
|
292
|
+
current: string;
|
|
293
|
+
};
|
|
294
|
+
tabs: {
|
|
295
|
+
refresh: string;
|
|
296
|
+
close: string;
|
|
297
|
+
closeLeft: string;
|
|
298
|
+
closeRight: string;
|
|
299
|
+
closeOthers: string;
|
|
300
|
+
closeAll: string;
|
|
301
|
+
fullscreen: string;
|
|
302
|
+
exitFullscreen: string;
|
|
303
|
+
};
|
|
304
|
+
table: {
|
|
305
|
+
search: string;
|
|
306
|
+
reset: string;
|
|
307
|
+
empty: string;
|
|
308
|
+
loadFailed: string;
|
|
309
|
+
retry: string;
|
|
310
|
+
total: string;
|
|
311
|
+
refresh: string;
|
|
312
|
+
};
|
|
313
|
+
form: {
|
|
314
|
+
required: string;
|
|
315
|
+
submit: string;
|
|
316
|
+
reset: string;
|
|
317
|
+
};
|
|
318
|
+
chart: {
|
|
319
|
+
compact: string;
|
|
320
|
+
empty: string;
|
|
321
|
+
loading: string;
|
|
322
|
+
total: string;
|
|
323
|
+
category: string;
|
|
324
|
+
value: string;
|
|
325
|
+
percent: string;
|
|
326
|
+
summaryLine: string;
|
|
327
|
+
summaryBar: string;
|
|
328
|
+
summarySeries: string;
|
|
329
|
+
summaryPie: string;
|
|
330
|
+
summaryPieItem: string;
|
|
331
|
+
summarySpark: string;
|
|
332
|
+
summaryGauge: string;
|
|
333
|
+
};
|
|
334
|
+
error: {
|
|
335
|
+
forbidden: string;
|
|
336
|
+
notFound: string;
|
|
337
|
+
backHome: string;
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
export { zhCN, enUS };
|