@esgettext/tools 1.1.0 → 1.2.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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/command.js +0 -1
- package/dist/commands/convert.js +16 -14
- package/dist/commands/install.js +12 -4
- package/dist/commands/msgfmt-all.js +65 -46
- package/dist/commands/msgmerge-all.js +64 -46
- package/dist/commands/xgettext/file-resolver.js +0 -1
- package/dist/commands/xgettext/files-collector.js +1 -1
- package/dist/commands/xgettext.js +16 -7
- package/dist/configuration.js +172 -156
- package/dist/esgettext-package-json.js +0 -1
- package/dist/index.js +75 -24
- package/dist/package.js +1 -2
- package/dist/parser/javascript.js +2 -1
- package/dist/parser/parser.js +17 -2
- package/dist/parser/po.js +34 -1
- package/dist/parser/typescript.js +2 -1
- package/dist/pot/catalog.js +36 -1
- package/dist/pot/entry.js +71 -1
- package/dist/pot/keyword.js +10 -5
- package/package.json +5 -4
- package/dist/command.d.ts +0 -11
- package/dist/command.js.map +0 -1
- package/dist/commands/convert.d.ts +0 -24
- package/dist/commands/convert.js.map +0 -1
- package/dist/commands/install.d.ts +0 -22
- package/dist/commands/install.js.map +0 -1
- package/dist/commands/msgfmt-all.d.ts +0 -20
- package/dist/commands/msgfmt-all.js.map +0 -1
- package/dist/commands/msgmerge-all.d.ts +0 -21
- package/dist/commands/msgmerge-all.js.map +0 -1
- package/dist/commands/xgettext/file-resolver.d.ts +0 -5
- package/dist/commands/xgettext/file-resolver.js.map +0 -1
- package/dist/commands/xgettext/file-resolver.spec.d.ts +0 -1
- package/dist/commands/xgettext/file-resolver.spec.js +0 -22
- package/dist/commands/xgettext/file-resolver.spec.js.map +0 -1
- package/dist/commands/xgettext/files-collector.d.ts +0 -5
- package/dist/commands/xgettext/files-collector.js.map +0 -1
- package/dist/commands/xgettext/files-collector.spec.d.ts +0 -1
- package/dist/commands/xgettext/files-collector.spec.js +0 -96
- package/dist/commands/xgettext/files-collector.spec.js.map +0 -1
- package/dist/commands/xgettext.d.ts +0 -29
- package/dist/commands/xgettext.js.map +0 -1
- package/dist/commands/xgettext.spec.d.ts +0 -1
- package/dist/commands/xgettext.spec.js +0 -897
- package/dist/commands/xgettext.spec.js.map +0 -1
- package/dist/configuration.d.ts +0 -36
- package/dist/configuration.js.map +0 -1
- package/dist/esgettext-package-json.d.ts +0 -15
- package/dist/esgettext-package-json.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/package.d.ts +0 -5
- package/dist/package.js.map +0 -1
- package/dist/parser/javascript.d.ts +0 -4
- package/dist/parser/javascript.js.map +0 -1
- package/dist/parser/javascript.spec.d.ts +0 -1
- package/dist/parser/javascript.spec.js +0 -535
- package/dist/parser/javascript.spec.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -45
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/po.d.ts +0 -22
- package/dist/parser/po.js.map +0 -1
- package/dist/parser/po.spec.d.ts +0 -1
- package/dist/parser/po.spec.js +0 -486
- package/dist/parser/po.spec.js.map +0 -1
- package/dist/parser/typescript.d.ts +0 -4
- package/dist/parser/typescript.js.map +0 -1
- package/dist/parser/typescript.spec.d.ts +0 -1
- package/dist/parser/typescript.spec.js +0 -121
- package/dist/parser/typescript.spec.js.map +0 -1
- package/dist/pot/catalog.d.ts +0 -26
- package/dist/pot/catalog.js.map +0 -1
- package/dist/pot/catalog.spec.d.ts +0 -1
- package/dist/pot/catalog.spec.js +0 -244
- package/dist/pot/catalog.spec.js.map +0 -1
- package/dist/pot/entry.d.ts +0 -35
- package/dist/pot/entry.js.map +0 -1
- package/dist/pot/entry.spec.d.ts +0 -1
- package/dist/pot/entry.spec.js +0 -433
- package/dist/pot/entry.spec.js.map +0 -1
- package/dist/pot/keyword.d.ts +0 -17
- package/dist/pot/keyword.js.map +0 -1
- package/dist/pot/keyword.spec.d.ts +0 -1
- package/dist/pot/keyword.spec.js +0 -54
- package/dist/pot/keyword.spec.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -294,7 +294,7 @@ for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
|
294
294
|
|
|
295
295
|
## Copyright
|
|
296
296
|
|
|
297
|
-
Copyright (C) 2020 Guido Flohr <guido.flohr@cantanea.com>, all
|
|
297
|
+
Copyright (C) 2020-2024 Guido Flohr <guido.flohr@cantanea.com>, all
|
|
298
298
|
rights reserved.
|
|
299
299
|
|
|
300
300
|
This software is available under the terms and conditions of the
|
package/dist/command.js
CHANGED
package/dist/commands/convert.js
CHANGED
|
@@ -29,8 +29,9 @@ const runtime_1 = require("@esgettext/runtime");
|
|
|
29
29
|
const package_1 = require("../package");
|
|
30
30
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
31
31
|
class Convert {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
constructor(_) {
|
|
34
|
+
this.options = undefined;
|
|
34
35
|
}
|
|
35
36
|
synopsis() {
|
|
36
37
|
return `[${gtx._('INPUTFILE')}] [${gtx._('OUTPUTFILE')}]`;
|
|
@@ -195,6 +196,7 @@ class Convert {
|
|
|
195
196
|
if (typeof filename !== 'undefined') {
|
|
196
197
|
return fs.readFileSync(filename);
|
|
197
198
|
}
|
|
199
|
+
// Must read from standard input.
|
|
198
200
|
const stdinFd = 0;
|
|
199
201
|
const chunks = [];
|
|
200
202
|
let bytesRead;
|
|
@@ -238,16 +240,16 @@ class Convert {
|
|
|
238
240
|
}
|
|
239
241
|
shortenAndEscapeString(input, maxLength) {
|
|
240
242
|
const controlCharMap = {
|
|
241
|
-
'\0': '\\0',
|
|
242
|
-
'\b': '\\b',
|
|
243
|
-
'\t': '\\t',
|
|
244
|
-
'\n': '\\n',
|
|
245
|
-
'\v': '\\v',
|
|
246
|
-
'\f': '\\f',
|
|
247
|
-
'\r': '\\r',
|
|
248
|
-
'"': '\\"',
|
|
249
|
-
"'": "\\'",
|
|
250
|
-
'\\': '\\\\',
|
|
243
|
+
'\0': '\\0', // Null character
|
|
244
|
+
'\b': '\\b', // Backspace
|
|
245
|
+
'\t': '\\t', // Horizontal Tab
|
|
246
|
+
'\n': '\\n', // New Line
|
|
247
|
+
'\v': '\\v', // Vertical Tab
|
|
248
|
+
'\f': '\\f', // Form Feed
|
|
249
|
+
'\r': '\\r', // Carriage Return
|
|
250
|
+
'"': '\\"', // Double quote
|
|
251
|
+
"'": "\\'", // Single quote
|
|
252
|
+
'\\': '\\\\', // Backslash
|
|
251
253
|
};
|
|
252
254
|
const escapeControlChar = (char) => {
|
|
253
255
|
if (controlCharMap[char]) {
|
|
@@ -257,8 +259,9 @@ class Convert {
|
|
|
257
259
|
if (code < 32) {
|
|
258
260
|
return `\\x${code.toString(16).padStart(2, '0')}`;
|
|
259
261
|
}
|
|
260
|
-
return char;
|
|
262
|
+
return char; // This line is technically redundant with the current regex.
|
|
261
263
|
};
|
|
264
|
+
// Escape all control characters
|
|
262
265
|
const escapedInput = input.replace(/[\x00-\x1F"'\\]/g, escapeControlChar);
|
|
263
266
|
let truncatedString = escapedInput;
|
|
264
267
|
if (escapedInput.length > maxLength) {
|
|
@@ -281,4 +284,3 @@ class Convert {
|
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
286
|
exports.Convert = Convert;
|
|
284
|
-
//# sourceMappingURL=convert.js.map
|
package/dist/commands/install.js
CHANGED
|
@@ -30,6 +30,8 @@ const mkdirp = __importStar(require("mkdirp"));
|
|
|
30
30
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
31
31
|
class Install {
|
|
32
32
|
constructor(configuration) {
|
|
33
|
+
this.locales = undefined;
|
|
34
|
+
this.options = undefined;
|
|
33
35
|
this.configuration = configuration;
|
|
34
36
|
}
|
|
35
37
|
synopsis() {
|
|
@@ -42,7 +44,7 @@ class Install {
|
|
|
42
44
|
return [];
|
|
43
45
|
}
|
|
44
46
|
args() {
|
|
45
|
-
var _a, _b, _c, _d, _e;
|
|
47
|
+
var _a, _b, _c, _d, _e, _f;
|
|
46
48
|
return {
|
|
47
49
|
locales: {
|
|
48
50
|
alias: 'l',
|
|
@@ -66,10 +68,16 @@ class Install {
|
|
|
66
68
|
choices: ['gmo', 'mo'],
|
|
67
69
|
group: gtx._('Input file options:'),
|
|
68
70
|
},
|
|
71
|
+
'default-domain': {
|
|
72
|
+
type: 'string',
|
|
73
|
+
describe: gtx._('The textdomain to use'),
|
|
74
|
+
default: (_d = this.configuration.package) === null || _d === void 0 ? void 0 : _d.textdomain,
|
|
75
|
+
group: gtx._('Output file options'),
|
|
76
|
+
},
|
|
69
77
|
'output-directory': {
|
|
70
78
|
type: 'string',
|
|
71
79
|
describe: gtx._('Output directory'),
|
|
72
|
-
default: (
|
|
80
|
+
default: (_f = (_e = this.configuration.install) === null || _e === void 0 ? void 0 : _e.directory) !== null && _f !== void 0 ? _f : 'src/locale',
|
|
73
81
|
group: gtx._('Output file options:'),
|
|
74
82
|
},
|
|
75
83
|
'output-format': {
|
|
@@ -86,6 +94,7 @@ class Install {
|
|
|
86
94
|
},
|
|
87
95
|
};
|
|
88
96
|
}
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
89
98
|
additional(_) { }
|
|
90
99
|
init(argv) {
|
|
91
100
|
var _a, _b, _c, _d;
|
|
@@ -224,7 +233,7 @@ class Install {
|
|
|
224
233
|
installLocale(locale) {
|
|
225
234
|
try {
|
|
226
235
|
const directory = this.options.outputDirectory + '/' + locale + '/LC_MESSAGES';
|
|
227
|
-
const outFile = directory + '/' +
|
|
236
|
+
const outFile = directory + '/' + this.options.defaultDomain + '.' + this.options.outputFormat;
|
|
228
237
|
const inFile = this.options.directory + '/' + locale + '.' + this.options.inputFormat;
|
|
229
238
|
if (!(0, fs_1.existsSync)(directory)) {
|
|
230
239
|
mkdirp.sync(directory);
|
|
@@ -246,4 +255,3 @@ class Install {
|
|
|
246
255
|
}
|
|
247
256
|
}
|
|
248
257
|
exports.Install = Install;
|
|
249
|
-
//# sourceMappingURL=install.js.map
|
|
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
25
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
35
|
exports.MsgfmtAll = void 0;
|
|
27
36
|
const fs = __importStar(require("fs"));
|
|
@@ -31,6 +40,8 @@ const package_1 = require("../package");
|
|
|
31
40
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
32
41
|
class MsgfmtAll {
|
|
33
42
|
constructor(configuration) {
|
|
43
|
+
this.locales = undefined;
|
|
44
|
+
this.options = undefined;
|
|
34
45
|
this.configuration = configuration;
|
|
35
46
|
}
|
|
36
47
|
synopsis() {
|
|
@@ -96,6 +107,7 @@ class MsgfmtAll {
|
|
|
96
107
|
}
|
|
97
108
|
return options;
|
|
98
109
|
}
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
99
111
|
additional(_) { }
|
|
100
112
|
init(argv) {
|
|
101
113
|
var _a, _b;
|
|
@@ -119,9 +131,15 @@ class MsgfmtAll {
|
|
|
119
131
|
run(argv) {
|
|
120
132
|
this.init(argv);
|
|
121
133
|
return new Promise(resolve => {
|
|
122
|
-
this.locales
|
|
123
|
-
|
|
124
|
-
.then(
|
|
134
|
+
const promises = this.locales.map(locale => this.msgfmtLocale(locale));
|
|
135
|
+
Promise.all(promises)
|
|
136
|
+
.then(results => {
|
|
137
|
+
const hasOne = results.some(result => result === 1);
|
|
138
|
+
resolve(hasOne ? 1 : 0);
|
|
139
|
+
})
|
|
140
|
+
.catch(() => {
|
|
141
|
+
resolve(1);
|
|
142
|
+
});
|
|
125
143
|
});
|
|
126
144
|
}
|
|
127
145
|
convertOptions(options) {
|
|
@@ -147,54 +165,55 @@ class MsgfmtAll {
|
|
|
147
165
|
}
|
|
148
166
|
return errors ? null : msgmergeOptions;
|
|
149
167
|
}
|
|
150
|
-
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
po
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
const msgfmt = childProcess.spawn(this.options.msgfmt, args, {
|
|
166
|
-
windowsHide: true,
|
|
167
|
-
});
|
|
168
|
-
msgfmt.stdout.on('data', (data) => process.stdout.write(data.toString()));
|
|
169
|
-
msgfmt.stderr.on('data', (data) => process.stderr.write(data.toString()));
|
|
170
|
-
msgfmt.on('close', code => {
|
|
171
|
-
if (code) {
|
|
172
|
-
fs.unlinkSync(moFile);
|
|
173
|
-
resolve(1);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
resolve(0);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
msgfmt.on('error', err => {
|
|
180
|
-
throw new Error(gtx._x("Failed to run '{prg}': {err}", {
|
|
181
|
-
prg: this.options.msgfmt,
|
|
182
|
-
err,
|
|
168
|
+
msgfmtLocale(locale) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
return new Promise(resolve => {
|
|
171
|
+
const args = this.convertOptions(this.options.options);
|
|
172
|
+
if (!args)
|
|
173
|
+
return resolve(1);
|
|
174
|
+
const poFile = this.options.directory + '/' + locale + '.po';
|
|
175
|
+
const moFile = this.options.directory + '/' + locale + '.' + this.options.format;
|
|
176
|
+
args.push('-o', moFile, poFile);
|
|
177
|
+
if (this.options.verbose) {
|
|
178
|
+
console.log(gtx._x("Compiling '{po}' into '{mo}'.", {
|
|
179
|
+
po: poFile,
|
|
180
|
+
mo: moFile,
|
|
183
181
|
}));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
catch (err) {
|
|
182
|
+
}
|
|
187
183
|
try {
|
|
188
|
-
|
|
184
|
+
const msgfmt = childProcess.spawn(this.options.msgfmt, args, {
|
|
185
|
+
windowsHide: true,
|
|
186
|
+
});
|
|
187
|
+
msgfmt.stdout.on('data', (data) => process.stdout.write(data.toString()));
|
|
188
|
+
msgfmt.stderr.on('data', (data) => process.stderr.write(data.toString()));
|
|
189
|
+
msgfmt.on('close', code => {
|
|
190
|
+
if (code) {
|
|
191
|
+
fs.unlinkSync(moFile);
|
|
192
|
+
resolve(1);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
resolve(0);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
msgfmt.on('error', err => {
|
|
199
|
+
throw new Error(gtx._x("Failed to run '{prg}': {err}", {
|
|
200
|
+
prg: this.options.msgfmt,
|
|
201
|
+
err,
|
|
202
|
+
}));
|
|
203
|
+
});
|
|
189
204
|
}
|
|
190
|
-
catch (
|
|
191
|
-
|
|
205
|
+
catch (err) {
|
|
206
|
+
try {
|
|
207
|
+
fs.unlinkSync(moFile);
|
|
208
|
+
}
|
|
209
|
+
catch (err1) {
|
|
210
|
+
console.error(err1);
|
|
211
|
+
}
|
|
212
|
+
console.error(err);
|
|
213
|
+
resolve(1);
|
|
192
214
|
}
|
|
193
|
-
|
|
194
|
-
resolve(1);
|
|
195
|
-
}
|
|
215
|
+
});
|
|
196
216
|
});
|
|
197
217
|
}
|
|
198
218
|
}
|
|
199
219
|
exports.MsgfmtAll = MsgfmtAll;
|
|
200
|
-
//# sourceMappingURL=msgfmt-all.js.map
|
|
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
25
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
35
|
exports.MsgmergeAll = void 0;
|
|
27
36
|
const path = __importStar(require("path"));
|
|
@@ -33,6 +42,8 @@ const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
|
33
42
|
class MsgmergeAll {
|
|
34
43
|
constructor(configuration) {
|
|
35
44
|
var _a, _b;
|
|
45
|
+
this.locales = [];
|
|
46
|
+
this.options = {};
|
|
36
47
|
this.configuration = configuration;
|
|
37
48
|
if (((_a = configuration.package) === null || _a === void 0 ? void 0 : _a.textdomain) &&
|
|
38
49
|
typeof ((_b = configuration.po) === null || _b === void 0 ? void 0 : _b.directory) !== 'undefined') {
|
|
@@ -131,9 +142,15 @@ class MsgmergeAll {
|
|
|
131
142
|
run(argv) {
|
|
132
143
|
this.init(argv);
|
|
133
144
|
return new Promise(resolve => {
|
|
134
|
-
this.locales
|
|
135
|
-
|
|
136
|
-
.then(
|
|
145
|
+
const promises = this.locales.map(locale => this.msgmergeLocale(locale));
|
|
146
|
+
Promise.all(promises)
|
|
147
|
+
.then(results => {
|
|
148
|
+
const hasOne = results.some(result => result === 1);
|
|
149
|
+
resolve(hasOne ? 1 : 0);
|
|
150
|
+
})
|
|
151
|
+
.catch(() => {
|
|
152
|
+
resolve(1);
|
|
153
|
+
});
|
|
137
154
|
});
|
|
138
155
|
}
|
|
139
156
|
convertOptions(options) {
|
|
@@ -159,54 +176,55 @@ class MsgmergeAll {
|
|
|
159
176
|
}
|
|
160
177
|
return errors ? null : msgmergeOptions;
|
|
161
178
|
}
|
|
162
|
-
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
pot
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
prg:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
msgmergeLocale(locale) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
return new Promise(resolve => {
|
|
182
|
+
const args = this.convertOptions(this.options.options);
|
|
183
|
+
if (!args)
|
|
184
|
+
return resolve(1);
|
|
185
|
+
const poFile = this.options.directory + '/' + locale + '.po';
|
|
186
|
+
const oldPoFile = this.options.directory + '/' + locale + '.old.po';
|
|
187
|
+
args.push(oldPoFile, this.potfile, '-o', poFile);
|
|
188
|
+
console.log(gtx._x("Merging '{pot}' into '{po}'.", {
|
|
189
|
+
pot: this.potfile,
|
|
190
|
+
po: poFile,
|
|
191
|
+
}));
|
|
192
|
+
try {
|
|
193
|
+
fs.renameSync(poFile, oldPoFile);
|
|
194
|
+
const msgmerge = childProcess.spawn(this.options.msgmerge, args, {
|
|
195
|
+
windowsHide: true,
|
|
196
|
+
});
|
|
197
|
+
msgmerge.on('error', err => {
|
|
198
|
+
throw new Error(gtx._x("Failed to run '{prg}': {err}", {
|
|
199
|
+
prg: this.options.msgmerge,
|
|
200
|
+
err,
|
|
201
|
+
}));
|
|
202
|
+
});
|
|
203
|
+
msgmerge.stdout.on('data', (data) => process.stdout.write(data.toString()));
|
|
204
|
+
msgmerge.stderr.on('data', (data) => process.stderr.write(data.toString()));
|
|
205
|
+
msgmerge.on('close', code => {
|
|
206
|
+
if (code) {
|
|
207
|
+
fs.renameSync(oldPoFile, poFile);
|
|
208
|
+
resolve(1);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
fs.unlinkSync(oldPoFile);
|
|
212
|
+
resolve(0);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
try {
|
|
189
218
|
fs.renameSync(oldPoFile, poFile);
|
|
190
|
-
resolve(1);
|
|
191
219
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
resolve(0);
|
|
220
|
+
catch (err1) {
|
|
221
|
+
console.error(err1);
|
|
195
222
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
catch (err) {
|
|
199
|
-
try {
|
|
200
|
-
fs.renameSync(oldPoFile, poFile);
|
|
201
|
-
}
|
|
202
|
-
catch (err1) {
|
|
203
|
-
console.error(err1);
|
|
223
|
+
console.error(err);
|
|
224
|
+
resolve(1);
|
|
204
225
|
}
|
|
205
|
-
|
|
206
|
-
resolve(1);
|
|
207
|
-
}
|
|
226
|
+
});
|
|
208
227
|
});
|
|
209
228
|
}
|
|
210
229
|
}
|
|
211
230
|
exports.MsgmergeAll = MsgmergeAll;
|
|
212
|
-
//# sourceMappingURL=msgmerge-all.js.map
|
|
@@ -18,6 +18,7 @@ class FilesCollector {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
args.forEach(filename => filenames.push(filename));
|
|
21
|
+
// Make filenames unique.
|
|
21
22
|
this.filenames = Array.from(new Set(filenames));
|
|
22
23
|
}
|
|
23
24
|
getFilesFromFile(filename) {
|
|
@@ -36,4 +37,3 @@ class FilesCollector {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
exports.FilesCollector = FilesCollector;
|
|
39
|
-
//# sourceMappingURL=files-collector.js.map
|
|
@@ -35,7 +35,11 @@ const javascript_1 = require("../parser/javascript");
|
|
|
35
35
|
const keyword_1 = require("../pot/keyword");
|
|
36
36
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
37
37
|
class XGettext {
|
|
38
|
+
// The date is only passed for testing.
|
|
38
39
|
constructor(configuration, date) {
|
|
40
|
+
this.catalog = undefined;
|
|
41
|
+
this.exclude = undefined;
|
|
42
|
+
this.options = undefined;
|
|
39
43
|
this.date = date;
|
|
40
44
|
this.configuration = configuration;
|
|
41
45
|
}
|
|
@@ -49,7 +53,7 @@ class XGettext {
|
|
|
49
53
|
return ['extract'];
|
|
50
54
|
}
|
|
51
55
|
args() {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
53
57
|
const outputFile = ((_a = this.configuration.package) === null || _a === void 0 ? void 0 : _a.textdomain)
|
|
54
58
|
? `${this.configuration.package.textdomain}.pot`
|
|
55
59
|
: undefined;
|
|
@@ -59,6 +63,7 @@ class XGettext {
|
|
|
59
63
|
type: 'string',
|
|
60
64
|
array: true,
|
|
61
65
|
describe: gtx._('get list of input files from FILE'),
|
|
66
|
+
default: (_b = this.configuration.package) === null || _b === void 0 ? void 0 : _b['files-from'],
|
|
62
67
|
},
|
|
63
68
|
directory: {
|
|
64
69
|
group: gtx._('Input file location:'),
|
|
@@ -84,7 +89,7 @@ class XGettext {
|
|
|
84
89
|
alias: 'p',
|
|
85
90
|
type: 'string',
|
|
86
91
|
describe: gtx._('output files will be placed in directory DIR. If output file is -, output is written to standard output.'),
|
|
87
|
-
default: (
|
|
92
|
+
default: (_d = (_c = this.configuration.po) === null || _c === void 0 ? void 0 : _c.directory) !== null && _d !== void 0 ? _d : '.',
|
|
88
93
|
},
|
|
89
94
|
language: {
|
|
90
95
|
group: gtx._('Choice of input file language:'),
|
|
@@ -188,7 +193,7 @@ class XGettext {
|
|
|
188
193
|
group: gtx._('Output details:'),
|
|
189
194
|
type: 'string',
|
|
190
195
|
describe: gtx._('set copyright holder in output'),
|
|
191
|
-
default: (
|
|
196
|
+
default: (_e = this.configuration.package) === null || _e === void 0 ? void 0 : _e['copyright-holder'],
|
|
192
197
|
},
|
|
193
198
|
'foreign-user': {
|
|
194
199
|
group: gtx._('Output details:'),
|
|
@@ -199,19 +204,19 @@ class XGettext {
|
|
|
199
204
|
group: gtx._('Output details:'),
|
|
200
205
|
type: 'string',
|
|
201
206
|
describe: gtx._('set package name in output'),
|
|
202
|
-
default: (
|
|
207
|
+
default: (_f = this.configuration.package) === null || _f === void 0 ? void 0 : _f.name,
|
|
203
208
|
},
|
|
204
209
|
'package-version': {
|
|
205
210
|
group: gtx._('Output details:'),
|
|
206
211
|
type: 'string',
|
|
207
212
|
describe: gtx._('set package version in output'),
|
|
208
|
-
default: (
|
|
213
|
+
default: (_g = this.configuration.package) === null || _g === void 0 ? void 0 : _g.version,
|
|
209
214
|
},
|
|
210
215
|
'msgid-bugs-address': {
|
|
211
216
|
group: gtx._('Output details:'),
|
|
212
217
|
type: 'string',
|
|
213
218
|
describe: gtx._('set report address for msgid bugs'),
|
|
214
|
-
default: (
|
|
219
|
+
default: (_h = this.configuration.package) === null || _h === void 0 ? void 0 : _h['msgid-bugs-address'],
|
|
215
220
|
},
|
|
216
221
|
'msgstr-prefix': {
|
|
217
222
|
group: gtx._('Output details:'),
|
|
@@ -232,6 +237,7 @@ class XGettext {
|
|
|
232
237
|
},
|
|
233
238
|
};
|
|
234
239
|
}
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
235
241
|
additional(_) { }
|
|
236
242
|
init(argv) {
|
|
237
243
|
var _a, _b, _c, _d, _e;
|
|
@@ -318,6 +324,8 @@ class XGettext {
|
|
|
318
324
|
console.error(`${this.options.$0}: ${e}`);
|
|
319
325
|
return 1;
|
|
320
326
|
}
|
|
327
|
+
// FIXME! The file collector must interpret all filenames relative to
|
|
328
|
+
// the files-from file's director.
|
|
321
329
|
fileCollector.filenames.forEach(filename => {
|
|
322
330
|
try {
|
|
323
331
|
if (!this.parse(this.readFile(filename), filename)) {
|
|
@@ -374,6 +382,7 @@ class XGettext {
|
|
|
374
382
|
return process.stdin.read();
|
|
375
383
|
}
|
|
376
384
|
const directories = this.options.directory || [''];
|
|
385
|
+
// Avoid ugly absolute paths.
|
|
377
386
|
const resolve = (dir, file) => {
|
|
378
387
|
if (dir === '') {
|
|
379
388
|
return file;
|
|
@@ -388,6 +397,7 @@ class XGettext {
|
|
|
388
397
|
return (0, fs_1.readFileSync)(fullName);
|
|
389
398
|
}
|
|
390
399
|
catch (e) {
|
|
400
|
+
/* ignore */
|
|
391
401
|
}
|
|
392
402
|
}
|
|
393
403
|
return (0, fs_1.readFileSync)(resolve(directories[directories.length - 1], filename));
|
|
@@ -522,4 +532,3 @@ class XGettext {
|
|
|
522
532
|
}
|
|
523
533
|
}
|
|
524
534
|
exports.XGettext = XGettext;
|
|
525
|
-
//# sourceMappingURL=xgettext.js.map
|