@markuplint/i18n 4.3.0 → 4.5.0-alpha.0
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/$schema.json +15 -0
- package/CHANGELOG.md +12 -0
- package/README.md +16 -5
- package/cjs/translator.js +12 -3
- package/cjs/types.d.ts +6 -1
- package/esm/translator.mjs +12 -3
- package/esm/types.d.ts +6 -1
- package/locales/ja.json +15 -0
- package/package.json +2 -2
package/$schema.json
CHANGED
|
@@ -48,12 +48,15 @@
|
|
|
48
48
|
"c:invalid": { "type": "string" },
|
|
49
49
|
"c:non-standard": { "type": "string" },
|
|
50
50
|
"c:obsolete": { "type": "string" },
|
|
51
|
+
"cell overlap": { "type": "string" },
|
|
51
52
|
"character": { "type": "string" },
|
|
52
53
|
"characters": { "type": "string" },
|
|
53
54
|
"child element": { "type": "string" },
|
|
54
55
|
"class name": { "type": "string" },
|
|
55
56
|
"code block": { "type": "string" },
|
|
56
57
|
"colon": { "type": "string" },
|
|
58
|
+
"column": { "type": "string" },
|
|
59
|
+
"columns": { "type": "string" },
|
|
57
60
|
"comma-separated list": { "type": "string" },
|
|
58
61
|
"comma": { "type": "string" },
|
|
59
62
|
"commas": { "type": "string" },
|
|
@@ -107,6 +110,8 @@
|
|
|
107
110
|
"minute": { "type": "string" },
|
|
108
111
|
"month": { "type": "string" },
|
|
109
112
|
"name": { "type": "string" },
|
|
113
|
+
"navigable target name": { "type": "string" },
|
|
114
|
+
"navigable target names": { "type": "string" },
|
|
110
115
|
"newline": { "type": "string" },
|
|
111
116
|
"node": { "type": "string" },
|
|
112
117
|
"non-negative integer": { "type": "string" },
|
|
@@ -118,6 +123,7 @@
|
|
|
118
123
|
"one or more elements": { "type": "string" },
|
|
119
124
|
"one": { "type": "string" },
|
|
120
125
|
"origin": { "type": "string" },
|
|
126
|
+
"orphaned end tag": { "type": "string" },
|
|
121
127
|
"password": { "type": "string" },
|
|
122
128
|
"perceptible nodes": { "type": "string" },
|
|
123
129
|
"placeholder label option": { "type": "string" },
|
|
@@ -128,6 +134,8 @@
|
|
|
128
134
|
"regular expression": { "type": "string" },
|
|
129
135
|
"role": { "type": "string" },
|
|
130
136
|
"roles": { "type": "string" },
|
|
137
|
+
"row": { "type": "string" },
|
|
138
|
+
"rows": { "type": "string" },
|
|
131
139
|
"second": { "type": "string" },
|
|
132
140
|
"semantics": { "type": "string" },
|
|
133
141
|
"serialized-origin": { "type": "string" },
|
|
@@ -177,6 +185,7 @@
|
|
|
177
185
|
"{0:c} on {1}": { "type": "string" },
|
|
178
186
|
"{0} ({1})": { "type": "string" },
|
|
179
187
|
"{0} according to {1}": { "type": "string" },
|
|
188
|
+
"{0} are causing {1}": { "type": "string" },
|
|
180
189
|
"{0} as {1}": { "type": "string" },
|
|
181
190
|
"{0} associates only {1}": { "type": "string" },
|
|
182
191
|
"{0} behaves the same as {1} if {2}": { "type": "string" },
|
|
@@ -188,6 +197,7 @@
|
|
|
188
197
|
"{0} does not exist": { "type": "string" },
|
|
189
198
|
"{0} expects {1:c}": { "type": "string" },
|
|
190
199
|
"{0} expects {1}": { "type": "string" },
|
|
200
|
+
"{0} extra {1} in {2}": { "type": "string" },
|
|
191
201
|
"{0} greater than {1} less than {2}": { "type": "string" },
|
|
192
202
|
"{0} greater than {1} less than or equal to {2}": { "type": "string" },
|
|
193
203
|
"{0} greater than {1}": { "type": "string" },
|
|
@@ -201,6 +211,7 @@
|
|
|
201
211
|
"{0} is {1:c}": { "type": "string" },
|
|
202
212
|
"{0} is {1}": { "type": "string" },
|
|
203
213
|
"{0} is {1} but {2}": { "type": "string" },
|
|
214
|
+
"{0} is causing {1}": { "type": "string" },
|
|
204
215
|
"{0} is disallowed": { "type": "string" },
|
|
205
216
|
"{0} is disallowed to accept the following values: {1}": { "type": "string" },
|
|
206
217
|
"{0} is matched with the below disallowed patterns: {1}": { "type": "string" },
|
|
@@ -211,6 +222,7 @@
|
|
|
211
222
|
"{0} is unmatched with the below patterns: {1}": { "type": "string" },
|
|
212
223
|
"{0} less than {1}": { "type": "string" },
|
|
213
224
|
"{0} less than or equal to {1}": { "type": "string" },
|
|
225
|
+
"{0} missing {1} in {2}": { "type": "string" },
|
|
214
226
|
"{0} must {1}": { "type": "string" },
|
|
215
227
|
"{0} must be {1}": { "type": "string" },
|
|
216
228
|
"{0} must not {1}": { "type": "string" },
|
|
@@ -238,6 +250,7 @@
|
|
|
238
250
|
"add {0}": { "type": "string" },
|
|
239
251
|
"allowed values are: {0}": { "type": "string" },
|
|
240
252
|
"also disallows {0} in this context": { "type": "string" },
|
|
253
|
+
"ambiguous {0}": { "type": "string" },
|
|
241
254
|
"an {0}": { "type": "string" },
|
|
242
255
|
"as its {0} is already provided by {1}": { "type": "string" },
|
|
243
256
|
"cannot overwrite {0} to {1}": { "type": "string" },
|
|
@@ -246,7 +259,9 @@
|
|
|
246
259
|
"corresponding {0}": { "type": "string" },
|
|
247
260
|
"detected {0} between {1} and {2}": { "type": "string" },
|
|
248
261
|
"did you mean \"{0}\"?": { "type": "string" },
|
|
262
|
+
"don't use {0}": { "type": "string" },
|
|
249
263
|
"either {0}": { "type": "string" },
|
|
264
|
+
"exceeds the number of available {0}": { "type": "string" },
|
|
250
265
|
"extra {0}": { "type": "string" },
|
|
251
266
|
"first {0}": { "type": "string" },
|
|
252
267
|
"found {0}": { "type": "string" },
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [4.5.0-alpha.0](https://github.com/markuplint/markuplint/compare/@markuplint/i18n@4.4.0...@markuplint/i18n@4.5.0-alpha.0) (2024-05-04)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **i18n:** add `useLastSeparator` param to Translate listed phrases API ([2da7e11](https://github.com/markuplint/markuplint/commit/2da7e11e9838af4cf7bde64725c43a5d08a2e0a1))
|
|
11
|
+
- **rules:** add `no-ambiguous-navigable-target-names` rule ([742db4e](https://github.com/markuplint/markuplint/commit/742db4eb98b8f27e8a1f6a82d3b6541871e02a5c))
|
|
12
|
+
- **rules:** add `table-row-column-alignment` rule ([4b071f8](https://github.com/markuplint/markuplint/commit/4b071f8d7dae0f1500e1a77046b289489eb5a598))
|
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@ console.log(phrase);
|
|
|
121
121
|
### Translate listed phrases
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
|
-
type T = (phrases: string[]) => string;
|
|
124
|
+
type T = (phrases: string[], useLastSeparator?: boolean) => string;
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
```ts
|
|
@@ -135,12 +135,23 @@ console.log(list);
|
|
|
135
135
|
// => "element", "attribute", "value"
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
+
```ts
|
|
139
|
+
const list = t(['element', 'attribute', 'value'], true);
|
|
140
|
+
|
|
141
|
+
console.log(list);
|
|
142
|
+
// => 「要素」「属性」「値」
|
|
143
|
+
|
|
144
|
+
/* If locale is "en" */
|
|
145
|
+
console.log(list);
|
|
146
|
+
// => "element", "attribute" and "value"
|
|
147
|
+
```
|
|
148
|
+
|
|
138
149
|
It converts the character-separated list specified in each locale.
|
|
139
150
|
|
|
140
|
-
| Locale | Separator | Before Char | After Char |
|
|
141
|
-
| ------ | -------------------- | -------------------------- | --------------------------- |
|
|
142
|
-
| **en** | `, ` (comma + space) | `"` (double quote) | `"` (double quote) |
|
|
143
|
-
| **ja** | none (empty string) | `「` (left corner bracket) | `」` (right corner bracket) |
|
|
151
|
+
| Locale | Separator | Before Char | After Char | Last Separator |
|
|
152
|
+
| ------ | -------------------- | -------------------------- | --------------------------- | ------------------------------ |
|
|
153
|
+
| **en** | `, ` (comma + space) | `"` (double quote) | `"` (double quote) | `and` (space + chars + space ) |
|
|
154
|
+
| **ja** | none (empty string) | `「` (left corner bracket) | `」` (right corner bracket) | none (empty string) |
|
|
144
155
|
|
|
145
156
|
### Avoid translation
|
|
146
157
|
|
package/cjs/translator.js
CHANGED
|
@@ -5,15 +5,24 @@ const defaultListFormat = {
|
|
|
5
5
|
quoteStart: '"',
|
|
6
6
|
quoteEnd: '"',
|
|
7
7
|
separator: ', ',
|
|
8
|
+
lastSeparator: ' and ',
|
|
8
9
|
};
|
|
9
10
|
function translator(localeSet) {
|
|
10
11
|
return (messageTmpl, ...keywords) => {
|
|
11
12
|
let message = messageTmpl;
|
|
12
13
|
if (typeof messageTmpl !== 'string') {
|
|
14
|
+
if (messageTmpl.length === 0) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
13
17
|
const format = localeSet?.listFormat ?? defaultListFormat;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const useLastSeparator = keywords[0] == null || keywords[0] == false ? false : true;
|
|
19
|
+
const lastSeparator = useLastSeparator ? format.lastSeparator ?? format.separator : format.separator;
|
|
20
|
+
const list = messageTmpl.map(keyword => format.quoteStart + translateKeyword(keyword, '', localeSet) + format.quoteEnd);
|
|
21
|
+
if (list.length === 1) {
|
|
22
|
+
return list[0];
|
|
23
|
+
}
|
|
24
|
+
const last = list.pop();
|
|
25
|
+
return list.join(format.separator) + lastSeparator + last;
|
|
17
26
|
}
|
|
18
27
|
const input = messageTmpl;
|
|
19
28
|
if (keywords.length === 0) {
|
package/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface Translator {
|
|
2
|
+
(messageTmpl: string, ...keywords: readonly Primitive[]): string;
|
|
3
|
+
(messageTmpl: readonly string[], useLastSeparator?: boolean): string;
|
|
4
|
+
(messageTmpl: string | readonly string[], ...keywords: readonly Primitive[]): string;
|
|
5
|
+
}
|
|
2
6
|
export type LocaleSet = {
|
|
3
7
|
readonly locale: string;
|
|
4
8
|
readonly listFormat?: ListFormat;
|
|
@@ -9,6 +13,7 @@ export type ListFormat = {
|
|
|
9
13
|
readonly quoteStart: string;
|
|
10
14
|
readonly quoteEnd: string;
|
|
11
15
|
readonly separator: string;
|
|
16
|
+
readonly lastSeparator?: string;
|
|
12
17
|
};
|
|
13
18
|
export type Primitive = string | number | boolean;
|
|
14
19
|
export type LocalesKeywords = {
|
package/esm/translator.mjs
CHANGED
|
@@ -2,15 +2,24 @@ const defaultListFormat = {
|
|
|
2
2
|
quoteStart: '"',
|
|
3
3
|
quoteEnd: '"',
|
|
4
4
|
separator: ', ',
|
|
5
|
+
lastSeparator: ' and ',
|
|
5
6
|
};
|
|
6
7
|
export function translator(localeSet) {
|
|
7
8
|
return (messageTmpl, ...keywords) => {
|
|
8
9
|
let message = messageTmpl;
|
|
9
10
|
if (typeof messageTmpl !== 'string') {
|
|
11
|
+
if (messageTmpl.length === 0) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
10
14
|
const format = localeSet?.listFormat ?? defaultListFormat;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const useLastSeparator = keywords[0] == null || keywords[0] == false ? false : true;
|
|
16
|
+
const lastSeparator = useLastSeparator ? format.lastSeparator ?? format.separator : format.separator;
|
|
17
|
+
const list = messageTmpl.map(keyword => format.quoteStart + translateKeyword(keyword, '', localeSet) + format.quoteEnd);
|
|
18
|
+
if (list.length === 1) {
|
|
19
|
+
return list[0];
|
|
20
|
+
}
|
|
21
|
+
const last = list.pop();
|
|
22
|
+
return list.join(format.separator) + lastSeparator + last;
|
|
14
23
|
}
|
|
15
24
|
const input = messageTmpl;
|
|
16
25
|
if (keywords.length === 0) {
|
package/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface Translator {
|
|
2
|
+
(messageTmpl: string, ...keywords: readonly Primitive[]): string;
|
|
3
|
+
(messageTmpl: readonly string[], useLastSeparator?: boolean): string;
|
|
4
|
+
(messageTmpl: string | readonly string[], ...keywords: readonly Primitive[]): string;
|
|
5
|
+
}
|
|
2
6
|
export type LocaleSet = {
|
|
3
7
|
readonly locale: string;
|
|
4
8
|
readonly listFormat?: ListFormat;
|
|
@@ -9,6 +13,7 @@ export type ListFormat = {
|
|
|
9
13
|
readonly quoteStart: string;
|
|
10
14
|
readonly quoteEnd: string;
|
|
11
15
|
readonly separator: string;
|
|
16
|
+
readonly lastSeparator?: string;
|
|
12
17
|
};
|
|
13
18
|
export type Primitive = string | number | boolean;
|
|
14
19
|
export type LocalesKeywords = {
|
package/locales/ja.json
CHANGED
|
@@ -36,12 +36,15 @@
|
|
|
36
36
|
"c:invalid": "は妥当ではありません",
|
|
37
37
|
"c:non-standard": "は非標準です",
|
|
38
38
|
"c:obsolete": "は廃止されています",
|
|
39
|
+
"cell overlap": "セルの交差",
|
|
39
40
|
"character": "文字",
|
|
40
41
|
"characters": "文字",
|
|
41
42
|
"child element": "子要素",
|
|
42
43
|
"class name": "クラス名",
|
|
43
44
|
"code block": "コードブロック",
|
|
44
45
|
"colon": "コロン",
|
|
46
|
+
"column": "列",
|
|
47
|
+
"columns": "列",
|
|
45
48
|
"comma-separated list": "カンマ区切りのリスト",
|
|
46
49
|
"comma": "カンマ",
|
|
47
50
|
"commas": "カンマ",
|
|
@@ -95,6 +98,8 @@
|
|
|
95
98
|
"minute": "分",
|
|
96
99
|
"month": "月",
|
|
97
100
|
"name": "名前",
|
|
101
|
+
"navigable target name": "ナビゲート可能なターゲット名",
|
|
102
|
+
"navigable target names": "ナビゲート可能なターゲット名",
|
|
98
103
|
"newline": "改行",
|
|
99
104
|
"node": "ノード",
|
|
100
105
|
"non-negative integer": "正の整数",
|
|
@@ -106,6 +111,7 @@
|
|
|
106
111
|
"one or more elements": "1つ以上の要素",
|
|
107
112
|
"one": "1",
|
|
108
113
|
"origin": "オリジン",
|
|
114
|
+
"orphaned end tag": "孤立した終了タグ",
|
|
109
115
|
"password": "パスワード",
|
|
110
116
|
"perceptible nodes": "知覚要素",
|
|
111
117
|
"placeholder label option": "プレースホルダーラベルオプション",
|
|
@@ -116,6 +122,8 @@
|
|
|
116
122
|
"regular expression": "正規表現",
|
|
117
123
|
"role": "ロール",
|
|
118
124
|
"roles": "ロール",
|
|
125
|
+
"row": "行",
|
|
126
|
+
"rows": "行",
|
|
119
127
|
"second": "秒",
|
|
120
128
|
"semantics": "セマンティクス",
|
|
121
129
|
"serialized-origin": "シリアル化されたオリジン",
|
|
@@ -161,6 +169,7 @@
|
|
|
161
169
|
"{0:c} on {1}": "{1}では、{0:c}",
|
|
162
170
|
"{0} ({1})": "{0}({1})",
|
|
163
171
|
"{0} according to {1}": "{1}において、{0}",
|
|
172
|
+
"{0} are causing {1}": "{0}が{1}を引き起こしています",
|
|
164
173
|
"{0} as {1}": "{1}として{0}",
|
|
165
174
|
"{0} associates only {1}": "{0}は{1}だけを関連付けます",
|
|
166
175
|
"{0} behaves the same as {1} if {2}": "{0}は{2}の場合、{1}と同じ振る舞いをします",
|
|
@@ -172,6 +181,7 @@
|
|
|
172
181
|
"{0} does not exist": "{0}は存在しません",
|
|
173
182
|
"{0} expects {1:c}": "{0}は{1}である必要があります",
|
|
174
183
|
"{0} expects {1}": "{0}には{1}が必要です",
|
|
184
|
+
"{0} extra {1} in {2}": "{2}に{0}つの余分な{1}があります",
|
|
175
185
|
"{0} greater than {1} less than {2}": "{1}より大きく{2}より小さい{0}",
|
|
176
186
|
"{0} greater than {1} less than or equal to {2}": "{1}より大きく{2}以下の{0}",
|
|
177
187
|
"{0} greater than {1}": "{1}より大きい{0}",
|
|
@@ -185,6 +195,7 @@
|
|
|
185
195
|
"{0} is {1:c}": "{0}{1:c}",
|
|
186
196
|
"{0} is {1} but {2}": "{0}は{1}ですが、{2}",
|
|
187
197
|
"{0} is {1}": "{0}は{1}です",
|
|
198
|
+
"{0} is causing {1}": "{0}が{1}を引き起こしています",
|
|
188
199
|
"{0} is disallowed": "{0}は禁止されています",
|
|
189
200
|
"{0} is disallowed to accept the following values: {1}": "{0}は次の値を受け取ることを禁止しています: {1}",
|
|
190
201
|
"{0} is matched with the below disallowed patterns: {1}": "{0}は次の許可しないパターンにマッチしました {1}",
|
|
@@ -195,6 +206,7 @@
|
|
|
195
206
|
"{0} is unmatched with the below patterns: {1}": "{0}は次のパターンにマッチしませんでした {1}",
|
|
196
207
|
"{0} less than {1}": "{1}より小さい{0}",
|
|
197
208
|
"{0} less than or equal to {1}": "{1}以下の{0}",
|
|
209
|
+
"{0} missing {1} in {2}": "{2}に{0}つの{1}がありません",
|
|
198
210
|
"{0} must {1}": "{0}は{1}するべきです",
|
|
199
211
|
"{0} must be {1}": "{0}は{1}にするべきです",
|
|
200
212
|
"{0} must not {1}": "{0}は{1}するべきではありません",
|
|
@@ -222,6 +234,7 @@
|
|
|
222
234
|
"add {0}": "{0}を追加してください",
|
|
223
235
|
"allowed values are: {0}": "許可されている値は次のとおりです {0}",
|
|
224
236
|
"also disallows {0} in this context": "このコンテキスト内では{0}も許可しません",
|
|
237
|
+
"ambiguous {0}": "曖昧な{0}",
|
|
225
238
|
"an {0}": "{0}",
|
|
226
239
|
"as its {0} is already provided by {1}": "その{0}は{1}によってすでに提供されています",
|
|
227
240
|
"cannot overwrite {0} to {1}": "{0}を{1}に上書きすることはできません",
|
|
@@ -230,7 +243,9 @@
|
|
|
230
243
|
"corresponding {0}": "対応する{0}",
|
|
231
244
|
"detected {0} between {1} and {2}": "{1}と{2}の間で{0}が検出されました",
|
|
232
245
|
"did you mean \"{0}\"?": "「{0}」ではありませんか?",
|
|
246
|
+
"don't use {0}": "{0}を使用しないでください",
|
|
233
247
|
"either {0}": "{0}のいずれか",
|
|
248
|
+
"exceeds the number of available {0}": "利用可能な{0}数を超えています",
|
|
234
249
|
"extra {0}": "余計な{0}",
|
|
235
250
|
"first {0}": "最初の{0}",
|
|
236
251
|
"found {0}": "{0}が発見されました",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/i18n",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-alpha.0",
|
|
4
4
|
"description": "Internationalization for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"build:cjs": "tsc --module commonjs --outDir cjs",
|
|
38
38
|
"clean": "tsc --build --clean"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "d091e2199e3dc6757c2c8edbf01fd19e8b072015"
|
|
41
41
|
}
|