@esgettext/tools 1.3.1 → 1.3.3
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 +52 -55
- package/dist/commands/init.js +16 -11
- package/dist/commands/install.js +1 -1
- package/dist/commands/msgfmt-all.js +5 -3
- package/dist/commands/msgmerge-all.js +5 -3
- package/dist/commands/xgettext.js +16 -16
- package/dist/configuration.js +10 -2
- package/dist/index.js +36 -4
- package/dist/optspec.js +1 -1
- package/dist/package.js +1 -1
- package/dist/parser/javascript.js +1 -2
- package/dist/parser/typescript.js +1 -2
- package/dist/pot/entry.js +8 -4
- package/package.json +18 -5
package/README.md
CHANGED
|
@@ -2,47 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
Supporting tools for https://github.com/gflohr/esgettext.
|
|
4
4
|
|
|
5
|
+
The package also contains code for parsing po files and for writing them.
|
|
6
|
+
|
|
5
7
|
## Table of Contents <!-- omit in toc -->
|
|
6
8
|
|
|
7
|
-
- [Status](#status)
|
|
8
9
|
- [Prerequisites](#prerequisites)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
- [Un\*x/Linux](#unxlinux)
|
|
11
|
+
- [Mac OS X](#mac-os-x)
|
|
12
|
+
- [MacPorts](#macports)
|
|
13
|
+
- [HomeBrew](#homebrew)
|
|
14
|
+
- [MS-DOS (Microsoft Windows)](#ms-dos-microsoft-windows)
|
|
14
15
|
- [Installation](#installation)
|
|
15
16
|
- [The Tools](#the-tools)
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
- [`esgettext xgettext`](#esgettext-xgettext)
|
|
18
|
+
- [Other Commands](#other-commands)
|
|
18
19
|
- [Configuration](#configuration)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
- [Configuration Files](#configuration-files)
|
|
21
|
+
- [Validation](#validation)
|
|
22
|
+
- [Configuration Schema](#configuration-schema)
|
|
23
|
+
- [`package`](#package)
|
|
24
|
+
- [`package.textdomain`](#packagetextdomain)
|
|
25
|
+
- [`package.msgid-bugs-address`](#packagemsgid-bugs-address)
|
|
26
|
+
- [`package.name`](#packagename)
|
|
27
|
+
- [`package.copyright-holder`](#packagecopyright-holder)
|
|
28
|
+
- [`package.version`](#packageversion)
|
|
29
|
+
- [`po`:](#po)
|
|
30
|
+
- [`po.directory`](#podirectory)
|
|
31
|
+
- [`po.locales`](#polocales)
|
|
32
|
+
- [`install`](#install)
|
|
33
|
+
- [`install.directory`](#installdirectory)
|
|
34
|
+
- [`programs`](#programs)
|
|
35
|
+
- [`programs.msgmerge`](#programsmsgmerge)
|
|
36
|
+
- [`programs.msgmerge.path`](#programsmsgmergepath)
|
|
37
|
+
- [`programs.msgmerge.options`](#programsmsgmergeoptions)
|
|
38
|
+
- [`programs.msgfmt`](#programsmsgfmt)
|
|
39
|
+
- [`programs.msgfmt.path`](#programsmsgfmtpath)
|
|
40
|
+
- [`programs.msgfmt.options`](#programsmsgfmtoptions)
|
|
40
41
|
- [Copyright](#copyright)
|
|
41
42
|
|
|
42
|
-
## Status
|
|
43
|
-
|
|
44
|
-
in development.
|
|
45
|
-
|
|
46
43
|
## Prerequisites
|
|
47
44
|
|
|
48
45
|
Most of the esgettext tools depend at least indirectly on the GNU gettext
|
|
@@ -50,7 +47,7 @@ tools. If the command `xgettext --version` outputs some kind of version
|
|
|
50
47
|
information, you are most probably set. Otherwise check the information for
|
|
51
48
|
your platform below.
|
|
52
49
|
|
|
53
|
-
### Un
|
|
50
|
+
### Un\*x/Linux
|
|
54
51
|
|
|
55
52
|
Use the package manager of your vendor to search for something like
|
|
56
53
|
"gettext-tools" or just "gettext" and install it. The gettext tools are
|
|
@@ -77,8 +74,8 @@ $ brew install gettext
|
|
|
77
74
|
|
|
78
75
|
The options that I know of are
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
- [Cygwin](https://www.cygwin.com/)
|
|
78
|
+
- [MinGW](http://www.mingw.org/)
|
|
82
79
|
|
|
83
80
|
See their documentation for more information.
|
|
84
81
|
|
|
@@ -124,6 +121,7 @@ If you have installed them globally, just omit the leading `npx`.
|
|
|
124
121
|
Try this for an overview:
|
|
125
122
|
|
|
126
123
|
```shell
|
|
124
|
+
$ npm install --save-deve @esgettext/tools
|
|
127
125
|
$ npx esgettext --help
|
|
128
126
|
```
|
|
129
127
|
|
|
@@ -140,7 +138,7 @@ for more details.
|
|
|
140
138
|
|
|
141
139
|
### Other Commands
|
|
142
140
|
|
|
143
|
-
All other commands should be understandable by their help output.
|
|
141
|
+
All other commands should be understandable by their help output. Try
|
|
144
142
|
`npx esgettext --help` for an overview over all commands, and
|
|
145
143
|
`npx esgettext COMMAND --help` for help for a specific command.
|
|
146
144
|
|
|
@@ -153,18 +151,18 @@ in a configuration file or just in `package.json`.
|
|
|
153
151
|
|
|
154
152
|
Configuration files are checked in this order:
|
|
155
153
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
- esgettext.config.mjs
|
|
155
|
+
- esgettext.config.cjs
|
|
156
|
+
- esgettext.config.js
|
|
157
|
+
- esgettext.config.json
|
|
158
|
+
- package.json
|
|
161
159
|
|
|
162
160
|
The JavaScript versions should have one default export with the configuration.
|
|
163
161
|
The JSON version just defines the configuration. Alteratively, you can add
|
|
164
162
|
a field "esgettext" to your `package.json`.
|
|
165
163
|
|
|
166
164
|
You should always configure `po.locales` with a list of locale identifiers that
|
|
167
|
-
your package supports.
|
|
165
|
+
your package supports. Otherwise, using `esgettext` does not make sense.
|
|
168
166
|
|
|
169
167
|
You should also set `package.textdomain` unless you are happy with the
|
|
170
168
|
default which is just your package name read from `package.json`.
|
|
@@ -173,8 +171,8 @@ All other configuration values have sane defaults.
|
|
|
173
171
|
|
|
174
172
|
### Validation
|
|
175
173
|
|
|
176
|
-
The required format is always the same.
|
|
177
|
-
validated against a schema.
|
|
174
|
+
The required format is always the same. Note that the configuration gets
|
|
175
|
+
validated against a schema. All tools will fail with a validation error if
|
|
178
176
|
you pass an invalid configuration.
|
|
179
177
|
|
|
180
178
|
### Configuration Schema
|
|
@@ -183,7 +181,7 @@ All fields in the configuration are optional because you are always able to
|
|
|
183
181
|
pass them on the command line.
|
|
184
182
|
|
|
185
183
|
Options passed on the command line have higher precedence than options given
|
|
186
|
-
in a configuration file.
|
|
184
|
+
in a configuration file. Options that you define inside a section `esgettext`
|
|
187
185
|
in `package.json` have higher precedence than options that default to
|
|
188
186
|
general fields inside `package.json`.
|
|
189
187
|
|
|
@@ -209,12 +207,12 @@ General information about your package.
|
|
|
209
207
|
##### `package.textdomain`
|
|
210
208
|
|
|
211
209
|
The textdomain of your package, usually something like
|
|
212
|
-
`com.example.YOUR-PACKAGE`.
|
|
210
|
+
`com.example.YOUR-PACKAGE`. You should configure this.
|
|
213
211
|
|
|
214
212
|
##### `package.msgid-bugs-address`
|
|
215
213
|
|
|
216
214
|
An email address or URL where to send bug reports or questions about message
|
|
217
|
-
ids.
|
|
215
|
+
ids. This is added to the respective field in all generated po files.
|
|
218
216
|
|
|
219
217
|
If you omit this field, it will be read from the fields `bugs.email` or
|
|
220
218
|
`bugs.url` (in that order) in `package.json`.
|
|
@@ -228,13 +226,12 @@ If you omit this field, it will be read from the field `name` in
|
|
|
228
226
|
|
|
229
227
|
##### `package.copyright-holder`
|
|
230
228
|
|
|
231
|
-
The copyright holder of your package.
|
|
229
|
+
The copyright holder of your package. This is added as a comment to all
|
|
232
230
|
generated po files.
|
|
233
231
|
|
|
234
232
|
If you omit this field, it will be read from the field `people.author` in
|
|
235
233
|
`package.json`.
|
|
236
234
|
|
|
237
|
-
|
|
238
235
|
##### `package.version`
|
|
239
236
|
|
|
240
237
|
The version of your package.
|
|
@@ -253,7 +250,7 @@ The directory where all translation related files reside, usually 'po'.
|
|
|
253
250
|
|
|
254
251
|
##### `po.locales`
|
|
255
252
|
|
|
256
|
-
An array of locale identifiers.
|
|
253
|
+
An array of locale identifiers. This should always be configured.
|
|
257
254
|
|
|
258
255
|
#### `install`
|
|
259
256
|
|
|
@@ -276,8 +273,8 @@ The path to the `msgmerge` program of your system.
|
|
|
276
273
|
|
|
277
274
|
###### `programs.msgmerge.options`
|
|
278
275
|
|
|
279
|
-
An array of options to pass to the `msgmerge` program.
|
|
280
|
-
without arguments are supported.
|
|
276
|
+
An array of options to pass to the `msgmerge` program. Only boolean options
|
|
277
|
+
without arguments are supported. And you have to omit the leading hyphens,
|
|
281
278
|
for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
282
279
|
|
|
283
280
|
##### `programs.msgfmt`
|
|
@@ -288,8 +285,8 @@ The path to the `msgfmt` program of your system.
|
|
|
288
285
|
|
|
289
286
|
###### `programs.msgfmt.options`
|
|
290
287
|
|
|
291
|
-
An array of options to pass to the `msgmerge` program.
|
|
292
|
-
without arguments are supported.
|
|
288
|
+
An array of options to pass to the `msgmerge` program. Only boolean options
|
|
289
|
+
without arguments are supported. And you have to omit the leading hyphens,
|
|
293
290
|
for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
294
291
|
|
|
295
292
|
## Copyright
|
package/dist/commands/init.js
CHANGED
|
@@ -257,7 +257,7 @@ class Init {
|
|
|
257
257
|
}
|
|
258
258
|
const dependencies = Object.assign(Object.assign({}, pkg.content.dependencies), { '@esgettext/runtime': `^${package_1.Package.getVersion()}` });
|
|
259
259
|
if (this.options.verbose) {
|
|
260
|
-
console.log(gtx._x("Adding package '{package}' version {version} as a development
|
|
260
|
+
console.log(gtx._x("Adding package '{package}' version {version} as a development dependency.", { package: '@esgettext/tools', version: `^${package_1.Package.getVersion()}` }));
|
|
261
261
|
}
|
|
262
262
|
const devDependencies = Object.assign(Object.assign({}, pkg.content.devDependencies), { '@esgettext/tools': `^${package_1.Package.getVersion()}` });
|
|
263
263
|
if (!((_a = pkg.content.devDependencies) === null || _a === void 0 ? void 0 : _a['npm-run-all']) &&
|
|
@@ -312,8 +312,11 @@ class Init {
|
|
|
312
312
|
command: 'npm run esgettext:update-po',
|
|
313
313
|
filename: `${setup.poDirectory}/${setup.textdomain}.pot`,
|
|
314
314
|
}));
|
|
315
|
-
console.log(gtx._x("3) Create a translation file with '{command}' (replace
|
|
315
|
+
console.log(gtx._x("3) Create a translation file with '{command}' (replace" +
|
|
316
|
+
" 'xy' with a language code like 'de' or 'pt_BR'). Get" +
|
|
317
|
+
" more information with '{command2}'", {
|
|
316
318
|
command: `msginit -l xy -i ${setup.poDirectory}/${setup.textdomain}.pot -o po/xy.po`,
|
|
319
|
+
command2: 'npm run esgettext:add-language',
|
|
317
320
|
}));
|
|
318
321
|
console.log(gtx._x('4) Translate the message with a PO editor of your choice.', {
|
|
319
322
|
command: `msginit -l xy -i ${setup.poDirectory}/${setup.textdomain}.pot -o po/xy.po`,
|
|
@@ -390,7 +393,7 @@ class Init {
|
|
|
390
393
|
const parts = candidate.split('/');
|
|
391
394
|
if (!hasTestDir && parts[0].match(/^tests?$/)) {
|
|
392
395
|
if (this.options.verbose) {
|
|
393
|
-
console.log(gtx._x(
|
|
396
|
+
console.log(gtx._x("Looks like you have test files under '{directory}'. We will not translate them.", { directory: parts[0] }));
|
|
394
397
|
}
|
|
395
398
|
exclude.push(`${parts[0]}/*/**`);
|
|
396
399
|
hasTestDir = true;
|
|
@@ -429,8 +432,8 @@ class Init {
|
|
|
429
432
|
options.push(`--exclude="${pattern}"`);
|
|
430
433
|
}
|
|
431
434
|
if (!topLevelDirectories.length) {
|
|
432
|
-
this.error(gtx._x("Warning! Could not find any source files. Will use the pattern './src/**/*.{js,jsx,ts,tsx}
|
|
433
|
-
options.push('"./src/**/*.{js,jsx,ts,tsx}"');
|
|
435
|
+
this.error(gtx._x("Warning! Could not find any source files. Will use the pattern '{pattern}'.", { pattern: './src/**/*.{js,cjs,mjs,jsx,ts,tsx}' }));
|
|
436
|
+
options.push('"./src/**/*.{js,cjs,mjs,jsx,ts,tsx}"');
|
|
434
437
|
}
|
|
435
438
|
else {
|
|
436
439
|
for (const tld in extenders) {
|
|
@@ -447,7 +450,7 @@ class Init {
|
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
452
|
if (this.options.verbose) {
|
|
450
|
-
console.log(gtx._x('Command-line options for extracting source files are: {options}', { options: options.join(' ') }));
|
|
453
|
+
console.log(gtx._x('Command-line options for extracting strings from source files are: {options}', { options: options.join(' ') }));
|
|
451
454
|
}
|
|
452
455
|
return options;
|
|
453
456
|
}
|
|
@@ -505,7 +508,7 @@ class Init {
|
|
|
505
508
|
return resolve(true);
|
|
506
509
|
}
|
|
507
510
|
catch (error) {
|
|
508
|
-
return resolve(gtx._x(
|
|
511
|
+
return resolve(gtx._x("The command '{command}' did not work. Error: {error}.", {
|
|
509
512
|
command,
|
|
510
513
|
error,
|
|
511
514
|
}));
|
|
@@ -550,7 +553,7 @@ class Init {
|
|
|
550
553
|
nonEmpty(answer) {
|
|
551
554
|
return new Promise(resolve => {
|
|
552
555
|
if (answer.trim().length === 0) {
|
|
553
|
-
resolve(gtx._('Please enter
|
|
556
|
+
resolve(gtx._('Please enter at least one character!'));
|
|
554
557
|
}
|
|
555
558
|
else {
|
|
556
559
|
resolve(true);
|
|
@@ -584,7 +587,7 @@ class Init {
|
|
|
584
587
|
return new Promise(resolve => {
|
|
585
588
|
const directory = answer.trim();
|
|
586
589
|
if (directory.length === 0) {
|
|
587
|
-
return resolve(gtx._('Please enter
|
|
590
|
+
return resolve(gtx._('Please enter at least one character!'));
|
|
588
591
|
}
|
|
589
592
|
if (!this.options.force) {
|
|
590
593
|
if (fs.existsSync(directory)) {
|
|
@@ -666,7 +669,7 @@ class Init {
|
|
|
666
669
|
message: gtx._x("(Boolean) options to invoke '{tool}' with", {
|
|
667
670
|
tool: 'msgmerge',
|
|
668
671
|
}),
|
|
669
|
-
default: '--
|
|
672
|
+
default: '--update --previous',
|
|
670
673
|
}),
|
|
671
674
|
msgfmt: yield (0, prompts_1.input)({
|
|
672
675
|
message: gtx._x("The '{tool}' program to use:", { tool: 'msgfmt' }),
|
|
@@ -674,7 +677,9 @@ class Init {
|
|
|
674
677
|
validate: answer => this.checkTool(answer),
|
|
675
678
|
}),
|
|
676
679
|
msgfmtOptions: yield (0, prompts_1.input)({
|
|
677
|
-
message: gtx._x("
|
|
680
|
+
message: gtx._x("(Boolean) options to invoke '{tool}' with", {
|
|
681
|
+
tool: 'msgfmt',
|
|
682
|
+
}),
|
|
678
683
|
default: '--check --statistics --verbose',
|
|
679
684
|
}),
|
|
680
685
|
poDirectory: yield (0, prompts_1.input)({
|
package/dist/commands/install.js
CHANGED
|
@@ -79,14 +79,16 @@ class MsgfmtAll {
|
|
|
79
79
|
},
|
|
80
80
|
msgfmt: {
|
|
81
81
|
type: 'string',
|
|
82
|
-
describe: gtx.
|
|
82
|
+
describe: gtx._x("'{program}' program if not in $PATH", {
|
|
83
|
+
program: 'msgfmt',
|
|
84
|
+
}),
|
|
83
85
|
default: (_f = (_e = (_d = this.configuration.programs) === null || _d === void 0 ? void 0 : _d.msgfmt) === null || _e === void 0 ? void 0 : _e.path) !== null && _f !== void 0 ? _f : 'msgfmt',
|
|
84
86
|
group: gtx._('Mode of operation:'),
|
|
85
87
|
},
|
|
86
88
|
options: {
|
|
87
89
|
multi: true,
|
|
88
90
|
type: 'string',
|
|
89
|
-
describe: gtx._x("Options to pass to '{program}' program (without hyphens)", { program: 'msgfmt' }),
|
|
91
|
+
describe: gtx._x("Options to pass to '{program}' program (without leading hyphens)", { program: 'msgfmt' }),
|
|
90
92
|
default: ((_h = (_g = this.configuration.programs) === null || _g === void 0 ? void 0 : _g.msgfmt) === null || _h === void 0 ? void 0 : _h.options) || [
|
|
91
93
|
'check',
|
|
92
94
|
'statistics',
|
|
@@ -151,7 +153,7 @@ class MsgfmtAll {
|
|
|
151
153
|
if (options) {
|
|
152
154
|
options.forEach(name => {
|
|
153
155
|
if (name.substring(0, 1) === '-') {
|
|
154
|
-
console.error(gtx._x("{programName}: option '{option}': Options passed to '{program}' must
|
|
156
|
+
console.error(gtx._x("{programName}: option '{option}': Options passed to '{program}' must be given without leading hyphens", {
|
|
155
157
|
programName: package_1.Package.getName(),
|
|
156
158
|
program: 'msgfmt',
|
|
157
159
|
option: name,
|
|
@@ -89,14 +89,16 @@ class MsgmergeAll {
|
|
|
89
89
|
},
|
|
90
90
|
msgmerge: {
|
|
91
91
|
type: 'string',
|
|
92
|
-
describe: gtx.
|
|
92
|
+
describe: gtx._x("'{program}' program if not in $PATH", {
|
|
93
|
+
program: 'msgmerge',
|
|
94
|
+
}),
|
|
93
95
|
default: (_f = (_e = (_d = this.configuration.programs) === null || _d === void 0 ? void 0 : _d.msgmerge) === null || _e === void 0 ? void 0 : _e.path) !== null && _f !== void 0 ? _f : 'msgmerge',
|
|
94
96
|
group: gtx._('Mode of operation:'),
|
|
95
97
|
},
|
|
96
98
|
options: {
|
|
97
99
|
multi: true,
|
|
98
100
|
type: 'string',
|
|
99
|
-
describe: gtx._x("Options to pass to '{program}' program (without hyphens)", { program: 'msgmerge' }),
|
|
101
|
+
describe: gtx._x("Options to pass to '{program}' program (without leading hyphens)", { program: 'msgmerge' }),
|
|
100
102
|
default: (_h = (_g = this.configuration.programs) === null || _g === void 0 ? void 0 : _g.msgmerge) === null || _h === void 0 ? void 0 : _h.options,
|
|
101
103
|
group: gtx._('Mode of operation:'),
|
|
102
104
|
},
|
|
@@ -163,7 +165,7 @@ class MsgmergeAll {
|
|
|
163
165
|
if (options) {
|
|
164
166
|
options.forEach(name => {
|
|
165
167
|
if (name.substring(0, 1) === '-') {
|
|
166
|
-
console.error(gtx._x("{programName}: option '{option}': Options passed to '{program}' must
|
|
168
|
+
console.error(gtx._x("{programName}: option '{option}': Options passed to '{program}' must be given without leading hyphens", {
|
|
167
169
|
programName: package_1.Package.getName(),
|
|
168
170
|
program: 'msgfmt',
|
|
169
171
|
option: name,
|
|
@@ -89,7 +89,7 @@ class XGettext {
|
|
|
89
89
|
group: gtx._('Output file location:'),
|
|
90
90
|
alias: 'p',
|
|
91
91
|
type: 'string',
|
|
92
|
-
describe: gtx._('output files will be placed in directory
|
|
92
|
+
describe: gtx._('output files will be placed in the specified directory. If output file is -, output is written to standard output.'),
|
|
93
93
|
default: (_d = (_c = this.configuration.po) === null || _c === void 0 ? void 0 : _c.directory) !== null && _d !== void 0 ? _d : '.',
|
|
94
94
|
},
|
|
95
95
|
language: {
|
|
@@ -107,27 +107,27 @@ class XGettext {
|
|
|
107
107
|
default: 'ASCII',
|
|
108
108
|
},
|
|
109
109
|
'join-existing': {
|
|
110
|
-
group: gtx._('
|
|
110
|
+
group: gtx._('Mode of operation:'),
|
|
111
111
|
alias: 'j',
|
|
112
112
|
type: 'boolean',
|
|
113
113
|
describe: gtx._('join messages with existing file'),
|
|
114
114
|
},
|
|
115
115
|
'exclude-file': {
|
|
116
116
|
multi: true,
|
|
117
|
-
group: gtx._('
|
|
117
|
+
group: gtx._('Mode of operation:'),
|
|
118
118
|
alias: 'x',
|
|
119
119
|
type: 'string',
|
|
120
|
-
describe: gtx._('entries from
|
|
120
|
+
describe: gtx._('entries from this po file are not extracted'),
|
|
121
121
|
},
|
|
122
122
|
'add-comments': {
|
|
123
123
|
multi: true,
|
|
124
|
-
group: gtx._('
|
|
124
|
+
group: gtx._('Mode of operation:'),
|
|
125
125
|
alias: 'c',
|
|
126
126
|
type: 'string',
|
|
127
|
-
describe: gtx._('place comment blocks starting with
|
|
127
|
+
describe: gtx._('place comment blocks starting with this string and preceding keyword lines in output file'),
|
|
128
128
|
},
|
|
129
129
|
'add-all-comments': {
|
|
130
|
-
group: gtx._('
|
|
130
|
+
group: gtx._('Mode of operation:'),
|
|
131
131
|
describe: gtx._('place all comment blocks preceding keyword lines in output file'),
|
|
132
132
|
type: 'boolean',
|
|
133
133
|
},
|
|
@@ -141,7 +141,7 @@ class XGettext {
|
|
|
141
141
|
multi: true,
|
|
142
142
|
group: gtx._('Language specific options:'),
|
|
143
143
|
type: 'string',
|
|
144
|
-
describe: gtx._('look for
|
|
144
|
+
describe: gtx._('look for this word as an additional keyword'),
|
|
145
145
|
},
|
|
146
146
|
flag: {
|
|
147
147
|
multi: true,
|
|
@@ -153,7 +153,7 @@ class XGettext {
|
|
|
153
153
|
multi: true,
|
|
154
154
|
group: gtx._('Language specific options:'),
|
|
155
155
|
type: 'string',
|
|
156
|
-
describe: gtx._('only
|
|
156
|
+
describe: gtx._('only search for method calls of specified instance names'),
|
|
157
157
|
},
|
|
158
158
|
'force-po': {
|
|
159
159
|
group: gtx._('Output details:'),
|
|
@@ -177,7 +177,7 @@ class XGettext {
|
|
|
177
177
|
group: gtx._('Output details:'),
|
|
178
178
|
alias: 's',
|
|
179
179
|
type: 'boolean',
|
|
180
|
-
describe: gtx._('generate sorted output'),
|
|
180
|
+
describe: gtx._('generate sorted output (deprecated)'),
|
|
181
181
|
},
|
|
182
182
|
'sort-by-file': {
|
|
183
183
|
group: gtx._('Output details:'),
|
|
@@ -223,13 +223,13 @@ class XGettext {
|
|
|
223
223
|
group: gtx._('Output details:'),
|
|
224
224
|
alias: 'm',
|
|
225
225
|
type: 'string',
|
|
226
|
-
describe: gtx._('use
|
|
226
|
+
describe: gtx._('use this string or "" as prefix for msgstr values'),
|
|
227
227
|
},
|
|
228
228
|
'msgstr-suffix': {
|
|
229
229
|
group: gtx._('Output details:'),
|
|
230
230
|
alias: 'M',
|
|
231
231
|
type: 'string',
|
|
232
|
-
describe: gtx._('use
|
|
232
|
+
describe: gtx._('use this string or "" as suffix for msgstr values'),
|
|
233
233
|
},
|
|
234
234
|
verbose: {
|
|
235
235
|
alias: 'V',
|
|
@@ -303,7 +303,7 @@ class XGettext {
|
|
|
303
303
|
}
|
|
304
304
|
if (this.options.joinExisting) {
|
|
305
305
|
if (this.options.output === '-') {
|
|
306
|
-
console.error(gtx._x(
|
|
306
|
+
console.error(gtx._x("{programName}: Error: '--join-existing'" +
|
|
307
307
|
' cannot be used, when output is written to stdout', {
|
|
308
308
|
programName: this.options.$0,
|
|
309
309
|
}));
|
|
@@ -432,16 +432,16 @@ class XGettext {
|
|
|
432
432
|
default:
|
|
433
433
|
if ('-' === filename) {
|
|
434
434
|
this.warn(gtx._('language for standard input is unknown without' +
|
|
435
|
-
' option "--language"; will try
|
|
435
|
+
' option "--language"; will try TypeScript'));
|
|
436
436
|
}
|
|
437
437
|
else {
|
|
438
438
|
this.warn(gtx._x('file "{filename}" extension "{extname}"' +
|
|
439
|
-
' is unknown; will try
|
|
439
|
+
' is unknown; will try TypeScript instead', {
|
|
440
440
|
filename,
|
|
441
441
|
extname: ext,
|
|
442
442
|
}));
|
|
443
443
|
}
|
|
444
|
-
parser = new
|
|
444
|
+
parser = new typescript_1.TypeScriptParser(this.catalog, parserOptions);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
447
|
return parser;
|
package/dist/configuration.js
CHANGED
|
@@ -46,8 +46,16 @@ require("@valibot/i18n/de");
|
|
|
46
46
|
const package_1 = require("./package");
|
|
47
47
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
48
48
|
const bugsAddressSchema = v.union([
|
|
49
|
-
v.pipe(v.string(), v.nonEmpty(gtx.
|
|
50
|
-
|
|
49
|
+
v.pipe(v.string(), v.nonEmpty(gtx._x("The field '{field}' must not be empty!", {
|
|
50
|
+
field: 'msgid-bugs-address',
|
|
51
|
+
})), v.email(gtx._x("The field '{field}' must contain a valid email address or URL!", {
|
|
52
|
+
field: 'msgid-bugs-address',
|
|
53
|
+
}))),
|
|
54
|
+
v.pipe(v.string(), v.nonEmpty(gtx._x("The field '{field}' must not be empty!", {
|
|
55
|
+
field: 'msgid-bugs-address',
|
|
56
|
+
})), v.url(gtx._x("The field '{field}' must contain a valid email address or URL!", {
|
|
57
|
+
field: 'msgid-bugs-address',
|
|
58
|
+
}))),
|
|
51
59
|
]);
|
|
52
60
|
const programSchema = (program) => {
|
|
53
61
|
return v.strictObject({
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
3
26
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
27
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
28
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
37
|
};
|
|
15
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
39
|
const yargs_1 = __importDefault(require("yargs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
17
41
|
const package_js_1 = require("./package.js");
|
|
18
42
|
const runtime_1 = require("@esgettext/runtime");
|
|
19
43
|
const configuration_js_1 = require("./configuration.js");
|
|
@@ -38,13 +62,21 @@ const commandNames = [
|
|
|
38
62
|
const configFiles = locateConfigFiles();
|
|
39
63
|
const pkgJsonFile = locatePkgJsonFile();
|
|
40
64
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
65
|
+
runtime_1.Textdomain.locale = runtime_1.Textdomain.selectLocale([
|
|
66
|
+
'en-AU',
|
|
67
|
+
'en-US',
|
|
68
|
+
'en-GB',
|
|
69
|
+
'en-NZ',
|
|
70
|
+
'de',
|
|
71
|
+
]);
|
|
72
|
+
const localePath = path.join(__dirname, 'locale');
|
|
73
|
+
gtx.bindtextdomain(localePath);
|
|
41
74
|
gtx
|
|
42
75
|
.resolve()
|
|
43
76
|
.then(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
77
|
var _a;
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const configuration = yield configuration_js_1.ConfigurationFactory.create(configFiles, pkgJsonFile, locale);
|
|
78
|
+
const ulocale = runtime_1.Textdomain.locale.replace('-', '_');
|
|
79
|
+
const configuration = yield configuration_js_1.ConfigurationFactory.create(configFiles, pkgJsonFile, runtime_1.Textdomain.locale);
|
|
48
80
|
if (!configuration)
|
|
49
81
|
process.exit(1);
|
|
50
82
|
const commands = {
|
|
@@ -74,7 +106,7 @@ gtx
|
|
|
74
106
|
default: 'package.json',
|
|
75
107
|
},
|
|
76
108
|
})
|
|
77
|
-
.showHelpOnFail(false, gtx._x("Try {programName}
|
|
109
|
+
.showHelpOnFail(false, gtx._x("Try '{programName} --help' for more information!", {
|
|
78
110
|
programName: package_js_1.Package.getName(),
|
|
79
111
|
}))
|
|
80
112
|
.demandCommand(1, gtx._('Error: No command given.'))
|
package/dist/optspec.js
CHANGED
|
@@ -18,7 +18,7 @@ function coerceOptions(args, optspecs) {
|
|
|
18
18
|
else {
|
|
19
19
|
if (isArray) {
|
|
20
20
|
console.error(gtx._x('{programName}: Error: The option' +
|
|
21
|
-
'
|
|
21
|
+
" '{optname}' cannot be specified more than once!", { programName: package_1.Package.getName(), optname }));
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
}
|
package/dist/package.js
CHANGED
|
@@ -11,8 +11,7 @@ class JavaScriptParser extends parser_2.Parser {
|
|
|
11
11
|
allowReturnOutsideFunction: true,
|
|
12
12
|
allowSuperOutsideMethod: true,
|
|
13
13
|
allowUndeclaredExports: true,
|
|
14
|
-
|
|
15
|
-
// errorRecovery: true,
|
|
14
|
+
errorRecovery: true,
|
|
16
15
|
sourceFilename: filename,
|
|
17
16
|
plugins: [
|
|
18
17
|
'flow',
|
|
@@ -11,8 +11,7 @@ class TypeScriptParser extends parser_2.Parser {
|
|
|
11
11
|
allowReturnOutsideFunction: true,
|
|
12
12
|
allowSuperOutsideMethod: true,
|
|
13
13
|
allowUndeclaredExports: true,
|
|
14
|
-
|
|
15
|
-
// errorRecovery: true,
|
|
14
|
+
errorRecovery: true,
|
|
16
15
|
sourceFilename: filename,
|
|
17
16
|
plugins: [
|
|
18
17
|
'typescript',
|
package/dist/pot/entry.js
CHANGED
|
@@ -21,19 +21,23 @@ class POTEntry {
|
|
|
21
21
|
constructor(properties) {
|
|
22
22
|
this.properties = properties;
|
|
23
23
|
if (/[\u0000-\u0006\u000e-\u001f]/.exec(properties.msgid)) {
|
|
24
|
-
throw new Error(gtx.
|
|
24
|
+
throw new Error(gtx._x("Section '{section}' must not contain control characters.", {
|
|
25
|
+
section: 'msgid',
|
|
26
|
+
}));
|
|
25
27
|
}
|
|
26
28
|
if (typeof this.properties.msgidPlural !== 'undefined') {
|
|
27
29
|
if (/[\u0000-\u0006\u000e-\u001f]/.exec(properties.msgidPlural)) {
|
|
28
|
-
throw new Error(gtx.
|
|
30
|
+
throw new Error(gtx._x("Section '{section}' must not contain control characters.", {
|
|
31
|
+
section: 'msgid_plural',
|
|
32
|
+
}));
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
if (this.properties.msgid === '' &&
|
|
32
36
|
(typeof this.properties.msgctxt === 'undefined' ||
|
|
33
37
|
this.properties.msgctxt === '')) {
|
|
34
38
|
this.warning(gtx._('Empty msgid. It is reserved by esgettext.\n' +
|
|
35
|
-
"Calling gettext('
|
|
36
|
-
'entry with meta information, not the empty ' +
|
|
39
|
+
"Calling 'gettext()' with an empty msgid returns the " +
|
|
40
|
+
' header entry with meta information, not the empty ' +
|
|
37
41
|
'string.\n' +
|
|
38
42
|
'Consider adding a message context, if this ' +
|
|
39
43
|
'is done intentionally.'));
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esgettext/tools",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Gettext-like po creation and manipulation",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"gettext",
|
|
7
|
+
"po parser",
|
|
8
|
+
"create po"
|
|
9
|
+
],
|
|
5
10
|
"publishConfig": {
|
|
6
11
|
"access": "public"
|
|
7
12
|
},
|
|
@@ -26,7 +31,7 @@
|
|
|
26
31
|
"prebuild": "node ./write-package.mjs >src/package.ts",
|
|
27
32
|
"prepublishOnly": "npm run build",
|
|
28
33
|
"check:clean": "../../check-clean",
|
|
29
|
-
"format": "prettier --write 'src/**/*.ts'",
|
|
34
|
+
"format": "prettier --write 'src/**/*.ts' *.mjs *.json",
|
|
30
35
|
"watch": "tsc --watch",
|
|
31
36
|
"prewatch": "node ./write-package.mjs >src/package.ts",
|
|
32
37
|
"clean": "rimraf ./dist",
|
|
@@ -39,7 +44,14 @@
|
|
|
39
44
|
"test:watch": "jest --watch",
|
|
40
45
|
"test:cov": "jest --coverage",
|
|
41
46
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
42
|
-
"typedoc": "echo nothing to do"
|
|
47
|
+
"typedoc": "echo nothing to do",
|
|
48
|
+
"esgettext": "npm-run-all esgettext:potfiles esgettext:extract esgettext:update-po esgettext:update-mo esgettext:install",
|
|
49
|
+
"esgettext:potfiles": "node --import=tsx src/index.ts potfiles --directory=po --git --exclude=\"dist/**/*\" --exclude=\"node_modules/**/*\" --exclude=\"**/*.spec.*\" \"./src/**/*.ts\" >po/POTFILES",
|
|
50
|
+
"esgettext:extract": "node --import=tsx src/index.ts extract --directory po --files-from=po/POTFILES --from-code='utf-8'",
|
|
51
|
+
"esgettext:update-po": "node --import=tsx src/index.ts msgmerge-all",
|
|
52
|
+
"esgettext:update-mo": "node --import=tsx src/index.ts msgfmt-all",
|
|
53
|
+
"esgettext:install": "node --import=tsx src/index.ts install",
|
|
54
|
+
"esgettext:addlang": "node --import=tsx src/index.ts msginit"
|
|
43
55
|
},
|
|
44
56
|
"author": "Guido Flohr <guido.flohr@cantanea.com> (http://www.guido.flohr.net/)",
|
|
45
57
|
"license": "WTFPL",
|
|
@@ -70,6 +82,7 @@
|
|
|
70
82
|
},
|
|
71
83
|
"devDependencies": {
|
|
72
84
|
"@babel/types": "^7.24.7",
|
|
85
|
+
"@esgettext/tools": "^1.3.1",
|
|
73
86
|
"@eslint/config-array": "^0.16.0",
|
|
74
87
|
"@humanwhocodes/retry": "^0.3.0",
|
|
75
88
|
"@tsconfig/recommended": "^1.0.6",
|
|
@@ -91,7 +104,7 @@
|
|
|
91
104
|
"dependencies": {
|
|
92
105
|
"@babel/parser": "^7.24.7",
|
|
93
106
|
"@babel/traverse": "^7.24.7",
|
|
94
|
-
"@esgettext/runtime": "^1.3.
|
|
107
|
+
"@esgettext/runtime": "^1.3.2",
|
|
95
108
|
"@inquirer/prompts": "^5.0.6",
|
|
96
109
|
"@npmcli/package-json": "^5.2.0",
|
|
97
110
|
"@valibot/i18n": "^0.15.0",
|
|
@@ -101,5 +114,5 @@
|
|
|
101
114
|
"valibot": "^0.31.1",
|
|
102
115
|
"yargs": "^17.7.2"
|
|
103
116
|
},
|
|
104
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "26c7da76d48c0e0e2d6021ed3e8fd5939417895f"
|
|
105
118
|
}
|