Skip to content

Commit a59df67

Browse files
committed
Add Chinese(zh-cn) translations
1 parent 46ac5c2 commit a59df67

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ netlifyIdentity.close();
8181
netlifyIdentity.logout();
8282

8383
// Refresh the user's JWT
84-
// Call in on('login') handler to ensure token refreshed after it expires (1hr)
84+
// Call in on('login') handler to ensure token refreshed after it expires (1hr)
8585
// Note: this method returns a promise.
8686
netlifyIdentity.refresh().then((jwt)=>console.log(jwt))
8787

@@ -157,7 +157,7 @@ module API. Options include:
157157
container: '#some-query-selector'; // container to attach to
158158
APIUrl: 'https://www.example.com/.netlify/functions/identity'; // Absolute url to endpoint. ONLY USE IN SPECIAL CASES!
159159
namePlaceholder: 'some-placeholder-for-Name'; // custom placeholder for name input form
160-
locale: 'en'; // language code for translations - available: en, fr, es, pt, hu, pl, cs, sk - default to en
160+
locale: 'en'; // language code for translations - available: en, fr, es, pt, hu, pl, cs, sk, zhCN - default to en
161161
```
162162
163163
Generally avoid setting the `APIUrl`. You should only set this when your app is

src/translations/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import * as pt from "./pt.json";
66
import * as pl from "./pl.json";
77
import * as cs from "./cs.json";
88
import * as sk from "./sk.json";
9+
import * as zhCN from "./zh-cn.json";
910

1011
export const defaultLocale = "en";
11-
const translations = { en, fr, es, hu, pt, pl, cs, sk };
12+
const translations = { en, fr, es, hu, pt, pl, cs, sk, zhCN };
1213

1314
export const getTranslation = (key, locale = defaultLocale) => {
1415
const translated = translations[locale] && translations[locale][key];

src/translations/index.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ describe("translations", () => {
4848
expect(getTranslation("log_in", "sk")).toEqual("Prihlásiť sa");
4949
});
5050

51+
it("should return translation for 'zhCN' locale", () => {
52+
const { getTranslation } = require("./");
53+
expect(getTranslation("log_in", "zhCN")).toEqual("登录");
54+
});
55+
5156
it("should return key for non existing translation", () => {
5257
const { getTranslation } = require("./");
5358
expect(getTranslation("unknown_key")).toEqual("unknown_key");
@@ -62,6 +67,7 @@ describe("translations", () => {
6267
jest.mock("./cs.json", () => ({}));
6368
jest.mock("./sk.json", () => ({}));
6469
jest.mock("./pl.json", () => ({}));
70+
jest.mock("./zh-cn.json", () => ({}));
6571

6672
const { getTranslation } = require("./");
6773
expect(getTranslation("log_in")).toEqual("Log in");
@@ -72,5 +78,6 @@ describe("translations", () => {
7278
expect(getTranslation("log_in", "pl")).toEqual("Log in");
7379
expect(getTranslation("log_in", "cs")).toEqual("Log in");
7480
expect(getTranslation("log_in", "sk")).toEqual("Log in");
81+
expect(getTranslation("log_in", "zhCN")).toEqual("登录");
7582
});
7683
});

src/translations/zh-cn.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"log_in": "登录",
3+
"log_out": "注销",
4+
"logged_in_as": "已登录账号: ",
5+
"logged_in": "已登录",
6+
"logging_in": "正在登录",
7+
"logging_out": "已退出",
8+
"sign_up": "注册",
9+
"signing_up": "正在注册",
10+
"forgot_password": "忘记密码?",
11+
"recover_password": "恢复密码",
12+
"send_recovery_email": "发送恢复邮件",
13+
"sending_recovery_email": "正在发送恢复邮件",
14+
"never_mind": "忽略",
15+
"update_password": "更新密码",
16+
"updating_password": "正在更新密码",
17+
"complete_your_signup": "完成注册",
18+
"site_url_title": "开发模式设置",
19+
"site_url_link_text": "清理 localhost URL",
20+
"site_url_message": "你似乎正在运行本地服务. 请告诉我们你的 Netlify 网站的 URL.",
21+
"site_url_label": "输入 Netlify 网站的 URL",
22+
"site_url_placeholder": "Netlify 网站的 URL",
23+
"site_url_submit": "设置网站 URL",
24+
"message_confirm": "已向您的邮箱发送确认邮件,请点击此处链接以继续.",
25+
"message_password_mail": "我们已向您的帐户发送了恢复邮件,请点击此处的链接重置您的密码.",
26+
"message_email_changed": "您的电子邮件地址已更新!",
27+
"message_verfication_error": "验证您的帐户时出错。请重试或联系管理员",
28+
"message_signup_disabled": "公开注册已关闭. 请联系管理员获取邀请链接.",
29+
"form_name_placeholder": "用户名",
30+
"form_email_label": "输入邮箱",
31+
"form_name_label": "输入用户名",
32+
"form_email_placeholder": "邮箱",
33+
"form_password_label": "输入密码",
34+
"form_password_placeholder": "密码",
35+
"coded_by": "由 Netlify 强力驱动",
36+
"continue_with": "继续登录",
37+
"No user found with this email": "未找到该邮箱的用户",
38+
"Invalid Password": "无效密码",
39+
"Email not confirmed": "邮箱未确认",
40+
"User not found": "用户未找到"
41+
}

0 commit comments

Comments
 (0)