@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/pot/entry.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.POTEntry = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const runtime_1 = require("@esgettext/runtime");
|
|
5
|
+
const gtx = runtime_1.Textdomain.getInstance('tools');
|
|
6
|
+
/**
|
|
7
|
+
* Class representing one entry in a POT file. This is simpler than a PO
|
|
8
|
+
* entry because a couple of things can be ignored:
|
|
9
|
+
*
|
|
10
|
+
* - no translations
|
|
11
|
+
* - no obsolete entries
|
|
12
|
+
* - no previous translations
|
|
13
|
+
*/
|
|
14
|
+
class POTEntry {
|
|
15
|
+
/**
|
|
16
|
+
* Create an entry.
|
|
17
|
+
*
|
|
18
|
+
* @param properties - the properties of the entry
|
|
19
|
+
* @param options - options for wrapping
|
|
20
|
+
*/
|
|
21
|
+
constructor(properties) {
|
|
8
22
|
this.properties = properties;
|
|
9
23
|
if (/[\u0000-\u0006\u000e-\u001f]/.exec(properties.msgid)) {
|
|
10
24
|
throw new Error(gtx._('msgid must not contain control characters.'));
|
|
@@ -24,58 +38,64 @@ var POTEntry = (function () {
|
|
|
24
38
|
'Consider adding a message context, if this ' +
|
|
25
39
|
'is done intentionally.'));
|
|
26
40
|
}
|
|
41
|
+
// Order matters here. This is most likely the order of appearance
|
|
42
|
+
// in the source file.
|
|
27
43
|
this.checkDeprecatedControls(this.properties.msgctxt);
|
|
28
44
|
this.checkDeprecatedControls(this.properties.msgid);
|
|
29
45
|
this.checkDeprecatedControls(this.properties.msgidPlural);
|
|
46
|
+
// See https://savannah.gnu.org/bugs/index.php?58356
|
|
30
47
|
this.checkReferences();
|
|
31
48
|
this.checkFlags();
|
|
32
49
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
static build() {
|
|
51
|
+
const entry = new POTEntry({ msgid: 'ignore' });
|
|
52
|
+
entry.properties.msgid = undefined;
|
|
36
53
|
return entry;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Serialize the entry to a string that can be put into a POT file.
|
|
57
|
+
*
|
|
58
|
+
* (Some) long lines are wrapped to `width` characters. If `width` is
|
|
59
|
+
* less or equal to zero, lines are not wrapped
|
|
60
|
+
*
|
|
61
|
+
* @param width - the requested page width
|
|
62
|
+
*/
|
|
63
|
+
toString(width = 76) {
|
|
64
|
+
let out = '';
|
|
41
65
|
if (typeof this.properties.translatorComments !== 'undefined') {
|
|
42
|
-
for (
|
|
43
|
-
var comment = _a[_i];
|
|
66
|
+
for (let comment of this.properties.translatorComments) {
|
|
44
67
|
comment = comment.replace(/\n/g, '\n# ');
|
|
45
|
-
out +=
|
|
68
|
+
out += `# ${comment}\n`;
|
|
46
69
|
}
|
|
47
70
|
}
|
|
48
71
|
if (typeof this.properties.extractedComments !== 'undefined') {
|
|
49
|
-
for (
|
|
50
|
-
var comment = _c[_b];
|
|
72
|
+
for (let comment of this.properties.extractedComments) {
|
|
51
73
|
comment = comment.replace(/\n/g, '\n#. ');
|
|
52
|
-
out +=
|
|
74
|
+
out += `#. ${comment}\n`;
|
|
53
75
|
}
|
|
54
76
|
}
|
|
55
77
|
if (typeof this.properties.automatic !== 'undefined') {
|
|
56
|
-
for (
|
|
57
|
-
var comment = _e[_d];
|
|
78
|
+
for (let comment of this.properties.automatic) {
|
|
58
79
|
comment = comment.replace(/\n/g, '\n#. ');
|
|
59
|
-
out +=
|
|
80
|
+
out += `#. ${comment}\n`;
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
if (typeof this.properties.references !== 'undefined') {
|
|
63
|
-
|
|
84
|
+
const references = Array.from(new Set(this.properties.references)).join(' ');
|
|
64
85
|
if (width > 0) {
|
|
65
|
-
|
|
66
|
-
for (
|
|
67
|
-
|
|
68
|
-
out += "#: ".concat(line.trimRight().replace(/ $/, ''), "\n");
|
|
86
|
+
const wrapped = this.wrap(references, width - 3);
|
|
87
|
+
for (const line of wrapped) {
|
|
88
|
+
out += `#: ${line.trimRight().replace(/ $/, '')}\n`;
|
|
69
89
|
}
|
|
70
90
|
}
|
|
71
91
|
else {
|
|
72
|
-
out +=
|
|
92
|
+
out += `#: ${references}\n`;
|
|
73
93
|
}
|
|
74
94
|
}
|
|
75
95
|
if (typeof this.properties.flags !== 'undefined' &&
|
|
76
96
|
this.properties.flags.length) {
|
|
77
|
-
|
|
78
|
-
out +=
|
|
97
|
+
const flags = Array.from(new Set(this.properties.flags)).join(', ');
|
|
98
|
+
out += `#, ${flags}\n`;
|
|
79
99
|
}
|
|
80
100
|
if (typeof this.properties.msgctxt !== 'undefined') {
|
|
81
101
|
out +=
|
|
@@ -97,136 +117,178 @@ var POTEntry = (function () {
|
|
|
97
117
|
out += 'msgstr[0] ""\nmsgstr[1] ""\n';
|
|
98
118
|
}
|
|
99
119
|
return out;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Merge to POT entries into one. It is a assumed that both entries share
|
|
123
|
+
* the same `msgid`, `msgidPlural`, and `msgContext`.
|
|
124
|
+
*
|
|
125
|
+
* @param other - the other POT entry
|
|
126
|
+
*/
|
|
127
|
+
merge(other) {
|
|
104
128
|
if (other.properties.translatorComments) {
|
|
105
129
|
if (!this.properties.translatorComments) {
|
|
106
130
|
this.properties.translatorComments = new Array();
|
|
107
131
|
}
|
|
108
|
-
|
|
132
|
+
this.properties.translatorComments.push(...other.properties.translatorComments);
|
|
109
133
|
}
|
|
110
134
|
if (other.properties.automatic) {
|
|
111
135
|
if (!this.properties.automatic) {
|
|
112
136
|
this.properties.automatic = new Array();
|
|
113
137
|
}
|
|
114
|
-
|
|
138
|
+
this.properties.automatic.push(...other.properties.automatic);
|
|
115
139
|
}
|
|
116
140
|
if (other.properties.flags) {
|
|
117
141
|
if (!this.properties.flags) {
|
|
118
142
|
this.properties.flags = new Array();
|
|
119
143
|
}
|
|
120
|
-
other.properties.flags.forEach(
|
|
121
|
-
|
|
144
|
+
other.properties.flags.forEach(flag => {
|
|
145
|
+
let negated = flag.replace(/^no-/, '');
|
|
122
146
|
if (negated === flag) {
|
|
123
147
|
negated = 'no-' + flag;
|
|
124
148
|
}
|
|
125
|
-
if (
|
|
149
|
+
if (this.properties.flags.includes(negated)) {
|
|
126
150
|
other.warning(gtx._x('flag "{flag}" conflicts with previous flag "{negated}"', {
|
|
127
|
-
flag
|
|
128
|
-
negated
|
|
151
|
+
flag,
|
|
152
|
+
negated,
|
|
129
153
|
}));
|
|
130
|
-
|
|
154
|
+
const refs = this.properties.references;
|
|
131
155
|
if (refs) {
|
|
132
|
-
other.warning(gtx._nx('The conflicting flag "{negated}" may stem from this location:', 'The conflicting flag "{negated}" may stem from one of these locations:', refs.length, { flag
|
|
133
|
-
refs.forEach(
|
|
134
|
-
console.warn(
|
|
156
|
+
other.warning(gtx._nx('The conflicting flag "{negated}" may stem from this location:', 'The conflicting flag "{negated}" may stem from one of these locations:', refs.length, { flag, negated }));
|
|
157
|
+
refs.forEach(ref => {
|
|
158
|
+
console.warn(`\t${ref}`);
|
|
135
159
|
});
|
|
136
160
|
}
|
|
137
161
|
}
|
|
138
162
|
});
|
|
139
|
-
|
|
163
|
+
this.properties.flags.push(...other.properties.flags);
|
|
140
164
|
}
|
|
141
165
|
if (other.properties.references) {
|
|
142
166
|
if (!this.properties.references) {
|
|
143
167
|
this.properties.references = new Array();
|
|
144
168
|
}
|
|
145
|
-
|
|
169
|
+
this.properties.references.push(...other.properties.references);
|
|
146
170
|
}
|
|
147
|
-
}
|
|
148
|
-
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Add an extracted comment line. These are comments starting with "#.".
|
|
174
|
+
*
|
|
175
|
+
* @param line - one comment line to add
|
|
176
|
+
*/
|
|
177
|
+
addExtractedCommentLine(line) {
|
|
149
178
|
if (!this.properties.extractedComments) {
|
|
150
179
|
this.properties.extractedComments = [];
|
|
151
180
|
}
|
|
152
181
|
this.properties.extractedComments.push(line);
|
|
153
|
-
}
|
|
154
|
-
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Add a normal comment line.
|
|
185
|
+
*
|
|
186
|
+
* @param line - one comment line to add
|
|
187
|
+
*/
|
|
188
|
+
addTranslatorCommentLine(line) {
|
|
155
189
|
if (!this.properties.translatorComments) {
|
|
156
190
|
this.properties.translatorComments = [];
|
|
157
191
|
}
|
|
158
192
|
this.properties.translatorComments.push(line);
|
|
159
|
-
}
|
|
160
|
-
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Add a flag.
|
|
196
|
+
*
|
|
197
|
+
* @param flags - the flag to add
|
|
198
|
+
*/
|
|
199
|
+
addFlag(flag) {
|
|
161
200
|
if (!this.properties.flags) {
|
|
162
201
|
this.properties.flags = [];
|
|
163
202
|
}
|
|
164
203
|
this.properties.flags.push(flag);
|
|
165
|
-
}
|
|
166
|
-
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Add a reference.
|
|
207
|
+
*
|
|
208
|
+
* @param reference - the reference to add
|
|
209
|
+
*/
|
|
210
|
+
addReference(reference) {
|
|
167
211
|
if (!this.properties.references) {
|
|
168
212
|
this.properties.references = [];
|
|
169
213
|
}
|
|
170
214
|
this.properties.references.push(reference);
|
|
171
|
-
}
|
|
172
|
-
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Add a string chunk to the msgid.
|
|
218
|
+
*
|
|
219
|
+
* @param chunk - the chunk to add
|
|
220
|
+
*/
|
|
221
|
+
addToMsgid(chunk) {
|
|
173
222
|
if (typeof this.properties.msgid === 'undefined') {
|
|
174
223
|
this.properties.msgid = '';
|
|
175
224
|
}
|
|
176
225
|
this.properties.msgid += chunk;
|
|
177
|
-
}
|
|
178
|
-
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Add a string chunk to the msgid_plural.
|
|
229
|
+
*
|
|
230
|
+
* @param chunk - the chunk to add
|
|
231
|
+
*/
|
|
232
|
+
addToMsgidPlural(chunk) {
|
|
179
233
|
if (typeof this.properties.msgidPlural === 'undefined') {
|
|
180
234
|
this.properties.msgidPlural = '';
|
|
181
235
|
}
|
|
182
236
|
this.properties.msgidPlural += chunk;
|
|
183
|
-
}
|
|
184
|
-
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Add a string chunk to the msgstr.
|
|
240
|
+
*
|
|
241
|
+
* @param chunk - the chunk to add
|
|
242
|
+
*/
|
|
243
|
+
addToMsgstr(chunk) {
|
|
185
244
|
if (typeof this.properties.msgstr === 'undefined') {
|
|
186
245
|
this.properties.msgstr = '';
|
|
187
246
|
}
|
|
188
247
|
this.properties.msgstr += chunk;
|
|
189
|
-
}
|
|
190
|
-
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Add a string chunk to the msgctxt.
|
|
251
|
+
*
|
|
252
|
+
* @param chunk - the chunk to add
|
|
253
|
+
*/
|
|
254
|
+
addToMsgctxt(chunk) {
|
|
191
255
|
if (typeof this.properties.msgctxt === 'undefined') {
|
|
192
256
|
this.properties.msgctxt = '';
|
|
193
257
|
}
|
|
194
258
|
this.properties.msgctxt += chunk;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var _this = this;
|
|
198
|
-
if (prefix === void 0) { prefix = 'msgid'; }
|
|
259
|
+
}
|
|
260
|
+
serializeMsgId(input, width, prefix = 'msgid') {
|
|
199
261
|
if (width <= 0) {
|
|
200
|
-
|
|
201
|
-
return
|
|
262
|
+
const escaped = this.escape(input);
|
|
263
|
+
return `${prefix} "${escaped}"`;
|
|
202
264
|
}
|
|
203
|
-
|
|
204
|
-
|
|
265
|
+
const output = new Array();
|
|
266
|
+
const preWrapped = input.split('\n').map(str => this.escape(str));
|
|
205
267
|
if (preWrapped.length > 1 ||
|
|
206
268
|
preWrapped[0].length > width - prefix.length - 3) {
|
|
207
|
-
output.push(
|
|
269
|
+
output.push(`${prefix} ""`);
|
|
208
270
|
}
|
|
209
271
|
else {
|
|
210
|
-
|
|
211
|
-
output.push(
|
|
272
|
+
const chunk = preWrapped.shift();
|
|
273
|
+
output.push(`${prefix} "${chunk}"`);
|
|
212
274
|
}
|
|
213
|
-
preWrapped.forEach(
|
|
275
|
+
preWrapped.forEach((line, index) => {
|
|
214
276
|
if (index < preWrapped.length - 1) {
|
|
215
277
|
line += '\\n';
|
|
216
278
|
}
|
|
217
279
|
if (line.length) {
|
|
218
|
-
|
|
219
|
-
wrapped.forEach(
|
|
220
|
-
output.push("
|
|
280
|
+
const wrapped = this.wrap(line, width - 2);
|
|
281
|
+
wrapped.forEach(inner => {
|
|
282
|
+
output.push(`"${inner}"`);
|
|
221
283
|
});
|
|
222
284
|
}
|
|
223
285
|
});
|
|
224
286
|
return output.join('\n');
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
287
|
+
}
|
|
288
|
+
wrap(input, width) {
|
|
289
|
+
const output = new Array();
|
|
228
290
|
while (input.length > width) {
|
|
229
|
-
|
|
291
|
+
let i = input.lastIndexOf(' ', width);
|
|
230
292
|
if (i < 0) {
|
|
231
293
|
i = input.indexOf(' ', width);
|
|
232
294
|
}
|
|
@@ -238,9 +300,9 @@ var POTEntry = (function () {
|
|
|
238
300
|
}
|
|
239
301
|
output.push(input);
|
|
240
302
|
return output;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
303
|
+
}
|
|
304
|
+
escape(input) {
|
|
305
|
+
const escapes = {
|
|
244
306
|
'\u0007': '\\a',
|
|
245
307
|
'\b': '\\b',
|
|
246
308
|
'\t': '\\t',
|
|
@@ -251,72 +313,68 @@ var POTEntry = (function () {
|
|
|
251
313
|
'"': '\\"',
|
|
252
314
|
'\\': '\\\\',
|
|
253
315
|
};
|
|
254
|
-
return input.replace(/([\u0007-\u000d"\\])/gs,
|
|
316
|
+
return input.replace(/([\u0007-\u000d"\\])/gs, m => {
|
|
255
317
|
return escapes[m[0]];
|
|
256
318
|
});
|
|
257
|
-
}
|
|
258
|
-
|
|
319
|
+
}
|
|
320
|
+
checkDeprecatedControls(str) {
|
|
259
321
|
if (typeof str === 'undefined') {
|
|
260
322
|
return;
|
|
261
323
|
}
|
|
262
|
-
|
|
263
|
-
|
|
324
|
+
const deprecated = RegExp('[\u0007\u0008\u000b-\u000e]', 'gs');
|
|
325
|
+
const escapes = {
|
|
264
326
|
'\u0007': '\\a',
|
|
265
327
|
'\b': '\\b',
|
|
266
328
|
'\v': '\\v',
|
|
267
329
|
'\f': '\\f',
|
|
268
330
|
'\r': '\\r',
|
|
269
331
|
};
|
|
270
|
-
|
|
332
|
+
let matches;
|
|
271
333
|
while ((matches = deprecated.exec(str)) !== null) {
|
|
272
|
-
|
|
273
|
-
if (!
|
|
334
|
+
const escape = escapes[matches[0]];
|
|
335
|
+
if (!escape) {
|
|
274
336
|
continue;
|
|
275
337
|
}
|
|
276
338
|
delete escapes[matches[0]];
|
|
277
339
|
this.warning(gtx._x('internationalized messages should not ' +
|
|
278
|
-
"contain the '{escape}' escape sequence", { escape
|
|
340
|
+
"contain the '{escape}' escape sequence", { escape }));
|
|
279
341
|
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
var _this = this;
|
|
342
|
+
}
|
|
343
|
+
checkReferences() {
|
|
283
344
|
if (typeof this.properties.references === 'undefined') {
|
|
284
345
|
return;
|
|
285
346
|
}
|
|
286
|
-
this.properties.references.forEach(
|
|
347
|
+
this.properties.references.forEach(ref => {
|
|
287
348
|
if (/[ \n]/.exec(ref)) {
|
|
288
|
-
|
|
349
|
+
this.error(gtx._('filenames must not contain space or newlines'));
|
|
289
350
|
}
|
|
290
351
|
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
var _this = this;
|
|
352
|
+
}
|
|
353
|
+
checkFlags() {
|
|
294
354
|
if (typeof this.properties.flags === 'undefined') {
|
|
295
355
|
return;
|
|
296
356
|
}
|
|
297
|
-
this.properties.flags.forEach(
|
|
357
|
+
this.properties.flags.forEach(flag => {
|
|
298
358
|
if (/[,\n]/.exec(flag)) {
|
|
299
|
-
|
|
359
|
+
this.error(gtx._('flags must not contain commas or newlines'));
|
|
300
360
|
}
|
|
301
361
|
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
362
|
+
}
|
|
363
|
+
error(msg) {
|
|
364
|
+
let location = gtx._('[in memory]');
|
|
305
365
|
if (typeof this.properties.references !== 'undefined') {
|
|
306
366
|
location = this.properties.references[0].toString();
|
|
307
367
|
}
|
|
308
|
-
throw new Error(gtx._x('{location}: error: {msg}', { location
|
|
309
|
-
}
|
|
310
|
-
|
|
368
|
+
throw new Error(gtx._x('{location}: error: {msg}', { location, msg }));
|
|
369
|
+
}
|
|
370
|
+
warning(msg) {
|
|
311
371
|
if (!this.properties.noWarnings) {
|
|
312
|
-
|
|
372
|
+
let location = gtx._('[in memory]');
|
|
313
373
|
if (typeof this.properties.references !== 'undefined') {
|
|
314
|
-
|
|
374
|
+
location = this.properties.references[0].toString();
|
|
315
375
|
}
|
|
316
|
-
console.warn(gtx._x('{location}: warning: {msg}', { location
|
|
376
|
+
console.warn(gtx._x('{location}: warning: {msg}', { location, msg }));
|
|
317
377
|
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
}());
|
|
378
|
+
}
|
|
379
|
+
}
|
|
321
380
|
exports.POTEntry = POTEntry;
|
|
322
|
-
//# sourceMappingURL=entry.js.map
|