Skip to content

Commit a9cdbff

Browse files
committed
♻️ nuxtI18nLocales use json as default #278
1 parent a303dd7 commit a9cdbff

File tree

11 files changed

+247
-232
lines changed

11 files changed

+247
-232
lines changed

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,16 @@
8585
"titleBar.inactiveForeground": "#e7e7e799"
8686
},
8787
"peacock.color": "#1857a4",
88+
"i18n-ally.sourceLanguage": "en-US",
89+
"i18n-ally.displayLanguage": "en-US",
90+
"i18n-ally.enabledFrameworks": ["vue"],
91+
"i18n-ally.localesPaths": ["**/i18n/locales/"],
92+
"i18n-ally.enabledParsers": ["json", "ts"],
93+
"i18n-ally.encoding": "utf-8",
94+
"i18n-ally.extract.keygenStyle": "camelCase",
95+
"i18n-ally.extract.keyMaxLength": 40,
96+
"i18n-ally.keystyle": "nested",
97+
"i18n-ally.namespace": false,
98+
"i18n-ally.dirStructure": "file",
99+
"i18n-ally.fullReloadOnChanged": true,
88100
}

layers/common/configures/nuxt-config-helper.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,13 @@ export function nuxtPublicDevProxy() {
3939
: {};
4040
}
4141

42-
export const nuxtI18nEnUs = {
43-
code: 'en-US',
44-
name: 'English',
45-
file: 'en-US.ts',
46-
language: 'en-US', // https://i18n.nuxtjs.org/docs/guide/seo
47-
};
48-
49-
export const nuxtI18nZhCn = {
50-
code: 'zh-CN',
51-
name: '简体中文',
52-
file: 'zh-CN.ts',
53-
language: 'zh-CN',
42+
export function nuxtI18nLocale(code: string, name: string, ext = 'json') {
43+
return {
44+
code,
45+
name,
46+
file: `${code}.${ext}`,
47+
language: code, // https://i18n.nuxtjs.org/docs/guide/seo
48+
};
5449
};
5550

5651
/**
@@ -69,12 +64,20 @@ export const nuxtI18nZhCn = {
6964
* export default () => ({
7065
* $vuetify,
7166
* });
72-
* // or static message
67+
* // or static message, but *.json is recommended
7368
* export default {
7469
* error: {}
7570
* };
7671
```
7772
*
7873
* @see https://i18n.nuxtjs.org/docs/guide/layers#merging-locales
7974
*/
80-
export const nuxtI18nLocales = [nuxtI18nEnUs, nuxtI18nZhCn];
75+
export const nuxtI18nLocales = [
76+
nuxtI18nLocale('en-US', 'English', 'json'),
77+
nuxtI18nLocale('zh-CN', '简体中文', 'json'),
78+
];
79+
80+
export const nuxtI18nLocalesTs = [
81+
nuxtI18nLocale('en-US', 'English', 'ts'),
82+
nuxtI18nLocale('zh-CN', '简体中文', 'ts'),
83+
];
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"error": {
3+
"authn": {
4+
"unauthorized": "unauthorized request",
5+
"onlyUserPass": "support username password only",
6+
"badCredentials": "bad credentials",
7+
"locked": "user account is locked",
8+
"disabled": "user account is disabled",
9+
"expired": "user account has expired",
10+
"credentialsExpired": "user credentials have expired",
11+
"failureWaiting1": "bad credentials, retry after {0}s"
12+
},
13+
"authz": {
14+
"accessDenied": "Access is denied"
15+
},
16+
"assert": {
17+
"true": "must be true",
18+
"false": "must be false",
19+
"null": "must be null",
20+
"notNull": "must not be null",
21+
"empty": "must be empty",
22+
"notEmpty": "must not be empty",
23+
"equal1": "must equal {0}",
24+
"notEqual1": "must not equal {0}",
25+
"greaterEqual1": "must be greater than or equal to {0}",
26+
"greater1": "must be greater than {0}",
27+
"lessEqual1": "must be less than or equal to {0}",
28+
"less1": "must be less than {0}",
29+
"true1": "{0} must be true",
30+
"false1": "{0} must be false",
31+
"null1": "{0} must be null",
32+
"notNull1": "{0} must not be null",
33+
"empty1": "{0} must be empty",
34+
"notEmpty1": "{0} must not be empty",
35+
"equal2": "{0} must equal {1}",
36+
"notEqual2": "{0} must not equal {1}",
37+
"greaterEqual2": "{0} must be greater than or equal to {1}",
38+
"greater2": "{0} must be greater than {1}",
39+
"lessEqual2": "{0} must be less than or equal to {1}",
40+
"less2": "{0} must be less than {1}"
41+
},
42+
"system": {
43+
"message1": "system error, {0}"
44+
},
45+
"fetcher": {
46+
"400": "Bad request, please check the input",
47+
"401": "Unauthorized, login and try again",
48+
"403": "Forbidden, access denied",
49+
"404": "Not found, please check the URL",
50+
"405": "Method not allowed, please check the method",
51+
"406": "Not acceptable, please check the Accept header",
52+
"408": "Request timeout, please try again later",
53+
"409": "Conflict, please check the request",
54+
"410": "Gone, the resource is no longer available",
55+
"411": "Length required, please provide Content-Length",
56+
"412": "Precondition failed, please check the request conditions",
57+
"413": "Payload too large, please check the payload",
58+
"414": "URI too long, please check the URL length",
59+
"415": "Unsupported media type, please check the media type",
60+
"417": "Expectation failed, please check the Expect header",
61+
"422": "Unprocessable entity, please check the request content",
62+
"429": "Too many requests, please try again later",
63+
"500": "Internal server error, please try again later",
64+
"501": "Not implemented, server does not support the request",
65+
"502": "Bad gateway, please try again later",
66+
"503": "Service unavailable, please try again later",
67+
"504": "Gateway timeout, please try again later",
68+
"505": "HTTP version not supported, please check the request version"
69+
}
70+
},
71+
"ui": {
72+
"button": {
73+
"submit": "Submit",
74+
"cancel": "Cancel",
75+
"confirm": "Confirm",
76+
"close": "Close",
77+
"ok": "OK",
78+
"back": "Back",
79+
"next": "Next",
80+
"prev": "Prev",
81+
"retry": "Retry",
82+
"delete": "Delete",
83+
"edit": "Edit",
84+
"save": "Save",
85+
"reset": "Reset",
86+
"clear": "Clear",
87+
"search": "Search",
88+
"filter": "Filter",
89+
"sort": "Sort"
90+
},
91+
"label": {
92+
"notice": "Notice",
93+
"error": "Error",
94+
"warning": "Warning",
95+
"info": "Info",
96+
"success": "Success"
97+
},
98+
"paging": {
99+
"option": "Pagination Options",
100+
"page": "Page",
101+
"data": "Data",
102+
"jumpTo": "Jump to",
103+
"pageSize": "Page Size"
104+
}
105+
}
106+
}

layers/common/i18n/locales/en-US.ts

Lines changed: 0 additions & 106 deletions
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"error": {
3+
"authn": {
4+
"unauthorized": "未经授权的请求",
5+
"onlyUserPass": "仅支持账号密码方式登录",
6+
"badCredentials": "密码错误",
7+
"locked": "账号已锁定",
8+
"disabled": "账号已禁用",
9+
"expired": "账号已过期",
10+
"credentialsExpired": "密码已过期",
11+
"failureWaiting1": "密码错误,请{0}秒后重试"
12+
},
13+
"authz": {
14+
"accessDenied": "禁止访问"
15+
},
16+
"assert": {
17+
"true": "必须是true",
18+
"false": "必须是false",
19+
"null": "必须是null",
20+
"notNull": "必须不是null",
21+
"empty": "必须是空",
22+
"notEmpty": "必须不是空",
23+
"equal1": "必须等于{0}",
24+
"notEqual1": "必须不等于{0}",
25+
"greaterEqual1": "必须大于等于{0}",
26+
"greater1": "必须大于{0}",
27+
"lessEqual1": "必须小于等于{0}",
28+
"less1": "必须小于{0}",
29+
"true1": "{0}必须是true",
30+
"false1": "{0}必须是false",
31+
"null1": "{0}必须是null",
32+
"notNull1": "{0}必须不是null",
33+
"empty1": "{0}必须是空",
34+
"notEmpty1": "{0}必须不是空",
35+
"equal2": "{0}必须等于{1}",
36+
"notEqual2": "{0}必须不等于{1}",
37+
"greaterEqual2": "{0}必须大于等于{1}",
38+
"greater2": "{0}必须大于{1}",
39+
"lessEqual2": "{0}必须小于等于{1}",
40+
"less2": "{0}必须小于{1}"
41+
},
42+
"system": {
43+
"message1": "系统错误,{0}"
44+
},
45+
"fetcher": {
46+
"400": "错误的请求,请检查输入",
47+
"401": "未授权,请登录后重试",
48+
"403": "禁止访问,无权限",
49+
"404": "未找到,请检查 URL",
50+
"405": "方法不允许,请检查请求方法",
51+
"406": "不可接受,请检查 Accept 头",
52+
"408": "请求超时,请稍后重试",
53+
"409": "请求冲突,请检查请求内容",
54+
"410": "资源已删除,不再可用",
55+
"411": "需要指定长度,请提供 Content-Length",
56+
"412": "前置条件未满足,请检查请求条件",
57+
"413": "请求体过大,请检查请求内容",
58+
"414": "URI 过长,请检查 URL 长度",
59+
"415": "不支持的媒体类型,请检查请求格式",
60+
"417": "预期失败,请检查 Expect 头",
61+
"422": "无法处理的实体,请检查请求内容",
62+
"429": "请求过多,请稍后重试",
63+
"500": "服务器内部错误,请稍后重试",
64+
"501": "未实现,服务器不支持该请求",
65+
"502": "网关错误,请稍后重试",
66+
"503": "服务不可用,请稍后重试",
67+
"504": "网关超时,请稍后重试",
68+
"505": "HTTP 版本不支持,请检查请求版本"
69+
}
70+
},
71+
"ui": {
72+
"button": {
73+
"submit": "提交",
74+
"cancel": "取消",
75+
"confirm": "确认",
76+
"close": "关闭",
77+
"ok": "确定",
78+
"back": "返回",
79+
"next": "下一步",
80+
"prev": "上一步",
81+
"retry": "重试",
82+
"delete": "删除",
83+
"edit": "编辑",
84+
"save": "保存",
85+
"reset": "重置",
86+
"clear": "清除",
87+
"search": "搜索",
88+
"filter": "过滤",
89+
"sort": "排序"
90+
},
91+
"label": {
92+
"notice": "通知",
93+
"error": "错误",
94+
"warning": "警告",
95+
"info": "信息",
96+
"success": "成功"
97+
},
98+
"paging": {
99+
"option": "分页选项",
100+
"page": "页码",
101+
"data": "条数",
102+
"jumpTo": "跳至页码",
103+
"pageSize": "每页条数"
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)