@markuplint/i18n 3.5.0 → 3.7.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 +3 -0
- package/lib/translator.d.ts +3 -1
- package/lib/translator.js +3 -3
- package/lib/types.d.ts +8 -8
- package/locales/ja.json +3 -0
- package/package.json +2 -2
package/$schema.json
CHANGED
|
@@ -144,6 +144,7 @@
|
|
|
144
144
|
"time": { "type": "string" },
|
|
145
145
|
"token": { "type": "string" },
|
|
146
146
|
"top level": { "type": "string" },
|
|
147
|
+
"type": { "type": "string" },
|
|
147
148
|
"transparent model": { "type": "string" },
|
|
148
149
|
"unit": { "type": "string" },
|
|
149
150
|
"uppercase": { "type": "string" },
|
|
@@ -191,6 +192,8 @@
|
|
|
191
192
|
"{0} is {1}": { "type": "string" },
|
|
192
193
|
"{0} is {1} but {2}": { "type": "string" },
|
|
193
194
|
"{0} is disallowed": { "type": "string" },
|
|
195
|
+
"{0} is disallowed to accept the following values: {1}": { "type": "string" },
|
|
196
|
+
"{0} is matched with the below disallowed patterns: {1}": { "type": "string" },
|
|
194
197
|
"{0} is not {1}": { "type": "string" },
|
|
195
198
|
"{0} is not allowed in {1} in this context": { "type": "string" },
|
|
196
199
|
"{0} is not allowed in {1} through the transparent model in this context": { "type": "string" },
|
package/lib/translator.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export declare function translator(localeSet?: LocaleSet): Translator;
|
|
|
3
3
|
/**
|
|
4
4
|
* @experimental
|
|
5
5
|
*/
|
|
6
|
-
export declare function taggedTemplateTranslator(
|
|
6
|
+
export declare function taggedTemplateTranslator(
|
|
7
|
+
localeSet?: LocaleSet,
|
|
8
|
+
): (strings: Readonly<TemplateStringsArray>, ...keys: readonly Primitive[]) => string;
|
package/lib/translator.js
CHANGED
|
@@ -8,10 +8,10 @@ const defaultListFormat = {
|
|
|
8
8
|
};
|
|
9
9
|
function translator(localeSet) {
|
|
10
10
|
return (messageTmpl, ...keywords) => {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
12
12
|
let message = messageTmpl;
|
|
13
13
|
if (typeof messageTmpl !== 'string') {
|
|
14
|
-
const format = (localeSet === null || localeSet === void 0 ? void 0 : localeSet.listFormat)
|
|
14
|
+
const format = (_a = localeSet === null || localeSet === void 0 ? void 0 : localeSet.listFormat) !== null && _a !== void 0 ? _a : defaultListFormat;
|
|
15
15
|
return `${format.quoteStart}${messageTmpl
|
|
16
16
|
.map(keyword => translateKeyword(keyword, '', localeSet))
|
|
17
17
|
.join(`${format.quoteEnd}${format.separator}${format.quoteStart}`)}${format.quoteEnd}`;
|
|
@@ -22,7 +22,7 @@ function translator(localeSet) {
|
|
|
22
22
|
}
|
|
23
23
|
const noTranslateIndex = Array.from(messageTmpl.matchAll(/(?<=\{)[0-9]+(?=\*\})/g)).map(m => m[0]);
|
|
24
24
|
const key = removeNoTranslateMark(messageTmpl).toLowerCase();
|
|
25
|
-
const sentence = (
|
|
25
|
+
const sentence = (_b = localeSet === null || localeSet === void 0 ? void 0 : localeSet.sentences) === null || _b === void 0 ? void 0 : _b[key];
|
|
26
26
|
messageTmpl = sentence !== null && sentence !== void 0 ? sentence : key;
|
|
27
27
|
messageTmpl =
|
|
28
28
|
removeNoTranslateMark(input.toLowerCase()) === messageTmpl ? removeNoTranslateMark(input) : messageTmpl;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export type Translator = (messageTmpl: string | readonly string[], ...keywords: readonly Primitive[]) => string;
|
|
2
2
|
export type LocaleSet = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
readonly locale: string;
|
|
4
|
+
readonly listFormat?: ListFormat;
|
|
5
|
+
readonly keywords?: LocalesKeywords;
|
|
6
|
+
readonly sentences?: LocalesKeywords;
|
|
7
7
|
};
|
|
8
8
|
export type ListFormat = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
readonly quoteStart: string;
|
|
10
|
+
readonly quoteEnd: string;
|
|
11
|
+
readonly separator: string;
|
|
12
12
|
};
|
|
13
13
|
export type Primitive = string | number | boolean;
|
|
14
14
|
export type LocalesKeywords = {
|
|
15
|
-
|
|
15
|
+
readonly [messageId: string]: string;
|
|
16
16
|
};
|
package/locales/ja.json
CHANGED
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
"time": "時間",
|
|
133
133
|
"token": "トークン",
|
|
134
134
|
"top level": "トップレベル",
|
|
135
|
+
"type": "型",
|
|
135
136
|
"transparent model": "トランスペアレントモデル",
|
|
136
137
|
"unit": "単位",
|
|
137
138
|
"uppercase": "大文字",
|
|
@@ -175,6 +176,8 @@
|
|
|
175
176
|
"{0} is {1} but {2}": "{0}は{1}ですが、{2}",
|
|
176
177
|
"{0} is {1}": "{0}は{1}です",
|
|
177
178
|
"{0} is disallowed": "{0}は禁止されています",
|
|
179
|
+
"{0} is disallowed to accept the following values: {1}": "{0}は次の値を受け取ることを禁止しています: {1}",
|
|
180
|
+
"{0} is matched with the below disallowed patterns: {1}": "{0}は次の許可しないパターンにマッチしました {1}",
|
|
178
181
|
"{0} is not {1}": "{0}は{1}ではありません",
|
|
179
182
|
"{0} is not allowed in {1} in this context": "このコンテキストでは、{1}に{0}を含めることはできません",
|
|
180
183
|
"{0} is not allowed in {1} through the transparent model in this context": "このコンテキストでは、トランスペアレントモデルを介して{1}に{0}を含めることはできません",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/i18n",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "HTML parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"build": "tsc",
|
|
19
19
|
"clean": "tsc --build --clean"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "884e8dbf60ec2a350761d5cda3cdc0725881b9dc"
|
|
22
22
|
}
|