@esgettext/tools 1.0.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 +197 -22
- package/dist/command.js +2 -0
- package/dist/commands/convert.js +286 -0
- package/dist/commands/install.js +257 -0
- package/dist/commands/msgfmt-all.js +219 -0
- package/dist/commands/msgmerge-all.js +230 -0
- package/dist/commands/xgettext/file-resolver.js +20 -0
- package/dist/commands/xgettext/files-collector.js +39 -0
- package/dist/commands/xgettext.js +534 -0
- package/dist/configuration.js +277 -0
- package/dist/esgettext-package-json.js +2 -0
- package/dist/index.js +135 -0
- package/dist/package.js +10 -12
- package/dist/parser/javascript.js +9 -28
- package/dist/parser/parser.js +176 -148
- package/dist/parser/po.js +144 -128
- package/dist/parser/typescript.js +10 -28
- package/dist/pot/catalog.js +134 -83
- package/dist/pot/entry.js +173 -115
- package/dist/pot/keyword.js +66 -92
- package/package.json +38 -25
- package/bin/esgettext-install.js +0 -5
- package/bin/esgettext-mo2json.js +0 -5
- package/bin/esgettext-msgfmt-all.js +0 -5
- package/bin/esgettext-msgmerge-all.js +0 -5
- package/bin/esgettext-xgettext.js +0 -5
- package/dist/cli/getopt.d.ts +0 -34
- package/dist/cli/getopt.js +0 -150
- package/dist/cli/getopt.js.map +0 -1
- package/dist/cli/getopt.spec.d.ts +0 -1
- package/dist/cli/getopt.spec.js +0 -164
- package/dist/cli/getopt.spec.js.map +0 -1
- package/dist/cli/install.d.ts +0 -1
- package/dist/cli/install.js +0 -91
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/mo2json-cli.d.ts +0 -1
- package/dist/cli/mo2json-cli.js +0 -48
- package/dist/cli/mo2json-cli.js.map +0 -1
- package/dist/cli/msgfmt-all.d.ts +0 -1
- package/dist/cli/msgfmt-all.js +0 -99
- package/dist/cli/msgfmt-all.js.map +0 -1
- package/dist/cli/msgmerge-all.d.ts +0 -1
- package/dist/cli/msgmerge-all.js +0 -85
- package/dist/cli/msgmerge-all.js.map +0 -1
- package/dist/cli/xgettext-cli.d.ts +0 -1
- package/dist/cli/xgettext-cli.js +0 -303
- package/dist/cli/xgettext-cli.js.map +0 -1
- package/dist/install/install.d.ts +0 -10
- package/dist/install/install.js +0 -157
- package/dist/install/install.js.map +0 -1
- package/dist/msgfmt-all/msgfmt-all.d.ts +0 -8
- package/dist/msgfmt-all/msgfmt-all.js +0 -142
- package/dist/msgfmt-all/msgfmt-all.js.map +0 -1
- package/dist/msgmerge-all/msgmerge-all.d.ts +0 -9
- package/dist/msgmerge-all/msgmerge-all.js +0 -157
- package/dist/msgmerge-all/msgmerge-all.js.map +0 -1
- package/dist/package.d.ts +0 -4
- package/dist/package.js.map +0 -1
- package/dist/parser/__snapshots__/javascript.spec.js.snap +0 -56
- package/dist/parser/__snapshots__/po.spec.js.snap +0 -176
- 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 -436
- 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 -296
- 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 -106
- package/dist/parser/typescript.spec.js.map +0 -1
- package/dist/pot/__snapshots__/catalog.spec.js.snap +0 -591
- 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 -240
- 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 -317
- 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/dist/xgettext/__snapshots__/xgettext.spec.js.snap +0 -462
- package/dist/xgettext/file-resolver.d.ts +0 -5
- package/dist/xgettext/file-resolver.js +0 -23
- package/dist/xgettext/file-resolver.js.map +0 -1
- package/dist/xgettext/file-resolver.spec.d.ts +0 -1
- package/dist/xgettext/file-resolver.spec.js +0 -22
- package/dist/xgettext/file-resolver.spec.js.map +0 -1
- package/dist/xgettext/files-collector.d.ts +0 -5
- package/dist/xgettext/files-collector.js +0 -41
- package/dist/xgettext/files-collector.js.map +0 -1
- package/dist/xgettext/files-collector.spec.d.ts +0 -1
- package/dist/xgettext/files-collector.spec.js +0 -78
- package/dist/xgettext/files-collector.spec.js.map +0 -1
- package/dist/xgettext/xgettext.d.ts +0 -16
- package/dist/xgettext/xgettext.js +0 -335
- package/dist/xgettext/xgettext.js.map +0 -1
- package/dist/xgettext/xgettext.spec.d.ts +0 -1
- package/dist/xgettext/xgettext.spec.js +0 -743
- package/dist/xgettext/xgettext.spec.js.map +0 -1
package/dist/parser/po.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.PoParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
const iconv_lite_1 = require("iconv-lite");
|
|
5
|
+
const runtime_1 = require("@esgettext/runtime");
|
|
6
|
+
const entry_1 = require("../pot/entry");
|
|
7
|
+
const parser_1 = require("./parser");
|
|
8
|
+
const gtx = runtime_1.Textdomain.getInstance('tools');
|
|
9
|
+
class PoParser extends parser_1.Parser {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
// All those get reset on each call to parse().
|
|
13
|
+
this.entry = undefined;
|
|
14
|
+
this.loc = undefined;
|
|
15
|
+
this.entryLoc = undefined;
|
|
16
|
+
this.msgType = undefined;
|
|
17
|
+
this.seen = {};
|
|
30
18
|
}
|
|
31
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Parse a po file into a catalog. This parser is very forgiving and
|
|
21
|
+
* accepts input that actually does not follow the standard in certain
|
|
22
|
+
* areas.
|
|
23
|
+
*
|
|
24
|
+
* The encoding will always be read from the PO header if present.
|
|
25
|
+
*
|
|
26
|
+
* @param input - the content of the po file
|
|
27
|
+
* @param filename - the filename
|
|
28
|
+
* @param encoding - an optional encoding
|
|
29
|
+
*/
|
|
30
|
+
parse(buf, filename, encoding) {
|
|
32
31
|
if (typeof encoding !== 'undefined') {
|
|
33
32
|
if (!(0, iconv_lite_1.encodingExists)(encoding)) {
|
|
34
|
-
console.error(gtx._x('unsupported encoding "{encoding}"', { encoding
|
|
33
|
+
console.error(gtx._x('unsupported encoding "{encoding}"', { encoding }));
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
const input = typeof encoding === 'undefined' ? buf.toString() : (0, iconv_lite_1.decode)(buf, encoding);
|
|
38
|
+
// Reset parser.
|
|
39
39
|
this.entry = undefined;
|
|
40
40
|
this.filename = filename;
|
|
41
41
|
this.loc = {
|
|
@@ -44,16 +44,22 @@ var PoParser = (function (_super) {
|
|
|
44
44
|
column: 1,
|
|
45
45
|
index: 0,
|
|
46
46
|
},
|
|
47
|
-
end:
|
|
48
|
-
|
|
47
|
+
end: {
|
|
48
|
+
line: 0,
|
|
49
|
+
column: 0,
|
|
50
|
+
index: 0,
|
|
51
|
+
},
|
|
52
|
+
filename,
|
|
49
53
|
identifierName: '',
|
|
50
54
|
};
|
|
51
|
-
this.msgType =
|
|
55
|
+
this.msgType = undefined;
|
|
52
56
|
this.seen = {};
|
|
53
57
|
this.errors = 0;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
// We cannot use forEach here because we may have to return from
|
|
59
|
+
// inside the loop.
|
|
60
|
+
const lines = input.split('\n');
|
|
61
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
62
|
+
const line = lines[i];
|
|
57
63
|
this.loc.start.column = 1;
|
|
58
64
|
++this.loc.start.line;
|
|
59
65
|
if (line === '') {
|
|
@@ -61,17 +67,20 @@ var PoParser = (function (_super) {
|
|
|
61
67
|
this.entry.properties.msgid === '' &&
|
|
62
68
|
typeof this.entry.properties.msgctxt === 'undefined' &&
|
|
63
69
|
this.entry.properties.msgstr) {
|
|
64
|
-
|
|
70
|
+
const charset = this.extractCharset(this.entry.properties.msgstr);
|
|
65
71
|
if (charset &&
|
|
66
72
|
(typeof encoding === 'undefined' ||
|
|
67
73
|
charset.toLowerCase() !== encoding.toLowerCase())) {
|
|
74
|
+
// FIXME! This must only happen, if the header is the first
|
|
75
|
+
// entry that has been added. Otherwise, we'll add the entries
|
|
76
|
+
// before this, twice.
|
|
68
77
|
return this.parse(buf, filename, charset);
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
80
|
this.flushEntry();
|
|
72
81
|
}
|
|
73
82
|
else {
|
|
74
|
-
|
|
83
|
+
const first = line[0];
|
|
75
84
|
switch (first) {
|
|
76
85
|
case '#':
|
|
77
86
|
if (line.length > 1 && line[1] === '~') {
|
|
@@ -112,10 +121,13 @@ var PoParser = (function (_super) {
|
|
|
112
121
|
this.entry.properties.msgid === '' &&
|
|
113
122
|
typeof this.entry.properties.msgctxt === 'undefined' &&
|
|
114
123
|
this.entry.properties.msgstr) {
|
|
115
|
-
|
|
124
|
+
const charset = this.extractCharset(this.entry.properties.msgstr);
|
|
116
125
|
if (charset &&
|
|
117
126
|
(typeof encoding === 'undefined' ||
|
|
118
127
|
charset.toLowerCase() !== encoding.toLowerCase())) {
|
|
128
|
+
// FIXME! This must only happen, if the header is the first
|
|
129
|
+
// entry that has been added. Otherwise, we'll add the entries
|
|
130
|
+
// before this, twice.
|
|
119
131
|
return this.parse(buf, filename, charset);
|
|
120
132
|
}
|
|
121
133
|
}
|
|
@@ -123,50 +135,53 @@ var PoParser = (function (_super) {
|
|
|
123
135
|
if (this.errors) {
|
|
124
136
|
return false;
|
|
125
137
|
}
|
|
138
|
+
// FIXME! This must go into the caller!
|
|
126
139
|
this.catalog.makePOT();
|
|
127
140
|
return true;
|
|
128
|
-
}
|
|
129
|
-
|
|
141
|
+
}
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
143
|
+
doParse(_input, _filename) {
|
|
130
144
|
throw new Error('not implemented');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
}
|
|
146
|
+
extractCharset(header) {
|
|
147
|
+
const headers = {};
|
|
134
148
|
header
|
|
135
149
|
.split('\n')
|
|
136
|
-
.map(
|
|
137
|
-
.map(
|
|
150
|
+
.map(line => line.split(':'))
|
|
151
|
+
.map(chunks => ({
|
|
138
152
|
name: chunks[0].toLowerCase(),
|
|
139
153
|
value: chunks.slice(1).join(':').trim(),
|
|
140
|
-
})
|
|
141
|
-
.filter(
|
|
142
|
-
.forEach(
|
|
143
|
-
|
|
154
|
+
}))
|
|
155
|
+
.filter(header => header.name !== '')
|
|
156
|
+
.forEach(header => (headers[header.name] = header.value));
|
|
157
|
+
const contentType = headers['content-type'];
|
|
144
158
|
if (typeof contentType === 'undefined') {
|
|
145
159
|
return null;
|
|
146
160
|
}
|
|
147
|
-
|
|
161
|
+
const tokens = contentType.split('=').map(token => token.trim());
|
|
148
162
|
if (tokens.length <= 1) {
|
|
149
163
|
return null;
|
|
150
164
|
}
|
|
151
|
-
|
|
165
|
+
const charset = tokens[tokens.length - 1];
|
|
152
166
|
if (!(0, iconv_lite_1.encodingExists)(charset)) {
|
|
153
167
|
this.warn(gtx._x('the charset "{charset}" is not a portable encoding name.', {
|
|
154
|
-
charset
|
|
168
|
+
charset,
|
|
155
169
|
}), this.loc);
|
|
156
170
|
this.warn(gtx._('message conversion to the users charset might not work.'), this.loc);
|
|
157
171
|
return null;
|
|
158
172
|
}
|
|
159
173
|
return charset;
|
|
160
|
-
}
|
|
161
|
-
|
|
174
|
+
}
|
|
175
|
+
flushEntry() {
|
|
162
176
|
if (this.errors) {
|
|
163
177
|
this.entry = undefined;
|
|
164
178
|
return;
|
|
165
179
|
}
|
|
166
180
|
if (this.entry) {
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
const msgctxt = this.entry.properties.msgctxt;
|
|
182
|
+
const msgid = this.entry.properties.msgid;
|
|
169
183
|
if (typeof msgid === 'undefined') {
|
|
184
|
+
// TRANSLATORS: Do not translate "msgid".
|
|
170
185
|
this.error(gtx._('missing "msgid" section'), this.loc);
|
|
171
186
|
return;
|
|
172
187
|
}
|
|
@@ -182,9 +197,9 @@ var PoParser = (function (_super) {
|
|
|
182
197
|
this.catalog.addEntry(this.entry);
|
|
183
198
|
}
|
|
184
199
|
this.entry = undefined;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
200
|
+
}
|
|
201
|
+
parseCommentLine(line) {
|
|
202
|
+
const marker = line[1];
|
|
188
203
|
switch (marker) {
|
|
189
204
|
case ',':
|
|
190
205
|
this.parseFlags(line);
|
|
@@ -202,44 +217,43 @@ var PoParser = (function (_super) {
|
|
|
202
217
|
this.entry.addTranslatorCommentLine(line.substr(1));
|
|
203
218
|
break;
|
|
204
219
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
var remainder = line.replace(/^[_A-Za-z0-9[\]]+/, function (keyword) {
|
|
220
|
+
}
|
|
221
|
+
parseKeywordLine(line) {
|
|
222
|
+
const errorsBefore = this.errors;
|
|
223
|
+
let remainder = line.replace(/^[_A-Za-z0-9[\]]+/, keyword => {
|
|
210
224
|
switch (keyword) {
|
|
211
225
|
case 'msgid':
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (typeof
|
|
215
|
-
|
|
226
|
+
this.entryLoc = this.copyLocation(this.loc);
|
|
227
|
+
this.msgType = keyword;
|
|
228
|
+
if (typeof this.entry.properties.msgid !== 'undefined') {
|
|
229
|
+
this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
|
|
216
230
|
}
|
|
217
231
|
break;
|
|
218
232
|
case 'msgstr':
|
|
219
|
-
|
|
220
|
-
if (typeof
|
|
221
|
-
|
|
233
|
+
this.msgType = keyword;
|
|
234
|
+
if (typeof this.entry.properties.msgstr !== 'undefined') {
|
|
235
|
+
this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
|
|
222
236
|
}
|
|
223
237
|
break;
|
|
224
238
|
case 'msgid_plural':
|
|
225
|
-
|
|
226
|
-
if (typeof
|
|
227
|
-
|
|
239
|
+
this.msgType = keyword;
|
|
240
|
+
if (typeof this.entry.properties.msgidPlural !== 'undefined') {
|
|
241
|
+
this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
|
|
228
242
|
}
|
|
229
243
|
break;
|
|
230
244
|
case 'msgctxt':
|
|
231
|
-
|
|
232
|
-
if (typeof
|
|
233
|
-
|
|
245
|
+
this.msgType = keyword;
|
|
246
|
+
if (typeof this.entry.properties.msgctxt !== 'undefined') {
|
|
247
|
+
this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
|
|
234
248
|
}
|
|
235
249
|
break;
|
|
236
250
|
default:
|
|
237
251
|
if (!/^msgstr\[[0-9]+\]/.exec(keyword)) {
|
|
238
|
-
|
|
252
|
+
this.error(gtx._x('keyword "{keyword}" unknown', { keyword }), this.loc);
|
|
239
253
|
}
|
|
240
|
-
|
|
254
|
+
this.msgType = keyword;
|
|
241
255
|
}
|
|
242
|
-
|
|
256
|
+
this.loc.start.column += keyword.length;
|
|
243
257
|
return '';
|
|
244
258
|
});
|
|
245
259
|
if (errorsBefore !== this.errors) {
|
|
@@ -252,21 +266,20 @@ var PoParser = (function (_super) {
|
|
|
252
266
|
else {
|
|
253
267
|
this.syntaxError();
|
|
254
268
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
var _this = this;
|
|
269
|
+
}
|
|
270
|
+
parseQuotedString(line) {
|
|
258
271
|
if (!line.endsWith('"')) {
|
|
259
272
|
this.loc.start.column += line.length;
|
|
260
273
|
this.error(gtx._('end-of-line within string'), this.loc);
|
|
261
274
|
return;
|
|
262
275
|
}
|
|
263
|
-
|
|
276
|
+
const raw = line.substr(1, line.length - 2);
|
|
264
277
|
if (raw.length && raw.endsWith('\\')) {
|
|
265
278
|
this.error(gtx._('end-of-line within string'), this.loc);
|
|
266
279
|
return;
|
|
267
280
|
}
|
|
268
|
-
|
|
269
|
-
|
|
281
|
+
const msg = raw.replace(/\\./g, (match, offset) => {
|
|
282
|
+
let retval;
|
|
270
283
|
switch (match[1]) {
|
|
271
284
|
case '\\':
|
|
272
285
|
case '"':
|
|
@@ -294,8 +307,9 @@ var PoParser = (function (_super) {
|
|
|
294
307
|
retval = '\r';
|
|
295
308
|
break;
|
|
296
309
|
default:
|
|
297
|
-
|
|
298
|
-
|
|
310
|
+
// We have to take the leading quote into account.
|
|
311
|
+
this.loc.start.column += offset + 1;
|
|
312
|
+
this.error(gtx._('invalid control sequence'), this.loc);
|
|
299
313
|
retval = '';
|
|
300
314
|
}
|
|
301
315
|
return retval;
|
|
@@ -317,78 +331,80 @@ var PoParser = (function (_super) {
|
|
|
317
331
|
this.entry.addToMsgctxt(msg);
|
|
318
332
|
break;
|
|
319
333
|
default:
|
|
334
|
+
// Ignore plural translations.
|
|
320
335
|
break;
|
|
321
336
|
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
flags.forEach(function (flag, i) {
|
|
337
|
+
}
|
|
338
|
+
parseFlags(line) {
|
|
339
|
+
const flags = line.substr(2).split(',');
|
|
340
|
+
flags.forEach((flag, i) => {
|
|
327
341
|
if (i) {
|
|
328
|
-
++
|
|
342
|
+
++this.loc.start.column;
|
|
329
343
|
}
|
|
330
|
-
|
|
331
|
-
flag =
|
|
344
|
+
const rspace = this.rspace(flag);
|
|
345
|
+
flag = this.trim(flag);
|
|
332
346
|
if (!flag.length) {
|
|
333
|
-
|
|
347
|
+
this.warn(gtx._('ignoring empty flag'), this.loc);
|
|
334
348
|
}
|
|
335
349
|
else {
|
|
336
|
-
|
|
350
|
+
this.entry.addFlag(flag);
|
|
337
351
|
}
|
|
338
|
-
|
|
352
|
+
this.loc.start.column += rspace + flag.length;
|
|
339
353
|
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
var _this = this;
|
|
354
|
+
}
|
|
355
|
+
parseReferences(line) {
|
|
343
356
|
this.loc.start.column += 2;
|
|
344
|
-
|
|
345
|
-
refs.forEach(
|
|
357
|
+
const refs = line.substr(2).split(' ');
|
|
358
|
+
refs.forEach((reference, i) => {
|
|
346
359
|
if (i) {
|
|
347
|
-
++
|
|
360
|
+
++this.loc.start.column;
|
|
348
361
|
}
|
|
349
|
-
reference =
|
|
362
|
+
reference = this.trim(reference);
|
|
350
363
|
if (/.+:[1-9][0-9]*$/.exec(reference)) {
|
|
351
|
-
|
|
364
|
+
this.entry.addReference(reference);
|
|
352
365
|
}
|
|
353
366
|
else if (reference !== '') {
|
|
354
|
-
|
|
355
|
-
reference
|
|
356
|
-
}),
|
|
367
|
+
this.warn(gtx._x('ignoring mal-formed reference "{reference}"', {
|
|
368
|
+
reference,
|
|
369
|
+
}), this.loc);
|
|
357
370
|
}
|
|
358
|
-
|
|
371
|
+
this.loc.start.column += reference.length;
|
|
359
372
|
});
|
|
360
|
-
}
|
|
361
|
-
|
|
373
|
+
}
|
|
374
|
+
syntaxError() {
|
|
362
375
|
this.error(gtx._('syntax error'), this.loc);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
var _this = this;
|
|
376
|
+
}
|
|
377
|
+
trim(str) {
|
|
366
378
|
return str
|
|
367
|
-
.replace(/^[\s\uFEFF\xA0]+/,
|
|
368
|
-
|
|
379
|
+
.replace(/^[\s\uFEFF\xA0]+/, match => {
|
|
380
|
+
this.loc.start.column += match.length;
|
|
369
381
|
return '';
|
|
370
382
|
})
|
|
371
383
|
.trim();
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
384
|
+
}
|
|
385
|
+
rspace(str) {
|
|
386
|
+
const space = /[\s\uFEFF\xA0]+$/.exec(str);
|
|
375
387
|
if (space) {
|
|
376
388
|
return space[0].length;
|
|
377
389
|
}
|
|
378
390
|
else {
|
|
379
391
|
return 0;
|
|
380
392
|
}
|
|
381
|
-
}
|
|
382
|
-
|
|
393
|
+
}
|
|
394
|
+
copyLocation(loc) {
|
|
383
395
|
return {
|
|
384
396
|
start: {
|
|
385
397
|
line: loc.start.line,
|
|
386
398
|
column: loc.start.column,
|
|
387
399
|
},
|
|
388
|
-
end:
|
|
400
|
+
end: {
|
|
401
|
+
line: 0,
|
|
402
|
+
column: 0,
|
|
403
|
+
index: 0,
|
|
404
|
+
},
|
|
405
|
+
filename: '',
|
|
406
|
+
identifierName: null,
|
|
389
407
|
};
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
}(parser_1.Parser));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
393
410
|
exports.PoParser = PoParser;
|
|
394
|
-
//# sourceMappingURL=po.js.map
|
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.TypeScriptParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
}
|
|
26
|
-
TypeScriptParser.prototype.doParse = function (input, filename) {
|
|
27
|
-
var ast = (0, parser_1.parse)(input, {
|
|
4
|
+
const parser_1 = require("@babel/parser");
|
|
5
|
+
const parser_2 = require("./parser");
|
|
6
|
+
class TypeScriptParser extends parser_2.Parser {
|
|
7
|
+
doParse(input, filename) {
|
|
8
|
+
const ast = (0, parser_1.parse)(input, {
|
|
28
9
|
allowAwaitOutsideFunction: true,
|
|
29
10
|
allowImportExportEverywhere: true,
|
|
30
11
|
allowReturnOutsideFunction: true,
|
|
31
12
|
allowSuperOutsideMethod: true,
|
|
32
13
|
allowUndeclaredExports: true,
|
|
14
|
+
// Documented but not supported. FIXME! Maybe only missing in types.
|
|
15
|
+
// errorRecovery: true,
|
|
33
16
|
sourceFilename: filename,
|
|
34
17
|
plugins: [
|
|
35
18
|
'typescript',
|
|
@@ -37,11 +20,10 @@ var TypeScriptParser = (function (_super) {
|
|
|
37
20
|
'classProperties',
|
|
38
21
|
'classPrivateMethods',
|
|
39
22
|
'classPrivateProperties',
|
|
23
|
+
'decorators',
|
|
40
24
|
],
|
|
41
25
|
});
|
|
42
26
|
return this.extract(filename, ast);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}(parser_2.Parser));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
46
29
|
exports.TypeScriptParser = TypeScriptParser;
|
|
47
|
-
//# sourceMappingURL=typescript.js.map
|