|
@@ -10,58 +10,16 @@ import CommentInput from "./components/CommentInput";
|
10
|
10
|
import CommentList from "./components/CommentList";
|
11
|
11
|
import Editor from "./components/Editor";
|
12
|
12
|
import RenderText from "./components/RenderText";
|
13
|
|
-// import lang from "./lang";
|
|
13
|
+import { SUPPORT_LOCALES, LOCALES_RESPONSE } from "./lang";
|
14
|
14
|
import USdata from "./lang/en-US.js";
|
15
|
15
|
import CNdata from "./lang/zh-CN.js";
|
16
|
16
|
import "./App.css";
|
17
|
|
-// import styles from "./App.module.css";
|
18
|
|
-
|
19
|
|
-/**
|
20
|
|
- * 当前支持的语言
|
21
|
|
- */
|
22
|
|
-const SUPPORT_LOCALES = [
|
23
|
|
- {
|
24
|
|
- name: "English",
|
25
|
|
- value: "en-US"
|
26
|
|
- },
|
27
|
|
- {
|
28
|
|
- name: "简体中文",
|
29
|
|
- value: "zh-CN"
|
30
|
|
- }
|
31
|
|
-];
|
32
|
17
|
|
33
|
18
|
const LOCALES = {
|
34
|
19
|
"zh-CN": CNdata,
|
35
|
20
|
"en-US": USdata
|
36
|
21
|
};
|
37
|
22
|
|
38
|
|
-const LOCALES_RESPONSE = {
|
39
|
|
- "zh-CN": {
|
40
|
|
- "not found": "没有数据",
|
41
|
|
- "auth failed": "请先登录",
|
42
|
|
- "create comment failed": "创建评论失败",
|
43
|
|
- "comment favor failed": "评论点赞失败",
|
44
|
|
- "delete comment favor failed": "评论取消点赞失败",
|
45
|
|
- "get comments failed": "获取评论列表失败",
|
46
|
|
- "create reply failed": "创建回复失败",
|
47
|
|
- "reply favor failed": "回复点赞失败",
|
48
|
|
- "delete reply favor failed": "删除回复点赞失败",
|
49
|
|
- "get replies failed": "获取回复列表失败"
|
50
|
|
- },
|
51
|
|
- "en-US": {
|
52
|
|
- "not found": "no data",
|
53
|
|
- "auth failed": "please log in first",
|
54
|
|
- "create comment failed": "Failed to create comment",
|
55
|
|
- "comment favor failed": "Comment likes failure",
|
56
|
|
- "delete comment favor failed": "评论取消点赞失败",
|
57
|
|
- "get comments failed": "Comment cancels praise failure",
|
58
|
|
- "create reply failed": "Create reply failed",
|
59
|
|
- "reply favor failed": "Reply to praise failed",
|
60
|
|
- "delete reply favor failed": "Delete reply clicks failed",
|
61
|
|
- "get replies failed": "Failed to get reply list"
|
62
|
|
- }
|
63
|
|
-};
|
64
|
|
-
|
65
|
23
|
class App extends Component {
|
66
|
24
|
constructor(props) {
|
67
|
25
|
super(props);
|
|
@@ -119,11 +77,9 @@ class App extends Component {
|
119
|
77
|
urlLocaleKey: "lang"
|
120
|
78
|
});
|
121
|
79
|
}
|
122
|
|
- console.log("currentLocale", currentLocale);
|
123
|
80
|
currentLocale = SUPPORT_LOCALES.find(item => item.value === currentLocale)
|
124
|
81
|
? currentLocale
|
125
|
82
|
: "zh-CN";
|
126
|
|
- console.log("locales is", LOCALES[currentLocale]);
|
127
|
83
|
intl
|
128
|
84
|
.init({
|
129
|
85
|
currentLocale,
|