@esgettext/tools 1.3.3 → 1.3.5
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 +50 -50
- package/dist/commands/add-language.js +17 -7
- package/dist/commands/convert.js +25 -11
- package/dist/commands/init.js +17 -7
- package/dist/commands/install.js +23 -11
- package/dist/commands/msgfmt-all.js +17 -7
- package/dist/commands/msgmerge-all.js +17 -7
- package/dist/commands/xgettext.js +21 -8
- package/dist/configuration.js +17 -7
- package/dist/index.js +17 -7
- package/dist/optspec.js +1 -2
- package/dist/package.js +1 -1
- package/dist/parser/javascript.js +1 -0
- package/dist/parser/parser.js +69 -7
- package/dist/parser/typescript.js +1 -0
- package/dist/pot/entry.js +1 -1
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -7,37 +7,37 @@ The package also contains code for parsing po files and for writing them.
|
|
|
7
7
|
## Table of Contents <!-- omit in toc -->
|
|
8
8
|
|
|
9
9
|
- [Prerequisites](#prerequisites)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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)
|
|
15
15
|
- [Installation](#installation)
|
|
16
16
|
- [The Tools](#the-tools)
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
- [`esgettext xgettext`](#esgettext-xgettext)
|
|
18
|
+
- [Other Commands](#other-commands)
|
|
19
19
|
- [Configuration](#configuration)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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)
|
|
41
41
|
- [Copyright](#copyright)
|
|
42
42
|
|
|
43
43
|
## Prerequisites
|
|
@@ -47,7 +47,7 @@ tools. If the command `xgettext --version` outputs some kind of version
|
|
|
47
47
|
information, you are most probably set. Otherwise check the information for
|
|
48
48
|
your platform below.
|
|
49
49
|
|
|
50
|
-
### Un
|
|
50
|
+
### Un*x/Linux
|
|
51
51
|
|
|
52
52
|
Use the package manager of your vendor to search for something like
|
|
53
53
|
"gettext-tools" or just "gettext" and install it. The gettext tools are
|
|
@@ -74,8 +74,8 @@ $ brew install gettext
|
|
|
74
74
|
|
|
75
75
|
The options that I know of are
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
* [Cygwin](https://www.cygwin.com/)
|
|
78
|
+
* [MinGW](http://www.mingw.org/)
|
|
79
79
|
|
|
80
80
|
See their documentation for more information.
|
|
81
81
|
|
|
@@ -121,7 +121,6 @@ If you have installed them globally, just omit the leading `npx`.
|
|
|
121
121
|
Try this for an overview:
|
|
122
122
|
|
|
123
123
|
```shell
|
|
124
|
-
$ npm install --save-deve @esgettext/tools
|
|
125
124
|
$ npx esgettext --help
|
|
126
125
|
```
|
|
127
126
|
|
|
@@ -138,7 +137,7 @@ for more details.
|
|
|
138
137
|
|
|
139
138
|
### Other Commands
|
|
140
139
|
|
|
141
|
-
All other commands should be understandable by their help output.
|
|
140
|
+
All other commands should be understandable by their help output. Try
|
|
142
141
|
`npx esgettext --help` for an overview over all commands, and
|
|
143
142
|
`npx esgettext COMMAND --help` for help for a specific command.
|
|
144
143
|
|
|
@@ -151,18 +150,18 @@ in a configuration file or just in `package.json`.
|
|
|
151
150
|
|
|
152
151
|
Configuration files are checked in this order:
|
|
153
152
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
* esgettext.config.mjs
|
|
154
|
+
* esgettext.config.cjs
|
|
155
|
+
* esgettext.config.js
|
|
156
|
+
* esgettext.config.json
|
|
157
|
+
* package.json
|
|
159
158
|
|
|
160
159
|
The JavaScript versions should have one default export with the configuration.
|
|
161
160
|
The JSON version just defines the configuration. Alteratively, you can add
|
|
162
161
|
a field "esgettext" to your `package.json`.
|
|
163
162
|
|
|
164
163
|
You should always configure `po.locales` with a list of locale identifiers that
|
|
165
|
-
your package supports.
|
|
164
|
+
your package supports. Otherwise, using `esgettext` does not make sense.
|
|
166
165
|
|
|
167
166
|
You should also set `package.textdomain` unless you are happy with the
|
|
168
167
|
default which is just your package name read from `package.json`.
|
|
@@ -171,8 +170,8 @@ All other configuration values have sane defaults.
|
|
|
171
170
|
|
|
172
171
|
### Validation
|
|
173
172
|
|
|
174
|
-
The required format is always the same.
|
|
175
|
-
validated against a schema.
|
|
173
|
+
The required format is always the same. Note that the configuration gets
|
|
174
|
+
validated against a schema. All tools will fail with a validation error if
|
|
176
175
|
you pass an invalid configuration.
|
|
177
176
|
|
|
178
177
|
### Configuration Schema
|
|
@@ -181,7 +180,7 @@ All fields in the configuration are optional because you are always able to
|
|
|
181
180
|
pass them on the command line.
|
|
182
181
|
|
|
183
182
|
Options passed on the command line have higher precedence than options given
|
|
184
|
-
in a configuration file.
|
|
183
|
+
in a configuration file. Options that you define inside a section `esgettext`
|
|
185
184
|
in `package.json` have higher precedence than options that default to
|
|
186
185
|
general fields inside `package.json`.
|
|
187
186
|
|
|
@@ -207,12 +206,12 @@ General information about your package.
|
|
|
207
206
|
##### `package.textdomain`
|
|
208
207
|
|
|
209
208
|
The textdomain of your package, usually something like
|
|
210
|
-
`com.example.YOUR-PACKAGE`.
|
|
209
|
+
`com.example.YOUR-PACKAGE`. You should configure this.
|
|
211
210
|
|
|
212
211
|
##### `package.msgid-bugs-address`
|
|
213
212
|
|
|
214
213
|
An email address or URL where to send bug reports or questions about message
|
|
215
|
-
ids.
|
|
214
|
+
ids. This is added to the respective field in all generated po files.
|
|
216
215
|
|
|
217
216
|
If you omit this field, it will be read from the fields `bugs.email` or
|
|
218
217
|
`bugs.url` (in that order) in `package.json`.
|
|
@@ -226,12 +225,13 @@ If you omit this field, it will be read from the field `name` in
|
|
|
226
225
|
|
|
227
226
|
##### `package.copyright-holder`
|
|
228
227
|
|
|
229
|
-
The copyright holder of your package.
|
|
228
|
+
The copyright holder of your package. This is added as a comment to all
|
|
230
229
|
generated po files.
|
|
231
230
|
|
|
232
231
|
If you omit this field, it will be read from the field `people.author` in
|
|
233
232
|
`package.json`.
|
|
234
233
|
|
|
234
|
+
|
|
235
235
|
##### `package.version`
|
|
236
236
|
|
|
237
237
|
The version of your package.
|
|
@@ -250,7 +250,7 @@ The directory where all translation related files reside, usually 'po'.
|
|
|
250
250
|
|
|
251
251
|
##### `po.locales`
|
|
252
252
|
|
|
253
|
-
An array of locale identifiers.
|
|
253
|
+
An array of locale identifiers. This should always be configured.
|
|
254
254
|
|
|
255
255
|
#### `install`
|
|
256
256
|
|
|
@@ -273,8 +273,8 @@ The path to the `msgmerge` program of your system.
|
|
|
273
273
|
|
|
274
274
|
###### `programs.msgmerge.options`
|
|
275
275
|
|
|
276
|
-
An array of options to pass to the `msgmerge` program.
|
|
277
|
-
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,
|
|
278
278
|
for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
279
279
|
|
|
280
280
|
##### `programs.msgfmt`
|
|
@@ -285,8 +285,8 @@ The path to the `msgfmt` program of your system.
|
|
|
285
285
|
|
|
286
286
|
###### `programs.msgfmt.options`
|
|
287
287
|
|
|
288
|
-
An array of options to pass to the `msgmerge` program.
|
|
289
|
-
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,
|
|
290
290
|
for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
291
291
|
|
|
292
292
|
## Copyright
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.AddLanguage = void 0;
|
|
27
37
|
const path = __importStar(require("path"));
|
package/dist/commands/convert.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.Convert = void 0;
|
|
27
37
|
const fs = __importStar(require("fs"));
|
|
@@ -116,16 +126,17 @@ class Convert {
|
|
|
116
126
|
console.error(gtx._x('Detected output format {outputFormat}.', { outputFormat }));
|
|
117
127
|
}
|
|
118
128
|
try {
|
|
119
|
-
const
|
|
129
|
+
const buffer = this.readInput(input);
|
|
130
|
+
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
120
131
|
let catalog;
|
|
121
132
|
switch (options.inputFormat) {
|
|
122
133
|
case 'mo.json':
|
|
123
|
-
catalog = (0, runtime_1.parseMoJsonCatalog)(
|
|
134
|
+
catalog = (0, runtime_1.parseMoJsonCatalog)(arrayBuffer);
|
|
124
135
|
break;
|
|
125
136
|
case 'mo':
|
|
126
137
|
case 'gmo':
|
|
127
138
|
default:
|
|
128
|
-
catalog = (0, runtime_1.parseMoCatalog)(
|
|
139
|
+
catalog = (0, runtime_1.parseMoCatalog)(arrayBuffer);
|
|
129
140
|
break;
|
|
130
141
|
}
|
|
131
142
|
const converted = this.convert(catalog, input, outputFormat);
|
|
@@ -135,7 +146,10 @@ class Convert {
|
|
|
135
146
|
this.output(output, converted);
|
|
136
147
|
}
|
|
137
148
|
catch (e) {
|
|
138
|
-
console.error(gtx._x('{programName}: Error: {e}'
|
|
149
|
+
console.error(gtx._x('{programName}: Error: {e}', {
|
|
150
|
+
programName: package_1.Package.getName(),
|
|
151
|
+
e,
|
|
152
|
+
}));
|
|
139
153
|
return resolve(1);
|
|
140
154
|
}
|
|
141
155
|
return resolve(0);
|
package/dist/commands/init.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/dist/commands/install.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.Install = void 0;
|
|
27
37
|
const fs_1 = require("fs");
|
|
@@ -182,8 +192,9 @@ class Install {
|
|
|
182
192
|
outFile,
|
|
183
193
|
}));
|
|
184
194
|
}
|
|
185
|
-
const
|
|
186
|
-
const
|
|
195
|
+
const buffer = (0, fs_1.readFileSync)(inFile);
|
|
196
|
+
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
197
|
+
const catalog = (0, runtime_1.parseMoCatalog)(arrayBuffer);
|
|
187
198
|
const json = JSON.stringify(catalog);
|
|
188
199
|
(0, fs_1.writeFile)(outFile, json, err => {
|
|
189
200
|
if (err) {
|
|
@@ -207,8 +218,9 @@ class Install {
|
|
|
207
218
|
outFile,
|
|
208
219
|
}));
|
|
209
220
|
}
|
|
210
|
-
const
|
|
211
|
-
const
|
|
221
|
+
const buffer = (0, fs_1.readFileSync)(inFile);
|
|
222
|
+
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
223
|
+
const catalog = (0, runtime_1.parseMoCatalog)(arrayBuffer);
|
|
212
224
|
const msgs = {};
|
|
213
225
|
for (const msgid in catalog.entries) {
|
|
214
226
|
const msgstr = catalog.entries[msgid];
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.XGettext = void 0;
|
|
27
37
|
const fs_1 = require("fs");
|
|
@@ -238,7 +248,6 @@ class XGettext {
|
|
|
238
248
|
},
|
|
239
249
|
};
|
|
240
250
|
}
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
242
251
|
additional(argv) {
|
|
243
252
|
argv.positional(gtx._('INPUTFILE'), {
|
|
244
253
|
type: 'string',
|
|
@@ -404,6 +413,7 @@ class XGettext {
|
|
|
404
413
|
try {
|
|
405
414
|
const fullName = resolve(directories[i], filename);
|
|
406
415
|
return (0, fs_1.readFileSync)(fullName);
|
|
416
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
407
417
|
}
|
|
408
418
|
catch (e) {
|
|
409
419
|
/* ignore */
|
|
@@ -539,6 +549,9 @@ class XGettext {
|
|
|
539
549
|
});
|
|
540
550
|
parserOptions.keyword = cookedKeywords;
|
|
541
551
|
}
|
|
552
|
+
if (this.options.instance) {
|
|
553
|
+
parserOptions.instance = this.options.instance;
|
|
554
|
+
}
|
|
542
555
|
return parserOptions;
|
|
543
556
|
}
|
|
544
557
|
}
|
package/dist/configuration.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/dist/index.js
CHANGED
|
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/dist/optspec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coerceOptions =
|
|
3
|
+
exports.coerceOptions = coerceOptions;
|
|
4
4
|
const runtime_1 = require("@esgettext/runtime");
|
|
5
5
|
const package_1 = require("./package");
|
|
6
6
|
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
@@ -25,4 +25,3 @@ function coerceOptions(args, optspecs) {
|
|
|
25
25
|
}
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
|
-
exports.coerceOptions = coerceOptions;
|
package/dist/package.js
CHANGED
package/dist/parser/parser.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -30,6 +40,8 @@ exports.Parser = void 0;
|
|
|
30
40
|
const iconv_lite_1 = require("iconv-lite");
|
|
31
41
|
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
32
42
|
const t = __importStar(require("@babel/types"));
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
33
45
|
const runtime_1 = require("@esgettext/runtime");
|
|
34
46
|
const entry_1 = require("../pot/entry");
|
|
35
47
|
const keyword_1 = require("../pot/keyword");
|
|
@@ -361,6 +373,12 @@ class Parser {
|
|
|
361
373
|
instance.push(me.property.name);
|
|
362
374
|
return this.methodFromMemberExpression(me.object, instance);
|
|
363
375
|
}
|
|
376
|
+
else if (t.isThisExpression(me.object) &&
|
|
377
|
+
t.isIdentifier(me.property) &&
|
|
378
|
+
!me.computed) {
|
|
379
|
+
instance.push(me.property.name);
|
|
380
|
+
return instance[0];
|
|
381
|
+
}
|
|
364
382
|
else if (t.isMemberExpression(me.object) &&
|
|
365
383
|
t.isLiteral(me.property) &&
|
|
366
384
|
me.computed) {
|
|
@@ -368,6 +386,12 @@ class Parser {
|
|
|
368
386
|
instance.push(this.literalValue(me.property));
|
|
369
387
|
return this.methodFromMemberExpression(me.object, instance);
|
|
370
388
|
}
|
|
389
|
+
else if (t.isThisExpression(me.object) &&
|
|
390
|
+
t.isLiteral(me.property) &&
|
|
391
|
+
me.computed) {
|
|
392
|
+
instance.push(this.literalValue(me.property));
|
|
393
|
+
return instance[0];
|
|
394
|
+
}
|
|
371
395
|
else {
|
|
372
396
|
return null;
|
|
373
397
|
}
|
|
@@ -606,5 +630,43 @@ class Parser {
|
|
|
606
630
|
}
|
|
607
631
|
return null;
|
|
608
632
|
}
|
|
633
|
+
getSourceTypeFromPackageJson(filename) {
|
|
634
|
+
const packageJsonPath = this.findPackageJson(filename);
|
|
635
|
+
if (packageJsonPath === null)
|
|
636
|
+
return 'script';
|
|
637
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
638
|
+
if (packageJson.type === 'module') {
|
|
639
|
+
return 'module';
|
|
640
|
+
}
|
|
641
|
+
return 'script';
|
|
642
|
+
}
|
|
643
|
+
getSourceType(filename) {
|
|
644
|
+
const extname = path.extname(filename).toLowerCase();
|
|
645
|
+
switch (extname) {
|
|
646
|
+
case '.js':
|
|
647
|
+
case '.ts':
|
|
648
|
+
case '.jsx':
|
|
649
|
+
case '.tsx':
|
|
650
|
+
return this.getSourceTypeFromPackageJson(filename);
|
|
651
|
+
case '.mjs':
|
|
652
|
+
return 'module';
|
|
653
|
+
case '.cjs':
|
|
654
|
+
return 'script';
|
|
655
|
+
default:
|
|
656
|
+
return 'script';
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
findPackageJson(filePath) {
|
|
660
|
+
const absolutePath = path.resolve(filePath);
|
|
661
|
+
let currentDir = absolutePath;
|
|
662
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
663
|
+
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
664
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
665
|
+
return packageJsonPath;
|
|
666
|
+
}
|
|
667
|
+
currentDir = path.dirname(currentDir);
|
|
668
|
+
}
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
609
671
|
}
|
|
610
672
|
exports.Parser = Parser;
|
package/dist/pot/entry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esgettext/tools",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Gettext-like po creation and manipulation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gettext",
|
|
@@ -81,38 +81,38 @@
|
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@babel/types": "^7.
|
|
85
|
-
"@esgettext/tools": "^1.3.
|
|
86
|
-
"@eslint/config-array": "^0.
|
|
87
|
-
"@humanwhocodes/retry": "^0.
|
|
88
|
-
"@tsconfig/recommended": "^1.0.
|
|
84
|
+
"@babel/types": "^7.26.3",
|
|
85
|
+
"@esgettext/tools": "^1.3.4",
|
|
86
|
+
"@eslint/config-array": "^0.19.0",
|
|
87
|
+
"@humanwhocodes/retry": "^0.4.1",
|
|
88
|
+
"@tsconfig/recommended": "^1.0.8",
|
|
89
89
|
"@types/glob": "^8.1.0",
|
|
90
|
-
"@types/jest": "^29.5.
|
|
90
|
+
"@types/jest": "^29.5.14",
|
|
91
91
|
"@types/jsonfile": "^6.1.4",
|
|
92
|
-
"@types/node": "^
|
|
92
|
+
"@types/node": "^22.10.1",
|
|
93
93
|
"@types/npmcli__package-json": "^4.0.4",
|
|
94
|
-
"@types/yargs": "^17.0.
|
|
95
|
-
"eslint": "^
|
|
94
|
+
"@types/yargs": "^17.0.33",
|
|
95
|
+
"eslint": "^9.16.0",
|
|
96
96
|
"jest": "^29.7.0",
|
|
97
97
|
"npm-run-all": "^4.1.5",
|
|
98
|
-
"prettier": "^3.
|
|
99
|
-
"rimraf": "^
|
|
100
|
-
"tsx": "^4.
|
|
101
|
-
"typescript": "^5.
|
|
102
|
-
"typescript-eslint": "^
|
|
98
|
+
"prettier": "^3.4.2",
|
|
99
|
+
"rimraf": "^6.0.1",
|
|
100
|
+
"tsx": "^4.19.2",
|
|
101
|
+
"typescript": "^5.7.2",
|
|
102
|
+
"typescript-eslint": "^8.17.0"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@babel/parser": "^7.
|
|
106
|
-
"@babel/traverse": "^7.
|
|
107
|
-
"@esgettext/runtime": "^1.3.
|
|
108
|
-
"@inquirer/prompts": "^
|
|
109
|
-
"@npmcli/package-json": "^
|
|
110
|
-
"@valibot/i18n": "^0.
|
|
105
|
+
"@babel/parser": "^7.26.3",
|
|
106
|
+
"@babel/traverse": "^7.26.3",
|
|
107
|
+
"@esgettext/runtime": "^1.3.5",
|
|
108
|
+
"@inquirer/prompts": "^7.1.0",
|
|
109
|
+
"@npmcli/package-json": "^6.1.0",
|
|
110
|
+
"@valibot/i18n": "^0.17.0",
|
|
111
111
|
"iconv-lite": "^0.6.3",
|
|
112
112
|
"jsonfile": "^6.1.0",
|
|
113
113
|
"mkdirp": "^3.0.1",
|
|
114
|
-
"valibot": "^0.
|
|
114
|
+
"valibot": "^0.42.1",
|
|
115
115
|
"yargs": "^17.7.2"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "4c46e2cc5863aa63635ea5e3580c9b041bcd0bc1"
|
|
118
118
|
}
|