auto-translate-json-library 1.2.0 → 1.2.1
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/README.MD +124 -0
- package/aws.d.ts +1 -1
- package/aws.js +80 -80
- package/azure.d.ts +1 -1
- package/azure.js +118 -118
- package/config.d.ts +10 -9
- package/deepl.d.ts +2 -2
- package/deepl.js +40 -40
- package/files.d.ts +7 -6
- package/files.js +10 -10
- package/folderFiles.d.ts +4 -3
- package/folderFiles.js +2 -2
- package/google.d.ts +1 -1
- package/google.js +114 -114
- package/index.d.ts +2 -2
- package/index.js +41 -33
- package/lib.d.ts +1 -1
- package/lib.js +35 -31
- package/openai.js +113 -113
- package/package.json +14 -2
- package/translate.interface.d.ts +3 -0
- package/util.js +7 -7
package/lib.js
CHANGED
|
@@ -20,39 +20,38 @@ const google_1 = require("./google");
|
|
|
20
20
|
const util_1 = require("./util");
|
|
21
21
|
const deepl_1 = require("./deepl");
|
|
22
22
|
const openai_1 = require("./openai");
|
|
23
|
-
const NAME = 'AutoTranslateJSON';
|
|
24
23
|
function translate(sourceFile, config) {
|
|
25
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
25
|
// set the delimiters for named arguments
|
|
27
|
-
const startDelimiter = config.startDelimiter ||
|
|
26
|
+
const startDelimiter = config.startDelimiter || "{";
|
|
28
27
|
if (startDelimiter) {
|
|
29
28
|
util_1.Util.startDelimiter = startDelimiter;
|
|
30
29
|
}
|
|
31
|
-
const endDelimiter = config.endDelimiter ||
|
|
30
|
+
const endDelimiter = config.endDelimiter || "}";
|
|
32
31
|
if (endDelimiter) {
|
|
33
32
|
util_1.Util.endDelimiter = endDelimiter;
|
|
34
33
|
}
|
|
35
34
|
let translateEngine;
|
|
36
|
-
if (config.translationKeyInfo.kind ===
|
|
35
|
+
if (config.translationKeyInfo.kind === "google") {
|
|
37
36
|
translateEngine = new google_1.GoogleTranslate(config.translationKeyInfo.apiKey);
|
|
38
37
|
}
|
|
39
|
-
else if (config.translationKeyInfo.kind ===
|
|
38
|
+
else if (config.translationKeyInfo.kind === "aws") {
|
|
40
39
|
translateEngine = new aws_1.AWSTranslate(config.translationKeyInfo.accessKeyId, config.translationKeyInfo.secretAccessKey, config.translationKeyInfo.region);
|
|
41
40
|
}
|
|
42
|
-
else if (config.translationKeyInfo.kind ===
|
|
41
|
+
else if (config.translationKeyInfo.kind === "azure") {
|
|
43
42
|
translateEngine = new azure_1.AzureTranslate(config.translationKeyInfo.secretKey, config.translationKeyInfo.region);
|
|
44
43
|
}
|
|
45
|
-
else if (config.translationKeyInfo.kind ===
|
|
46
|
-
translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey,
|
|
44
|
+
else if (config.translationKeyInfo.kind === "deepLFree") {
|
|
45
|
+
translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey, "free");
|
|
47
46
|
}
|
|
48
|
-
else if (config.translationKeyInfo.kind ===
|
|
49
|
-
translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey,
|
|
47
|
+
else if (config.translationKeyInfo.kind === "deepLPro") {
|
|
48
|
+
translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey, "pro");
|
|
50
49
|
}
|
|
51
|
-
else if (config.translationKeyInfo.kind ===
|
|
50
|
+
else if (config.translationKeyInfo.kind === "openai") {
|
|
52
51
|
translateEngine = new openai_1.OpenAITranslate(config.translationKeyInfo.apiKey);
|
|
53
52
|
}
|
|
54
53
|
else {
|
|
55
|
-
console.warn(
|
|
54
|
+
console.warn("You must provide a Google, AWS, Azure, deepL, openai parameters first in the extension settings.");
|
|
56
55
|
return;
|
|
57
56
|
}
|
|
58
57
|
const fileMode = config.mode;
|
|
@@ -62,13 +61,11 @@ function translate(sourceFile, config) {
|
|
|
62
61
|
}
|
|
63
62
|
// enforce source locale if provided in settings
|
|
64
63
|
if (config.sourceLocale !== files.sourceLocale) {
|
|
65
|
-
console.log(
|
|
66
|
-
config.sourceLocale +
|
|
67
|
-
'.json file due to your Source Locale setting.');
|
|
64
|
+
console.log(`You must use the ${config.sourceLocale}.json file due to your Source Locale setting.`);
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
|
-
const keepTranslations = config.keepTranslations ===
|
|
71
|
-
const keepExtras = config.keepExtraTranslations ===
|
|
67
|
+
const keepTranslations = config.keepTranslations === "keep";
|
|
68
|
+
const keepExtras = config.keepExtraTranslations === "keep";
|
|
72
69
|
// load source JSON
|
|
73
70
|
let source;
|
|
74
71
|
try {
|
|
@@ -76,7 +73,7 @@ function translate(sourceFile, config) {
|
|
|
76
73
|
}
|
|
77
74
|
catch (error) {
|
|
78
75
|
if (error instanceof Error) {
|
|
79
|
-
console.log(error,
|
|
76
|
+
console.log(error, "Source file malformed");
|
|
80
77
|
}
|
|
81
78
|
return;
|
|
82
79
|
}
|
|
@@ -85,14 +82,14 @@ function translate(sourceFile, config) {
|
|
|
85
82
|
try {
|
|
86
83
|
const isValid = yield translateEngine.isValidLocale(targetLocale);
|
|
87
84
|
if (!isValid) {
|
|
88
|
-
throw Error(targetLocale
|
|
85
|
+
throw Error(`${targetLocale} is not supported. Skipping.`);
|
|
89
86
|
}
|
|
90
87
|
const targetOriginal = yield files.loadJsonFromLocale(targetLocale);
|
|
91
88
|
// Iterate source terms
|
|
92
|
-
const targetNew = yield recurseNode(source, targetOriginal, keepTranslations, keepExtras, files.sourceLocale, targetLocale, translateEngine);
|
|
89
|
+
const targetNew = yield recurseNode(source, targetOriginal, keepTranslations, keepExtras, files.sourceLocale, targetLocale, translateEngine, config.ignorePrefix);
|
|
93
90
|
// save target
|
|
94
91
|
files.saveJsonToLocale(targetLocale, targetNew);
|
|
95
|
-
const feedback =
|
|
92
|
+
const feedback = `Translated locale '${targetLocale}'`;
|
|
96
93
|
console.log(feedback);
|
|
97
94
|
}
|
|
98
95
|
catch (error) {
|
|
@@ -107,10 +104,10 @@ function translate(sourceFile, config) {
|
|
|
107
104
|
exports.translate = translate;
|
|
108
105
|
const readFiles = (filePath, mode) => {
|
|
109
106
|
try {
|
|
110
|
-
const files = mode ===
|
|
107
|
+
const files = mode === "file" ? new files_1.Files(filePath) : new folderFiles_1.FolderFiles(filePath);
|
|
111
108
|
// log locale info
|
|
112
|
-
console.log(
|
|
113
|
-
console.log(
|
|
109
|
+
console.log(`Source locale = ${files.sourceLocale}`);
|
|
110
|
+
console.log(`Target locales = ${files.targetLocales}`);
|
|
114
111
|
return files;
|
|
115
112
|
}
|
|
116
113
|
catch (error) {
|
|
@@ -120,9 +117,10 @@ const readFiles = (filePath, mode) => {
|
|
|
120
117
|
return null;
|
|
121
118
|
}
|
|
122
119
|
};
|
|
123
|
-
function recurseNode(source, original, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, isArray = false) {
|
|
120
|
+
function recurseNode(source, original, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, ignorePrefix = "", isArray = false) {
|
|
124
121
|
var _a;
|
|
125
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
// rome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
126
124
|
const destination = isArray ? [] : {};
|
|
127
125
|
// defaults
|
|
128
126
|
if (keepTranslations === null) {
|
|
@@ -134,22 +132,28 @@ function recurseNode(source, original, keepTranslations, keepExtras, sourceLocal
|
|
|
134
132
|
for (const term in source) {
|
|
135
133
|
const node = source[term];
|
|
136
134
|
if (node instanceof Object && node !== null) {
|
|
137
|
-
destination[term] = yield recurseNode(node, (_a = original[term]) !== null && _a !== void 0 ? _a : {}, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, node instanceof Array);
|
|
135
|
+
destination[term] = yield recurseNode(node, (_a = original[term]) !== null && _a !== void 0 ? _a : {}, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, ignorePrefix, node instanceof Array);
|
|
138
136
|
}
|
|
139
137
|
else {
|
|
140
138
|
// if we already have a translation, keep it
|
|
141
139
|
if (keepTranslations && original[term]) {
|
|
142
140
|
destination[term] = original[term];
|
|
143
141
|
}
|
|
144
|
-
else if (typeof node ===
|
|
142
|
+
else if (typeof node === "number" || typeof node === "boolean") {
|
|
145
143
|
// numbers and booleans do not need translations
|
|
146
144
|
destination[term] = node;
|
|
147
145
|
}
|
|
148
146
|
else {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
if (ignorePrefix === "" ||
|
|
148
|
+
(ignorePrefix !== "" && !term.startsWith(ignorePrefix))) {
|
|
149
|
+
const translation = yield translateEngine
|
|
150
|
+
.translateText(node, sourceLocale, locale)
|
|
151
|
+
.catch((err) => console.error(err));
|
|
152
|
+
destination[term] = translation;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
delete destination[term];
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
}
|
package/openai.js
CHANGED
|
@@ -13,119 +13,119 @@ exports.OpenAITranslate = void 0;
|
|
|
13
13
|
const util_1 = require("./util");
|
|
14
14
|
const openai_1 = require("openai");
|
|
15
15
|
const supportedLanguages = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
16
|
+
af: "Afrikaans",
|
|
17
|
+
sq: "Albanian",
|
|
18
|
+
am: "Amharic",
|
|
19
|
+
ar: "Arabic",
|
|
20
|
+
hy: "Armenian",
|
|
21
|
+
az: "Azerbaijani",
|
|
22
|
+
eu: "Basque",
|
|
23
|
+
be: "Belarusian",
|
|
24
|
+
bn: "Bengali",
|
|
25
|
+
bs: "Bosnian",
|
|
26
|
+
bg: "Bulgarian",
|
|
27
|
+
ca: "Catalan",
|
|
28
|
+
ceb: "Cebuano",
|
|
29
|
+
"zh-CN": "Chinese (Simplified)",
|
|
30
|
+
"zh-TW": "Chinese (Traditional)",
|
|
31
|
+
co: "Corsican",
|
|
32
|
+
hr: "Croatian",
|
|
33
|
+
cs: "Czech",
|
|
34
|
+
da: "Danish",
|
|
35
|
+
nl: "Dutch",
|
|
36
|
+
en: "English",
|
|
37
|
+
eo: "Esperanto",
|
|
38
|
+
et: "Estonian",
|
|
39
|
+
fi: "Finnish",
|
|
40
|
+
fr: "French",
|
|
41
|
+
fy: "Frisian",
|
|
42
|
+
gl: "Galician",
|
|
43
|
+
ka: "Georgian",
|
|
44
|
+
de: "German",
|
|
45
|
+
el: "Greek",
|
|
46
|
+
gu: "Gujarati",
|
|
47
|
+
ht: "Haitian Creole",
|
|
48
|
+
ha: "Hausa",
|
|
49
|
+
haw: "Hawaiian",
|
|
50
|
+
he: "Hebrew",
|
|
51
|
+
hi: "Hindi",
|
|
52
|
+
hmn: "Hmong",
|
|
53
|
+
hu: "Hungarian",
|
|
54
|
+
is: "Icelandic",
|
|
55
|
+
ig: "Igbo",
|
|
56
|
+
id: "Indonesian",
|
|
57
|
+
ga: "Irish",
|
|
58
|
+
it: "Italian",
|
|
59
|
+
ja: "Japanese",
|
|
60
|
+
jv: "Javanese",
|
|
61
|
+
kn: "Kannada",
|
|
62
|
+
kk: "Kazakh",
|
|
63
|
+
km: "Khmer",
|
|
64
|
+
ko: "Korean",
|
|
65
|
+
ku: "Kurdish",
|
|
66
|
+
ky: "Kyrgyz",
|
|
67
|
+
lo: "Lao",
|
|
68
|
+
la: "Latin",
|
|
69
|
+
lv: "Latvian",
|
|
70
|
+
lt: "Lithuanian",
|
|
71
|
+
lb: "Luxembourgish",
|
|
72
|
+
mk: "Macedonian",
|
|
73
|
+
mg: "Malagasy",
|
|
74
|
+
ms: "Malay",
|
|
75
|
+
ml: "Malayalam",
|
|
76
|
+
mt: "Maltese",
|
|
77
|
+
mi: "Maori",
|
|
78
|
+
mr: "Marathi",
|
|
79
|
+
mn: "Mongolian",
|
|
80
|
+
my: "Myanmar (Burmese)",
|
|
81
|
+
ne: "Nepali",
|
|
82
|
+
no: "Norwegian",
|
|
83
|
+
ny: "Nyanja (Chichewa)",
|
|
84
|
+
or: "Odia (Oriya)",
|
|
85
|
+
ps: "Pashto",
|
|
86
|
+
fa: "Persian",
|
|
87
|
+
pl: "Polish",
|
|
88
|
+
pt: "Portuguese",
|
|
89
|
+
pa: "Punjabi",
|
|
90
|
+
ro: "Romanian",
|
|
91
|
+
ru: "Russian",
|
|
92
|
+
sm: "Samoan",
|
|
93
|
+
gd: "Scots Gaelic",
|
|
94
|
+
sr: "Serbian",
|
|
95
|
+
st: "Sesotho",
|
|
96
|
+
sn: "Shona",
|
|
97
|
+
sd: "Sindhi",
|
|
98
|
+
si: "Sinhala (Sinhalese)",
|
|
99
|
+
sk: "Slovak",
|
|
100
|
+
sl: "Slovenian",
|
|
101
|
+
so: "Somali",
|
|
102
|
+
es: "Spanish",
|
|
103
|
+
su: "Sundanese",
|
|
104
|
+
sw: "Swahili",
|
|
105
|
+
sv: "Swedish",
|
|
106
|
+
tl: "Tagalog (Filipino)",
|
|
107
|
+
tg: "Tajik",
|
|
108
|
+
ta: "Tamil",
|
|
109
|
+
tt: "Tatar",
|
|
110
|
+
te: "Telugu",
|
|
111
|
+
th: "Thai",
|
|
112
|
+
tr: "Turkish",
|
|
113
|
+
tk: "Turkmen",
|
|
114
|
+
uk: "Ukrainian",
|
|
115
|
+
ur: "Urdu",
|
|
116
|
+
ug: "Uyghur",
|
|
117
|
+
uz: "Uzbek",
|
|
118
|
+
vi: "Vietnamese",
|
|
119
|
+
cy: "Welsh",
|
|
120
|
+
xh: "Xhosa",
|
|
121
|
+
yi: "Yiddish",
|
|
122
|
+
yo: "Yoruba",
|
|
123
|
+
zu: "Zulu",
|
|
124
124
|
};
|
|
125
125
|
class OpenAITranslate {
|
|
126
126
|
constructor(apiKey) {
|
|
127
127
|
this.apiKey = apiKey;
|
|
128
|
-
this.endpoint =
|
|
128
|
+
this.endpoint = "https://api.cognitive.microsofttranslator.com";
|
|
129
129
|
const configuration = new openai_1.Configuration({
|
|
130
130
|
apiKey: apiKey,
|
|
131
131
|
});
|
|
@@ -136,10 +136,10 @@ class OpenAITranslate {
|
|
|
136
136
|
}
|
|
137
137
|
translateText(text, sourceLocale, targetLocale) {
|
|
138
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
if (sourceLocale !==
|
|
140
|
-
throw Error(sourceLocale
|
|
139
|
+
if (sourceLocale !== "en") {
|
|
140
|
+
throw Error(`${sourceLocale} is not supported.Currently we support just English `);
|
|
141
141
|
}
|
|
142
|
-
let result =
|
|
142
|
+
let result = "";
|
|
143
143
|
let args;
|
|
144
144
|
({ args, text } = util_1.Util.replaceContextVariables(text));
|
|
145
145
|
const prompt = `Translate this into ${supportedLanguages[targetLocale]}:\n${text}\n.`;
|
|
@@ -154,7 +154,7 @@ class OpenAITranslate {
|
|
|
154
154
|
});
|
|
155
155
|
if (response.data.choices[0].text !== undefined) {
|
|
156
156
|
result = util_1.Util.replaceArgumentsWithNumbers(args, response.data.choices[0].text);
|
|
157
|
-
result = result.replace(/^\n+|\n+$/g,
|
|
157
|
+
result = result.replace(/^\n+|\n+$/g, "");
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
160
160
|
console.error(`can not translate text with prompt :${prompt}`);
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auto-translate-json-library",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Automatically translates JSON language files to other languages using Google Translate,AWS,Azure,DeepL or OpenAI",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"prepare": "tsc",
|
|
9
9
|
"build": "tsc",
|
|
10
|
+
"lint": "rome check ./src",
|
|
11
|
+
"lint-fix": "rome check ./src --apply",
|
|
12
|
+
"lint-fix-all": "rome check --apply-unsafe ./src",
|
|
13
|
+
"format": "rome format ./src",
|
|
14
|
+
"format-fix": "rome format ./src --write",
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"test:coverage": "jest --coverage",
|
|
17
|
+
"test:watch": "jest --watch",
|
|
10
18
|
"start": "ts-node src/index.ts"
|
|
11
19
|
},
|
|
12
20
|
"keywords": [
|
|
@@ -39,11 +47,15 @@
|
|
|
39
47
|
}
|
|
40
48
|
},
|
|
41
49
|
"devDependencies": {
|
|
42
|
-
"@types/
|
|
50
|
+
"@types/jest": "29.5.1",
|
|
51
|
+
"@types/node": "20.2.0",
|
|
43
52
|
"@types/yargs": "17.0.24",
|
|
44
53
|
"husky": "8.0.3",
|
|
54
|
+
"jest": "^29.5.0",
|
|
45
55
|
"prettier": "2.8.8",
|
|
46
56
|
"pretty-quick": "3.1.3",
|
|
57
|
+
"rome": "^12.1.1",
|
|
58
|
+
"ts-jest": "^29.1.0",
|
|
47
59
|
"ts-node": "10.9.1",
|
|
48
60
|
"typescript": "5.0.4"
|
|
49
61
|
},
|
package/translate.interface.d.ts
CHANGED
package/util.js
CHANGED
|
@@ -5,17 +5,17 @@ class Util {
|
|
|
5
5
|
static set startDelimiter(value) {
|
|
6
6
|
Util._startDelimiter = value;
|
|
7
7
|
// update regex
|
|
8
|
-
Util.pattern = new RegExp(Util._startDelimiter
|
|
8
|
+
Util.pattern = new RegExp(`${Util._startDelimiter}(.*?)${Util._endDelimiter}`, "g");
|
|
9
9
|
}
|
|
10
10
|
static set endDelimiter(value) {
|
|
11
11
|
Util._endDelimiter = value;
|
|
12
12
|
// update regex
|
|
13
|
-
Util.pattern = new RegExp(Util._startDelimiter
|
|
13
|
+
Util.pattern = new RegExp(`${Util._startDelimiter}(.*?)${Util._endDelimiter}`, "g");
|
|
14
14
|
}
|
|
15
15
|
static replaceArgumentsWithNumbers(args, result) {
|
|
16
16
|
if (args) {
|
|
17
17
|
let i = 0;
|
|
18
|
-
for (
|
|
18
|
+
for (const arg of args) {
|
|
19
19
|
result = result.replace(Util._startDelimiter + i + Util._endDelimiter, arg);
|
|
20
20
|
i++;
|
|
21
21
|
}
|
|
@@ -27,7 +27,7 @@ class Util {
|
|
|
27
27
|
// replace arguments with numbers
|
|
28
28
|
if (args) {
|
|
29
29
|
let i = 0;
|
|
30
|
-
for (
|
|
30
|
+
for (const arg of args) {
|
|
31
31
|
text = text.replace(arg, Util._startDelimiter + i + Util._endDelimiter);
|
|
32
32
|
i++;
|
|
33
33
|
}
|
|
@@ -35,7 +35,7 @@ class Util {
|
|
|
35
35
|
return { args, text };
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
Util._startDelimiter =
|
|
39
|
-
Util._endDelimiter =
|
|
40
|
-
Util.pattern = new RegExp(Util._startDelimiter
|
|
38
|
+
Util._startDelimiter = "{";
|
|
39
|
+
Util._endDelimiter = "}";
|
|
40
|
+
Util.pattern = new RegExp(`${Util._startDelimiter}(.*?)${Util._endDelimiter}`, "g");
|
|
41
41
|
exports.Util = Util;
|