You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As our community gets bigger and bigger, language becomes a barrier for users and players from different countries to communicate. To change this, we made `I18nAPI` and encourage plugin creators use it.
3
+
As our community gets bigger and bigger, language becomes a barrier for users and players from different countries to
4
+
communicate. To change this, we made `I18nAPI` and encourage plugin creators use it.
The file[^1]/directory[^2] where the translation data is located
13
-
- defaultLocaleName: `String`
14
-
**This parameter is deprecated since 0.9.0, it will follows LeviLamina's language**. default locale name, in the form of `zh_CN` or `en` (this parameter will be used if the target language is not provided for the translation of `i18n.tr` or `i18n.get`)
15
-
If an empty string is passed in, the default follows the system language
16
-
- defaultLangData: `Object`
17
-
This parameter will be used to complete or create translation files in the form of
18
-
```js
19
-
{
20
-
localeName: {
21
-
"src":"translation"
22
-
},
23
-
en_CN: {
24
-
"a.b.c.d.114514":"1919810",
25
-
"src":"source"
11
+
- path: `String`
12
+
The file[^1]/directory[^2] where the translation data is located
13
+
- defaultLocaleName: `String`
14
+
default locale name, in the form of `zh_CN` or `en` (this parameter will be used if the target language is not
15
+
provided for the translation of `i18n.tr` or `i18n.get`)
16
+
If an empty string is passed in, the default follows the system language
17
+
- defaultLangData: `Object`
18
+
This parameter will be used to complete or create translation files in the form of
19
+
```js
20
+
{
21
+
localeName: {
22
+
"src":"translation"
23
+
},
24
+
en_CN: {
25
+
"a.b.c.d.114514":"1919810",
26
+
"src":"source"
27
+
}
26
28
}
27
-
}
28
-
```
29
+
```
29
30
- Throw:
30
-
- Invalid parameter
31
+
- Invalid parameter
31
32
32
33
[^1]: the file must be inJSON format and the content of the file should be similar to
34
+
33
35
```json
34
36
{
35
-
"localeName": {
36
-
"src": "translation"
37
-
},
38
-
"zh_CN": {
39
-
"a.b.c.d.114514": "1919810",
40
-
"src": "源"
41
-
}
37
+
"localeName": {
38
+
"src": "translation"
39
+
},
40
+
"zh_CN": {
41
+
"a.b.c.d.114514": "1919810",
42
+
"src": "源"
42
43
}
44
+
}
43
45
```
44
46
45
47
[^2]: Please add the path separator (`/` or `\\\`) at the end of the path.
46
-
The contents of the directory should be similar to.
48
+
The contents of the directory should be similar to.
49
+
47
50
```
48
51
┌ LOCALE_name.json
49
52
[Dir] ┼ en.json
50
53
└ zh_CN.json
51
54
```
52
-
Each file inside should be similar to:
55
+
56
+
Each file inside should be similar to:
57
+
53
58
```json
54
59
{
55
-
"a.c.b.d":"translation",
56
-
"use": {
57
-
"nested": {
58
-
"src":"translation"
59
-
},
60
-
"114514": {
61
-
"1919810":"heng heng aaaaaaaaaaaaaaaaaaaaaaaaa",
62
-
"a":"此处的ID为use.nested.114514.a",
63
-
"b":"The ID of this will be use.nested.114514.b"
64
-
}
60
+
"a.c.b.d":"translation",
61
+
"use": {
62
+
"nested": {
63
+
"src":"translation"
64
+
},
65
+
"114514": {
66
+
"1919810":"heng heng aaaaaaaaaaaaaaaaaaaaaaaaa",
67
+
"a":"此处的ID为use.nested.114514.a",
68
+
"b":"The ID of this will be use.nested.114514.b"
65
69
}
66
70
}
71
+
}
67
72
```
68
73
69
74
<br/>
@@ -73,13 +78,13 @@ As our community gets bigger and bigger, language becomes a barrier for users an
73
78
`i18n.get(key[,localeName])`
74
79
75
80
- Params:
76
-
- key: `String`
77
-
Text or ID
78
-
- localeName: `String`(Optional)
79
-
Target language, default is the `defaultLocaleName` passed in when `i18n.load`.
81
+
- key: `String`
82
+
Text or ID
83
+
- localeName: `String`(Optional)
84
+
Target language, default is the `defaultLocaleName` passed in when `i18n.load`.
80
85
- Return value: `String` translation (if no translation is found after multiple fallbacks, then `key` is returned)
81
86
- Throw:
82
-
- Invalid parameter
87
+
- Invalid parameter
83
88
84
89
<br/>
85
90
@@ -88,16 +93,16 @@ As our community gets bigger and bigger, language becomes a barrier for users an
88
93
`i18n.trl(localeName, key, ...) `
89
94
90
95
- Parameters:
91
-
- localeName: `String`
92
-
Target language
93
-
- key: `String`
94
-
Text or ID
95
-
- ... : `Any`
96
-
Format arguments
96
+
- localeName: `String`
97
+
Target language
98
+
- key: `String`
99
+
Text or ID
100
+
- ... : `Any`
101
+
Format arguments
97
102
- Return value: `String` translated and formatted text
98
103
- Note: Formatting should follow [syntax](https://fmt.dev/latest/syntax.html)
99
104
- Throw:
100
-
- Invalid parameter
105
+
- Invalid parameter
101
106
102
107
<br/>
103
108
@@ -106,49 +111,51 @@ As our community gets bigger and bigger, language becomes a barrier for users an
106
111
`i18n.tr(key, ...) `
107
112
108
113
- Parameters:
109
-
- key: `String`
110
-
Text or ID
111
-
- ... : `Any`
112
-
Format arguments
114
+
- key: `String`
115
+
Text or ID
116
+
- ... : `Any`
117
+
Format arguments
113
118
- Return value: `String` translated and formatted text
114
119
- Note: Formatting should follow [syntax](https://fmt.dev/latest/syntax.html)
0 commit comments