@markuplint/i18n 4.4.0 → 4.5.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 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" },
@@ -129,6 +134,8 @@
129
134
  "regular expression": { "type": "string" },
130
135
  "role": { "type": "string" },
131
136
  "roles": { "type": "string" },
137
+ "row": { "type": "string" },
138
+ "rows": { "type": "string" },
132
139
  "second": { "type": "string" },
133
140
  "semantics": { "type": "string" },
134
141
  "serialized-origin": { "type": "string" },
@@ -178,6 +185,7 @@
178
185
  "{0:c} on {1}": { "type": "string" },
179
186
  "{0} ({1})": { "type": "string" },
180
187
  "{0} according to {1}": { "type": "string" },
188
+ "{0} are causing {1}": { "type": "string" },
181
189
  "{0} as {1}": { "type": "string" },
182
190
  "{0} associates only {1}": { "type": "string" },
183
191
  "{0} behaves the same as {1} if {2}": { "type": "string" },
@@ -189,6 +197,7 @@
189
197
  "{0} does not exist": { "type": "string" },
190
198
  "{0} expects {1:c}": { "type": "string" },
191
199
  "{0} expects {1}": { "type": "string" },
200
+ "{0} extra {1} in {2}": { "type": "string" },
192
201
  "{0} greater than {1} less than {2}": { "type": "string" },
193
202
  "{0} greater than {1} less than or equal to {2}": { "type": "string" },
194
203
  "{0} greater than {1}": { "type": "string" },
@@ -202,6 +211,7 @@
202
211
  "{0} is {1:c}": { "type": "string" },
203
212
  "{0} is {1}": { "type": "string" },
204
213
  "{0} is {1} but {2}": { "type": "string" },
214
+ "{0} is causing {1}": { "type": "string" },
205
215
  "{0} is disallowed": { "type": "string" },
206
216
  "{0} is disallowed to accept the following values: {1}": { "type": "string" },
207
217
  "{0} is matched with the below disallowed patterns: {1}": { "type": "string" },
@@ -212,6 +222,7 @@
212
222
  "{0} is unmatched with the below patterns: {1}": { "type": "string" },
213
223
  "{0} less than {1}": { "type": "string" },
214
224
  "{0} less than or equal to {1}": { "type": "string" },
225
+ "{0} missing {1} in {2}": { "type": "string" },
215
226
  "{0} must {1}": { "type": "string" },
216
227
  "{0} must be {1}": { "type": "string" },
217
228
  "{0} must not {1}": { "type": "string" },
@@ -239,6 +250,7 @@
239
250
  "add {0}": { "type": "string" },
240
251
  "allowed values are: {0}": { "type": "string" },
241
252
  "also disallows {0} in this context": { "type": "string" },
253
+ "ambiguous {0}": { "type": "string" },
242
254
  "an {0}": { "type": "string" },
243
255
  "as its {0} is already provided by {1}": { "type": "string" },
244
256
  "cannot overwrite {0} to {1}": { "type": "string" },
@@ -247,7 +259,9 @@
247
259
  "corresponding {0}": { "type": "string" },
248
260
  "detected {0} between {1} and {2}": { "type": "string" },
249
261
  "did you mean \"{0}\"?": { "type": "string" },
262
+ "don't use {0}": { "type": "string" },
250
263
  "either {0}": { "type": "string" },
264
+ "exceeds the number of available {0}": { "type": "string" },
251
265
  "extra {0}": { "type": "string" },
252
266
  "first {0}": { "type": "string" },
253
267
  "found {0}": { "type": "string" },
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
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](https://github.com/markuplint/markuplint/compare/@markuplint/i18n@4.5.0-alpha.0...@markuplint/i18n@4.5.0) (2024-05-04)
7
+
8
+ **Note:** Version bump only for package @markuplint/i18n
9
+
10
+ # [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)
11
+
12
+ ### Features
13
+
14
+ - **i18n:** add `useLastSeparator` param to Translate listed phrases API ([2da7e11](https://github.com/markuplint/markuplint/commit/2da7e11e9838af4cf7bde64725c43a5d08a2e0a1))
15
+ - **rules:** add `no-ambiguous-navigable-target-names` rule ([742db4e](https://github.com/markuplint/markuplint/commit/742db4eb98b8f27e8a1f6a82d3b6541871e02a5c))
16
+ - **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
- return `${format.quoteStart}${messageTmpl
15
- .map(keyword => translateKeyword(keyword, '', localeSet))
16
- .join(`${format.quoteEnd}${format.separator}${format.quoteStart}`)}${format.quoteEnd}`;
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 type Translator = (messageTmpl: string | readonly string[], ...keywords: readonly Primitive[]) => string;
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 = {
@@ -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
- return `${format.quoteStart}${messageTmpl
12
- .map(keyword => translateKeyword(keyword, '', localeSet))
13
- .join(`${format.quoteEnd}${format.separator}${format.quoteStart}`)}${format.quoteEnd}`;
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 type Translator = (messageTmpl: string | readonly string[], ...keywords: readonly Primitive[]) => string;
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": "正の整数",
@@ -117,6 +122,8 @@
117
122
  "regular expression": "正規表現",
118
123
  "role": "ロール",
119
124
  "roles": "ロール",
125
+ "row": "行",
126
+ "rows": "行",
120
127
  "second": "秒",
121
128
  "semantics": "セマンティクス",
122
129
  "serialized-origin": "シリアル化されたオリジン",
@@ -162,6 +169,7 @@
162
169
  "{0:c} on {1}": "{1}では、{0:c}",
163
170
  "{0} ({1})": "{0}({1})",
164
171
  "{0} according to {1}": "{1}において、{0}",
172
+ "{0} are causing {1}": "{0}が{1}を引き起こしています",
165
173
  "{0} as {1}": "{1}として{0}",
166
174
  "{0} associates only {1}": "{0}は{1}だけを関連付けます",
167
175
  "{0} behaves the same as {1} if {2}": "{0}は{2}の場合、{1}と同じ振る舞いをします",
@@ -173,6 +181,7 @@
173
181
  "{0} does not exist": "{0}は存在しません",
174
182
  "{0} expects {1:c}": "{0}は{1}である必要があります",
175
183
  "{0} expects {1}": "{0}には{1}が必要です",
184
+ "{0} extra {1} in {2}": "{2}に{0}つの余分な{1}があります",
176
185
  "{0} greater than {1} less than {2}": "{1}より大きく{2}より小さい{0}",
177
186
  "{0} greater than {1} less than or equal to {2}": "{1}より大きく{2}以下の{0}",
178
187
  "{0} greater than {1}": "{1}より大きい{0}",
@@ -186,6 +195,7 @@
186
195
  "{0} is {1:c}": "{0}{1:c}",
187
196
  "{0} is {1} but {2}": "{0}は{1}ですが、{2}",
188
197
  "{0} is {1}": "{0}は{1}です",
198
+ "{0} is causing {1}": "{0}が{1}を引き起こしています",
189
199
  "{0} is disallowed": "{0}は禁止されています",
190
200
  "{0} is disallowed to accept the following values: {1}": "{0}は次の値を受け取ることを禁止しています: {1}",
191
201
  "{0} is matched with the below disallowed patterns: {1}": "{0}は次の許可しないパターンにマッチしました {1}",
@@ -196,6 +206,7 @@
196
206
  "{0} is unmatched with the below patterns: {1}": "{0}は次のパターンにマッチしませんでした {1}",
197
207
  "{0} less than {1}": "{1}より小さい{0}",
198
208
  "{0} less than or equal to {1}": "{1}以下の{0}",
209
+ "{0} missing {1} in {2}": "{2}に{0}つの{1}がありません",
199
210
  "{0} must {1}": "{0}は{1}するべきです",
200
211
  "{0} must be {1}": "{0}は{1}にするべきです",
201
212
  "{0} must not {1}": "{0}は{1}するべきではありません",
@@ -223,6 +234,7 @@
223
234
  "add {0}": "{0}を追加してください",
224
235
  "allowed values are: {0}": "許可されている値は次のとおりです {0}",
225
236
  "also disallows {0} in this context": "このコンテキスト内では{0}も許可しません",
237
+ "ambiguous {0}": "曖昧な{0}",
226
238
  "an {0}": "{0}",
227
239
  "as its {0} is already provided by {1}": "その{0}は{1}によってすでに提供されています",
228
240
  "cannot overwrite {0} to {1}": "{0}を{1}に上書きすることはできません",
@@ -231,7 +243,9 @@
231
243
  "corresponding {0}": "対応する{0}",
232
244
  "detected {0} between {1} and {2}": "{1}と{2}の間で{0}が検出されました",
233
245
  "did you mean \"{0}\"?": "「{0}」ではありませんか?",
246
+ "don't use {0}": "{0}を使用しないでください",
234
247
  "either {0}": "{0}のいずれか",
248
+ "exceeds the number of available {0}": "利用可能な{0}数を超えています",
235
249
  "extra {0}": "余計な{0}",
236
250
  "first {0}": "最初の{0}",
237
251
  "found {0}": "{0}が発見されました",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/i18n",
3
- "version": "4.4.0",
3
+ "version": "4.5.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": "d5c8786b0dbbd82cdd89018dd57941d62bbe8d06"
40
+ "gitHead": "7a5967fce14fdf66f0d8eae9d93ae5b350648d3d"
41
41
  }