@esgettext/tools 1.0.0 → 1.1.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/README.md +196 -21
- package/dist/command.d.ts +11 -0
- package/dist/command.js +3 -0
- package/dist/command.js.map +1 -0
- package/dist/commands/convert.d.ts +24 -0
- package/dist/commands/convert.js +284 -0
- package/dist/commands/convert.js.map +1 -0
- package/dist/commands/install.d.ts +22 -0
- package/dist/commands/install.js +249 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/msgfmt-all.d.ts +20 -0
- package/dist/commands/msgfmt-all.js +200 -0
- package/dist/commands/msgfmt-all.js.map +1 -0
- package/dist/commands/msgmerge-all.d.ts +21 -0
- package/dist/commands/msgmerge-all.js +212 -0
- package/dist/commands/msgmerge-all.js.map +1 -0
- package/dist/{xgettext → commands/xgettext}/file-resolver.d.ts +1 -1
- package/dist/commands/xgettext/file-resolver.js +21 -0
- package/dist/commands/xgettext/file-resolver.js.map +1 -0
- package/dist/commands/xgettext/file-resolver.spec.js +22 -0
- package/dist/commands/xgettext/file-resolver.spec.js.map +1 -0
- package/dist/commands/xgettext/files-collector.js +39 -0
- package/dist/commands/xgettext/files-collector.js.map +1 -0
- package/dist/{xgettext → commands/xgettext}/files-collector.spec.js +39 -21
- package/dist/commands/xgettext/files-collector.spec.js.map +1 -0
- package/dist/commands/xgettext.d.ts +29 -0
- package/dist/commands/xgettext.js +525 -0
- package/dist/commands/xgettext.js.map +1 -0
- package/dist/commands/xgettext.spec.js +897 -0
- package/dist/commands/xgettext.spec.js.map +1 -0
- package/dist/configuration.d.ts +36 -0
- package/dist/configuration.js +261 -0
- package/dist/configuration.js.map +1 -0
- package/dist/esgettext-package-json.d.ts +15 -0
- package/dist/esgettext-package-json.js +3 -0
- package/dist/esgettext-package-json.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/package.d.ts +1 -0
- package/dist/package.js +10 -11
- package/dist/package.js.map +1 -1
- package/dist/parser/javascript.js +7 -27
- package/dist/parser/javascript.js.map +1 -1
- package/dist/parser/javascript.spec.js +271 -172
- package/dist/parser/javascript.spec.js.map +1 -1
- package/dist/parser/parser.js +159 -146
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/po.d.ts +1 -1
- package/dist/parser/po.js +111 -128
- package/dist/parser/po.js.map +1 -1
- package/dist/parser/po.spec.js +349 -159
- package/dist/parser/po.spec.js.map +1 -1
- package/dist/parser/typescript.js +8 -27
- package/dist/parser/typescript.js.map +1 -1
- package/dist/parser/typescript.spec.js +56 -41
- package/dist/parser/typescript.spec.js.map +1 -1
- package/dist/pot/catalog.js +98 -82
- package/dist/pot/catalog.js.map +1 -1
- package/dist/pot/catalog.spec.js +47 -43
- package/dist/pot/catalog.spec.js.map +1 -1
- package/dist/pot/entry.js +102 -114
- package/dist/pot/entry.js.map +1 -1
- package/dist/pot/entry.spec.js +255 -139
- package/dist/pot/entry.spec.js.map +1 -1
- package/dist/pot/keyword.js +57 -88
- package/dist/pot/keyword.js.map +1 -1
- package/dist/pot/keyword.spec.js +26 -26
- package/dist/pot/keyword.spec.js.map +1 -1
- package/package.json +36 -24
- 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/parser/__snapshots__/javascript.spec.js.snap +0 -56
- package/dist/parser/__snapshots__/po.spec.js.snap +0 -176
- package/dist/pot/__snapshots__/catalog.spec.js.snap +0 -591
- package/dist/xgettext/__snapshots__/xgettext.spec.js.snap +0 -462
- package/dist/xgettext/file-resolver.js +0 -23
- package/dist/xgettext/file-resolver.js.map +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.js +0 -41
- package/dist/xgettext/files-collector.js.map +0 -1
- 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.js +0 -743
- package/dist/xgettext/xgettext.spec.js.map +0 -1
- /package/dist/{xgettext → commands/xgettext}/file-resolver.spec.d.ts +0 -0
- /package/dist/{xgettext → commands/xgettext}/files-collector.d.ts +0 -0
- /package/dist/{xgettext → commands/xgettext}/files-collector.spec.d.ts +0 -0
- /package/dist/{xgettext → commands}/xgettext.spec.d.ts +0 -0
package/README.md
CHANGED
|
@@ -6,15 +6,37 @@ Supporting tools for https://github.com/gflohr/esgettext.
|
|
|
6
6
|
|
|
7
7
|
- [Status](#status)
|
|
8
8
|
- [Prerequisites](#prerequisites)
|
|
9
|
-
- [Un
|
|
9
|
+
- [Un\*x/Linux](#unxlinux)
|
|
10
10
|
- [Mac OS X](#mac-os-x)
|
|
11
11
|
- [MacPorts](#macports)
|
|
12
12
|
- [HomeBrew](#homebrew)
|
|
13
13
|
- [MS-DOS (Microsoft Windows)](#ms-dos-microsoft-windows)
|
|
14
14
|
- [Installation](#installation)
|
|
15
15
|
- [The Tools](#the-tools)
|
|
16
|
-
- [`esgettext
|
|
17
|
-
- [
|
|
16
|
+
- [`esgettext xgettext`](#esgettext-xgettext)
|
|
17
|
+
- [Other Commands](#other-commands)
|
|
18
|
+
- [Configuration](#configuration)
|
|
19
|
+
- [Configuration Files](#configuration-files)
|
|
20
|
+
- [Validation](#validation)
|
|
21
|
+
- [Configuration Schema](#configuration-schema)
|
|
22
|
+
- [`package`](#package)
|
|
23
|
+
- [`package.textdomain`](#packagetextdomain)
|
|
24
|
+
- [`package.msgid-bugs-address`](#packagemsgid-bugs-address)
|
|
25
|
+
- [`package.name`](#packagename)
|
|
26
|
+
- [`package.copyright-holder`](#packagecopyright-holder)
|
|
27
|
+
- [`package.version`](#packageversion)
|
|
28
|
+
- [`po`:](#po)
|
|
29
|
+
- [`po.directory`](#podirectory)
|
|
30
|
+
- [`po.locales`](#polocales)
|
|
31
|
+
- [`install`](#install)
|
|
32
|
+
- [`install.directory`](#installdirectory)
|
|
33
|
+
- [`programs`](#programs)
|
|
34
|
+
- [`programs.msgmerge`](#programsmsgmerge)
|
|
35
|
+
- [`programs.msgmerge.path`](#programsmsgmergepath)
|
|
36
|
+
- [`programs.msgmerge.options`](#programsmsgmergeoptions)
|
|
37
|
+
- [`programs.msgfmt`](#programsmsgfmt)
|
|
38
|
+
- [`programs.msgfmt.path`](#programsmsgfmtpath)
|
|
39
|
+
- [`programs.msgfmt.options`](#programsmsgfmtoptions)
|
|
18
40
|
- [Copyright](#copyright)
|
|
19
41
|
|
|
20
42
|
## Status
|
|
@@ -75,48 +97,201 @@ $ sudo npm install --global @esgettext/tools
|
|
|
75
97
|
|
|
76
98
|
For [Yarn](https://yarnpkg.com/), you would do this:
|
|
77
99
|
|
|
78
|
-
```
|
|
100
|
+
```shell
|
|
79
101
|
$ sudo yarn global add @esgettext/tools
|
|
80
102
|
```
|
|
81
103
|
|
|
82
|
-
|
|
83
|
-
then you can (es)gettextize your project like this:
|
|
104
|
+
Normally, it is better to install them just locally:
|
|
84
105
|
|
|
85
|
-
```
|
|
106
|
+
```shell
|
|
86
107
|
$ npm install --save-dev @esgettext/tools
|
|
87
|
-
$ npx @esgettext/gettextize
|
|
88
108
|
```
|
|
89
109
|
|
|
90
110
|
or for yarn:
|
|
91
111
|
|
|
92
|
-
```
|
|
112
|
+
```shell
|
|
93
113
|
$ yarn add --dev @esgettext/tools
|
|
94
|
-
$ npx @esgettext/gettextize
|
|
95
114
|
```
|
|
96
115
|
|
|
97
|
-
This will modify your `package.json` with a couple of scripts, all named
|
|
98
|
-
`po:.*`. You can then finetune your setup by just editing `package.json`.
|
|
99
|
-
|
|
100
116
|
## The Tools
|
|
101
117
|
|
|
102
|
-
|
|
118
|
+
The tools are really just one tool `esgettext` that supports several
|
|
119
|
+
commands.
|
|
103
120
|
|
|
104
|
-
|
|
105
|
-
|
|
121
|
+
In the following, it is assumed that you have installed the tools locally.
|
|
122
|
+
If you have installed them globally, just omit the leading `npx`.
|
|
106
123
|
|
|
107
|
-
|
|
108
|
-
[esgettext-gettextize usage information](./README-esgettext-gettextize.md)
|
|
109
|
-
for more details.
|
|
124
|
+
Try this for an overview:
|
|
110
125
|
|
|
111
|
-
|
|
126
|
+
```shell
|
|
127
|
+
$ npx esgettext --help
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### `esgettext xgettext`
|
|
112
131
|
|
|
113
|
-
The
|
|
132
|
+
The command `npx esgetext xgettext` extracts translatable strings from your source
|
|
114
133
|
files into `.po` resp. `.pot` files.
|
|
115
134
|
|
|
135
|
+
You can use `npx esgettext extract` as an alias for `npx esgettext xgettext`.
|
|
136
|
+
|
|
116
137
|
See the detailed
|
|
117
138
|
[esgettext-xgettext usage information](./README-esgettext-xgettext.md)
|
|
118
139
|
for more details.
|
|
119
140
|
|
|
141
|
+
### Other Commands
|
|
142
|
+
|
|
143
|
+
All other commands should be understandable by their help output. Try
|
|
144
|
+
`npx esgettext --help` for an overview over all commands, and
|
|
145
|
+
`npx esgettext COMMAND --help` for help for a specific command.
|
|
146
|
+
|
|
147
|
+
## Configuration
|
|
148
|
+
|
|
149
|
+
Instead of passing options on the command line, you can add a lot of defaults
|
|
150
|
+
in a configuration file or just in `package.json`.
|
|
151
|
+
|
|
152
|
+
### Configuration Files
|
|
153
|
+
|
|
154
|
+
Configuration files are checked in this order:
|
|
155
|
+
|
|
156
|
+
* esgettext.config.mjs
|
|
157
|
+
* esgettext.config.cjs
|
|
158
|
+
* esgettext.config.js
|
|
159
|
+
* esgettext.config.json
|
|
160
|
+
* package.json
|
|
161
|
+
|
|
162
|
+
The JavaScript versions should have one default export with the configuration.
|
|
163
|
+
The JSON version just defines the configuration. Alteratively, you can add
|
|
164
|
+
a field "esgettext" to your `package.json`.
|
|
165
|
+
|
|
166
|
+
You should always configure `po.locales` with a list of locale identifiers that
|
|
167
|
+
your package supports. Otherwise, using `esgettext` does not make sense.
|
|
168
|
+
|
|
169
|
+
You should also set `package.textdomain` unless you are happy with the
|
|
170
|
+
default which is just your package name read from `package.json`.
|
|
171
|
+
|
|
172
|
+
All other configuration values have sane defaults.
|
|
173
|
+
|
|
174
|
+
### Validation
|
|
175
|
+
|
|
176
|
+
The required format is always the same. Note that the configuration gets
|
|
177
|
+
validated against a schema. All tools will fail with a validation error if
|
|
178
|
+
you pass an invalid configuration.
|
|
179
|
+
|
|
180
|
+
### Configuration Schema
|
|
181
|
+
|
|
182
|
+
All fields in the configuration are optional because you are always able to
|
|
183
|
+
pass them on the command line.
|
|
184
|
+
|
|
185
|
+
Options passed on the command line have higher precedence than options given
|
|
186
|
+
in a configuration file. Options that you define inside a section `esgettext`
|
|
187
|
+
in `package.json` have higher precedence than options that default to
|
|
188
|
+
general fields inside `package.json`.
|
|
189
|
+
|
|
190
|
+
A complete example for a configuration can look like this:
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
package: {
|
|
194
|
+
textdomain: 'com.example.my-package',
|
|
195
|
+
'msgid-bugs-address': 'you@example.com',
|
|
196
|
+
name: 'my-package',
|
|
197
|
+
'copyright-holder': 'Yours Truly <you@example.com>',
|
|
198
|
+
},
|
|
199
|
+
po: {
|
|
200
|
+
directory: 'po',
|
|
201
|
+
locales: ['de', 'fr-CA', 'fr-FR', 'it'],
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### `package`
|
|
206
|
+
|
|
207
|
+
General information about your package.
|
|
208
|
+
|
|
209
|
+
##### `package.textdomain`
|
|
210
|
+
|
|
211
|
+
The textdomain of your package, usually something like
|
|
212
|
+
`com.example.YOUR-PACKAGE`. You should configure this.
|
|
213
|
+
|
|
214
|
+
##### `package.msgid-bugs-address`
|
|
215
|
+
|
|
216
|
+
An email address or URL where to send bug reports or questions about message
|
|
217
|
+
ids. This is added to the respective field in all generated po files.
|
|
218
|
+
|
|
219
|
+
If you omit this field, it will be read from the fields `bugs.email` or
|
|
220
|
+
`bugs.url` (in that order) in `package.json`.
|
|
221
|
+
|
|
222
|
+
##### `package.name`
|
|
223
|
+
|
|
224
|
+
The name of your package.
|
|
225
|
+
|
|
226
|
+
If you omit this field, it will be read from the field `name` in
|
|
227
|
+
`package.json`.
|
|
228
|
+
|
|
229
|
+
##### `package.copyright-holder`
|
|
230
|
+
|
|
231
|
+
The copyright holder of your package. This is added as a comment to all
|
|
232
|
+
generated po files.
|
|
233
|
+
|
|
234
|
+
If you omit this field, it will be read from the field `people.author` in
|
|
235
|
+
`package.json`.
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
##### `package.version`
|
|
239
|
+
|
|
240
|
+
The version of your package.
|
|
241
|
+
|
|
242
|
+
If you omit this field, it will be read from the field `version` in
|
|
243
|
+
`package.json`.
|
|
244
|
+
|
|
245
|
+
#### `po`:
|
|
246
|
+
|
|
247
|
+
The location of your translation and translation workflow files and feature
|
|
248
|
+
thereof.
|
|
249
|
+
|
|
250
|
+
##### `po.directory`
|
|
251
|
+
|
|
252
|
+
The directory where all translation related files reside, usually 'po'.
|
|
253
|
+
|
|
254
|
+
##### `po.locales`
|
|
255
|
+
|
|
256
|
+
An array of locale identifiers. This should always be configured.
|
|
257
|
+
|
|
258
|
+
#### `install`
|
|
259
|
+
|
|
260
|
+
Installation options.
|
|
261
|
+
|
|
262
|
+
##### `install.directory`
|
|
263
|
+
|
|
264
|
+
Where to install compiled translation files, usually something like
|
|
265
|
+
`src/locale`, `assets/locale`, or `dist/assets/locale`.
|
|
266
|
+
|
|
267
|
+
#### `programs`
|
|
268
|
+
|
|
269
|
+
Information for helper programs.
|
|
270
|
+
|
|
271
|
+
##### `programs.msgmerge`
|
|
272
|
+
|
|
273
|
+
###### `programs.msgmerge.path`
|
|
274
|
+
|
|
275
|
+
The path to the `msgmerge` program of your system.
|
|
276
|
+
|
|
277
|
+
###### `programs.msgmerge.options`
|
|
278
|
+
|
|
279
|
+
An array of options to pass to the `msgmerge` program. Only boolean options
|
|
280
|
+
without arguments are supported. And you have to omit the leading hyphens,
|
|
281
|
+
for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
282
|
+
|
|
283
|
+
##### `programs.msgfmt`
|
|
284
|
+
|
|
285
|
+
###### `programs.msgfmt.path`
|
|
286
|
+
|
|
287
|
+
The path to the `msgfmt` program of your system.
|
|
288
|
+
|
|
289
|
+
###### `programs.msgfmt.options`
|
|
290
|
+
|
|
291
|
+
An array of options to pass to the `msgmerge` program. Only boolean options
|
|
292
|
+
without arguments are supported. And you have to omit the leading hyphens,
|
|
293
|
+
for example `['verbose']` or `['v']`, and not `['--verbose']` or `['-v']`.
|
|
294
|
+
|
|
120
295
|
## Copyright
|
|
121
296
|
|
|
122
297
|
Copyright (C) 2020 Guido Flohr <guido.flohr@cantanea.com>, all
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
export interface Command {
|
|
3
|
+
synopsis(): string;
|
|
4
|
+
description(): string;
|
|
5
|
+
aliases(): Array<string>;
|
|
6
|
+
args(): {
|
|
7
|
+
[key: string]: yargs.Options;
|
|
8
|
+
};
|
|
9
|
+
additional(argv: yargs.Argv): void;
|
|
10
|
+
run(argv: yargs.Arguments): Promise<number>;
|
|
11
|
+
}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
import { Command } from '../command';
|
|
3
|
+
import { Configuration } from '../configuration';
|
|
4
|
+
export declare class Convert implements Command {
|
|
5
|
+
private options;
|
|
6
|
+
private readonly configuration;
|
|
7
|
+
constructor(configuration: Configuration);
|
|
8
|
+
synopsis(): string;
|
|
9
|
+
description(): string;
|
|
10
|
+
aliases(): Array<string>;
|
|
11
|
+
args(): {
|
|
12
|
+
[key: string]: yargs.Options;
|
|
13
|
+
};
|
|
14
|
+
additional(argv: yargs.Argv): void;
|
|
15
|
+
private init;
|
|
16
|
+
run(argv: yargs.Arguments): Promise<number>;
|
|
17
|
+
private getFileFormat;
|
|
18
|
+
private checkInputFormat;
|
|
19
|
+
private checkOutputFormat;
|
|
20
|
+
private readInput;
|
|
21
|
+
private convert;
|
|
22
|
+
private shortenAndEscapeString;
|
|
23
|
+
private output;
|
|
24
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Convert = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const runtime_1 = require("@esgettext/runtime");
|
|
29
|
+
const package_1 = require("../package");
|
|
30
|
+
const gtx = runtime_1.Textdomain.getInstance('com.cantanea.esgettext-tools');
|
|
31
|
+
class Convert {
|
|
32
|
+
constructor(configuration) {
|
|
33
|
+
this.configuration = configuration;
|
|
34
|
+
}
|
|
35
|
+
synopsis() {
|
|
36
|
+
return `[${gtx._('INPUTFILE')}] [${gtx._('OUTPUTFILE')}]`;
|
|
37
|
+
}
|
|
38
|
+
description() {
|
|
39
|
+
return gtx._('Convert translation catalogs.');
|
|
40
|
+
}
|
|
41
|
+
aliases() {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
args() {
|
|
45
|
+
return {
|
|
46
|
+
input: {
|
|
47
|
+
alias: 'i',
|
|
48
|
+
type: 'string',
|
|
49
|
+
describe: gtx._('Input file (stdin when omitted)'),
|
|
50
|
+
group: gtx._('File locations:'),
|
|
51
|
+
},
|
|
52
|
+
output: {
|
|
53
|
+
alias: 'o',
|
|
54
|
+
type: 'string',
|
|
55
|
+
describe: gtx._('Output file (stdout when omitted)'),
|
|
56
|
+
group: gtx._('File locations:'),
|
|
57
|
+
},
|
|
58
|
+
'input-format': {
|
|
59
|
+
alias: 'I',
|
|
60
|
+
type: 'string',
|
|
61
|
+
describe: gtx._('Input file format (defaul: derived from filename)'),
|
|
62
|
+
choices: ['mo.json', 'mo', 'gmo', 'json'],
|
|
63
|
+
coerce: arg => arg.toLowerCase(),
|
|
64
|
+
group: gtx._('File formats:'),
|
|
65
|
+
},
|
|
66
|
+
'output-format': {
|
|
67
|
+
alias: 'O',
|
|
68
|
+
type: 'string',
|
|
69
|
+
describe: gtx._('Output file format (default: derived from format)'),
|
|
70
|
+
choices: ['mo.json', 'json'],
|
|
71
|
+
coerce: arg => arg.toLowerCase(),
|
|
72
|
+
group: gtx._('File formats:'),
|
|
73
|
+
},
|
|
74
|
+
verbose: {
|
|
75
|
+
alias: 'V',
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
describe: gtx._('Enable verbose output'),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
additional(argv) {
|
|
82
|
+
argv.positional(gtx._('INPUTFILE'), {
|
|
83
|
+
type: 'string',
|
|
84
|
+
describe: gtx._('Input file (or option -i or standard input)'),
|
|
85
|
+
});
|
|
86
|
+
argv.positional(gtx._('OUTPUTFILE'), {
|
|
87
|
+
type: 'string',
|
|
88
|
+
describe: gtx._('Output file (or option -o or standard output)'),
|
|
89
|
+
});
|
|
90
|
+
argv.conflicts('input', 'INPUTFILE');
|
|
91
|
+
argv.conflicts('output', 'OUTPUTFILE');
|
|
92
|
+
}
|
|
93
|
+
init(argv) {
|
|
94
|
+
const options = argv;
|
|
95
|
+
this.options = options;
|
|
96
|
+
}
|
|
97
|
+
run(argv) {
|
|
98
|
+
this.init(argv);
|
|
99
|
+
const options = this.options;
|
|
100
|
+
return new Promise(resolve => {
|
|
101
|
+
const input = options.input || options[gtx._('INPUTFILE')];
|
|
102
|
+
const output = options.output || options[gtx._('OUTPUTFILE')];
|
|
103
|
+
const inputFormat = this.getFileFormat(input);
|
|
104
|
+
if (!this.checkInputFormat(inputFormat, input)) {
|
|
105
|
+
return resolve(1);
|
|
106
|
+
}
|
|
107
|
+
if (options.verbose) {
|
|
108
|
+
console.error(gtx._x('Detected input format {inputFormat}.', { inputFormat }));
|
|
109
|
+
}
|
|
110
|
+
const outputFormat = this.getFileFormat(output);
|
|
111
|
+
if (!this.checkOutputFormat(outputFormat, output)) {
|
|
112
|
+
return resolve(1);
|
|
113
|
+
}
|
|
114
|
+
if (options.verbose) {
|
|
115
|
+
console.error(gtx._x('Detected output format {outputFormat}.', { outputFormat }));
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const inBuffer = this.readInput(input);
|
|
119
|
+
let catalog;
|
|
120
|
+
switch (options.inputFormat) {
|
|
121
|
+
case 'mo.json':
|
|
122
|
+
catalog = (0, runtime_1.parseMoJsonCatalog)(inBuffer);
|
|
123
|
+
break;
|
|
124
|
+
case 'mo':
|
|
125
|
+
case 'gmo':
|
|
126
|
+
default:
|
|
127
|
+
catalog = (0, runtime_1.parseMoCatalog)(inBuffer);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
const converted = this.convert(catalog, input, outputFormat);
|
|
131
|
+
if (!converted) {
|
|
132
|
+
return resolve(1);
|
|
133
|
+
}
|
|
134
|
+
this.output(output, converted);
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
console.error(gtx._x('{programName}: Error: {e}'));
|
|
138
|
+
return resolve(1);
|
|
139
|
+
}
|
|
140
|
+
return resolve(0);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getFileFormat(input) {
|
|
144
|
+
if (this.options.inputFormat) {
|
|
145
|
+
return this.options.inputFormat;
|
|
146
|
+
}
|
|
147
|
+
else if (typeof input !== 'undefined') {
|
|
148
|
+
const match = input.match(/\.(mo\.json|g?mo|json)$/i);
|
|
149
|
+
if (match) {
|
|
150
|
+
return match[1].toLowerCase();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
checkInputFormat(format, filename) {
|
|
156
|
+
if (!format) {
|
|
157
|
+
if (typeof filename === 'undefined') {
|
|
158
|
+
console.error(gtx._x("{programName}: Error: The option '--inputFormat' is mandatory, when reading from standard input", { programName: package_1.Package.getName() }));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
console.error(gtx._x("{programName}: Error: Please specify the input format with '--inputFormat'! Cannot guess it from input filename '{filename}'!", { programName: package_1.Package.getName(), filename }));
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
else if (format !== 'mo.json' &&
|
|
166
|
+
format !== 'mo' &&
|
|
167
|
+
format !== 'gmo' &&
|
|
168
|
+
format !== 'json') {
|
|
169
|
+
console.error(gtx._("Only 'mo.json', 'mo', 'gmo', and 'json' are allowed as input formats!"));
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
checkOutputFormat(format, filename) {
|
|
175
|
+
if (!format) {
|
|
176
|
+
if (typeof filename === 'undefined') {
|
|
177
|
+
console.error(gtx._x("{programName}: Error: The option '--outputFormat' is mandatory, when writing to standard input", { programName: package_1.Package.getName() }));
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
console.error(gtx._x("{programName}: Error: Please specify the output format with '--outputFormat'! Cannot guess it from input filename '{filename}'!", { programName: package_1.Package.getName(), filename }));
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
else if (format !== 'mo.json' && format !== 'json') {
|
|
185
|
+
console.error(gtx._("Only 'mo.json' and 'json' are allowed as output formats!"));
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
readInput(filename) {
|
|
191
|
+
try {
|
|
192
|
+
if (filename === '-' && !fs.existsSync(filename)) {
|
|
193
|
+
filename = undefined;
|
|
194
|
+
}
|
|
195
|
+
if (typeof filename !== 'undefined') {
|
|
196
|
+
return fs.readFileSync(filename);
|
|
197
|
+
}
|
|
198
|
+
const stdinFd = 0;
|
|
199
|
+
const chunks = [];
|
|
200
|
+
let bytesRead;
|
|
201
|
+
const buffer = Buffer.alloc(8192);
|
|
202
|
+
while ((bytesRead = fs.readSync(stdinFd, buffer, 0, buffer.length, null)) > 0) {
|
|
203
|
+
chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
|
|
204
|
+
}
|
|
205
|
+
return Buffer.concat(chunks);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
if (typeof filename === 'undefined') {
|
|
209
|
+
filename = gtx._('[standard input]');
|
|
210
|
+
}
|
|
211
|
+
throw Error(gtx._x('{filename}: read failed: {error}', { filename, error }));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
convert(catalog, filename, outputFormat) {
|
|
215
|
+
if (typeof filename === 'undefined') {
|
|
216
|
+
filename = gtx._('[standard input]');
|
|
217
|
+
}
|
|
218
|
+
if (outputFormat === 'json') {
|
|
219
|
+
const entries = {};
|
|
220
|
+
let errors = 0;
|
|
221
|
+
for (const [msgid, msgstr] of Object.entries(catalog.entries)) {
|
|
222
|
+
if (msgstr.length > 1) {
|
|
223
|
+
++errors;
|
|
224
|
+
console.error(gtx._x("{filename}: Error: msgid '{msgid}': plural forms are not supported by the 'json' catalog format!", { filename, msgid: this.shortenAndEscapeString(msgid, 40) }));
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
entries[msgid] = msgstr[0];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (errors) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
return JSON.stringify(entries);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
return JSON.stringify(catalog);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
shortenAndEscapeString(input, maxLength) {
|
|
240
|
+
const controlCharMap = {
|
|
241
|
+
'\0': '\\0',
|
|
242
|
+
'\b': '\\b',
|
|
243
|
+
'\t': '\\t',
|
|
244
|
+
'\n': '\\n',
|
|
245
|
+
'\v': '\\v',
|
|
246
|
+
'\f': '\\f',
|
|
247
|
+
'\r': '\\r',
|
|
248
|
+
'"': '\\"',
|
|
249
|
+
"'": "\\'",
|
|
250
|
+
'\\': '\\\\',
|
|
251
|
+
};
|
|
252
|
+
const escapeControlChar = (char) => {
|
|
253
|
+
if (controlCharMap[char]) {
|
|
254
|
+
return controlCharMap[char];
|
|
255
|
+
}
|
|
256
|
+
const code = char.charCodeAt(0);
|
|
257
|
+
if (code < 32) {
|
|
258
|
+
return `\\x${code.toString(16).padStart(2, '0')}`;
|
|
259
|
+
}
|
|
260
|
+
return char;
|
|
261
|
+
};
|
|
262
|
+
const escapedInput = input.replace(/[\x00-\x1F"'\\]/g, escapeControlChar);
|
|
263
|
+
let truncatedString = escapedInput;
|
|
264
|
+
if (escapedInput.length > maxLength) {
|
|
265
|
+
truncatedString = escapedInput.slice(0, maxLength - 3) + '...';
|
|
266
|
+
}
|
|
267
|
+
return truncatedString;
|
|
268
|
+
}
|
|
269
|
+
output(filename, data) {
|
|
270
|
+
if (typeof filename === 'undefined') {
|
|
271
|
+
console.log(data);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
try {
|
|
275
|
+
fs.writeFileSync(filename, data, { encoding: 'utf-8' });
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
throw Error(gtx._x('{filename}: write failed: {error}', { filename, error }));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.Convert = Convert;
|
|
284
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/commands/convert.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAGzB,gDAK4B;AAE5B,wCAAqC;AAErC,MAAM,GAAG,GAAG,oBAAU,CAAC,WAAW,CAAC,8BAA8B,CAAC,CAAC;AAcnE,MAAa,OAAO;IAInB,YAAY,aAA4B;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC;IAC3D,CAAC;IAED,WAAW;QACV,OAAO,GAAG,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACN,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI;QACH,OAAO;YACN,KAAK,EAAE;gBACN,KAAK,EAAE,GAAG;gBACV,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,iCAAiC,CAAC;gBAClD,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,CAAC;aAC/B;YACD,MAAM,EAAE;gBACP,KAAK,EAAE,GAAG;gBACV,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,mCAAmC,CAAC;gBACpD,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,CAAC;aAC/B;Y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AAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,KAAK,CACV,GAAG,CAAC,EAAE,CAAC,mCAAmC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAChE,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;CACD;AA5VD,0BA4VC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from '../command';
|
|
2
|
+
import yargs from 'yargs';
|
|
3
|
+
import { Configuration } from '../configuration';
|
|
4
|
+
export declare class Install implements Command {
|
|
5
|
+
private locales;
|
|
6
|
+
private options;
|
|
7
|
+
private readonly configuration;
|
|
8
|
+
constructor(configuration: Configuration);
|
|
9
|
+
synopsis(): string;
|
|
10
|
+
description(): string;
|
|
11
|
+
aliases(): Array<string>;
|
|
12
|
+
args(): {
|
|
13
|
+
[key: string]: yargs.Options;
|
|
14
|
+
};
|
|
15
|
+
additional(_: yargs.Argv): void;
|
|
16
|
+
private init;
|
|
17
|
+
run(argv: yargs.Arguments): Promise<number>;
|
|
18
|
+
private installMoLocale;
|
|
19
|
+
private installMoJsonLocale;
|
|
20
|
+
private installJsonLocale;
|
|
21
|
+
private installLocale;
|
|
22
|
+
}
|