@makefully/dutifully 1.19.0 → 1.20.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/CHANGELOG.md +5 -0
- package/README.md +32 -1
- package/package.json +4 -2
- package/src/classes/Translate.js +47 -0
- package/src/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.20.0
|
|
6
|
+
|
|
7
|
+
- Add `translate` client for Amazon Translate (Cheerfully script JSON or language-matrix CSV/TSV).
|
|
8
|
+
- Support `ignore` for phrases left untranslated.
|
|
9
|
+
|
|
5
10
|
## 1.19.0
|
|
6
11
|
|
|
7
12
|
- Authenticate Showfully yap chores with `Authorization: Bearer` and `POST /yap/:service` (token no longer in the URL path).
|
package/README.md
CHANGED
|
@@ -355,9 +355,40 @@ Script lines may also include an optional `events` array for one-shot timed mark
|
|
|
355
355
|
|
|
356
356
|
Cheerfully resolves these against caption timings and exports them in parallel using the same caption `format` (`events.json`, `{id}.events.vtt` / `.srt` / `.sami` / `.smi` / `.lrc`, or a separate MP3 SYLT frame with content type `EVENTS` labeled `"events"`).
|
|
357
357
|
|
|
358
|
+
### Translate
|
|
359
|
+
|
|
360
|
+
This text-to-text service translates Cheerfully scripts or language-matrix CSV/TSV via Amazon Translate. Set jobs in `cheerfully.json`:
|
|
361
|
+
|
|
362
|
+
```javascript
|
|
363
|
+
{
|
|
364
|
+
"translate": [{
|
|
365
|
+
"script": "./example/script.json",
|
|
366
|
+
"language": "en-US",
|
|
367
|
+
"languages": ["es-ES", "fr-FR"],
|
|
368
|
+
"output": "./example/scripts/",
|
|
369
|
+
"ignore": ["Makefully Studios"]
|
|
370
|
+
}, {
|
|
371
|
+
"script": "./example/strings.csv",
|
|
372
|
+
"language": "en-US",
|
|
373
|
+
"languages": ["es-ES", "fr-FR"],
|
|
374
|
+
"output": "./example/scripts/"
|
|
375
|
+
}]
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
* `script` — path to a Cheerfully `.json` script or a language-matrix `.csv` / `.tsv` (first column = ids, first row = language tags).
|
|
380
|
+
* `language` — source locale (CSV: source column). Matrix jobs require this; JSON may use `auto`.
|
|
381
|
+
* `languages` — target locales to produce or fill.
|
|
382
|
+
* `format` / `exports` — optional. Defaults to the source extension (`json`, `csv`, or `tsv`).
|
|
383
|
+
* `ignore` — phrases left untranslated.
|
|
384
|
+
|
|
385
|
+
JSON sources write `{lang}/{basename}.{ext}` under `output`. CSV/TSV sources write an updated matrix file and leave existing non-empty cells unchanged.
|
|
386
|
+
|
|
387
|
+
Supported formats: `json`, `i18n`, `csv`, `tsv`, `po`, `xliff`, `properties`, `yml` / `yaml`, `strings`, `xml`.
|
|
388
|
+
|
|
358
389
|
## Example
|
|
359
390
|
|
|
360
|
-
Find an example script in the `./examples/` folder. You can run either `npm run test-elevenlabs` or `npm run test-polly` to create VO tracks in the examples folder that you can then use to try out `npm run test-rhubarb` and `npm run test-transcription`. Sample sprites for atlas packing are under `./example/sprites/`; run `npm run test-packfully` to pack them into `./example/atlases/`.
|
|
391
|
+
Find an example script in the `./examples/` folder. You can run either `npm run test-elevenlabs` or `npm run test-polly` to create VO tracks in the examples folder that you can then use to try out `npm run test-rhubarb` and `npm run test-transcription`. Sample sprites for atlas packing are under `./example/sprites/`; run `npm run test-packfully` to pack them into `./example/atlases/`. Run `npm run test-translate` to translate `./example/script.json` and `./example/strings.csv` into `./example/scripts/`.
|
|
361
392
|
|
|
362
393
|
These examples are specified using a JSON definition in `./cheerfully.json` which you can copy or modify to set different generation parameters as supported by Cheerfully.
|
|
363
394
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makefully/dutifully",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Client tools for Cheerfully service.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test-sharp": "node ./cheer.js -service sharp",
|
|
29
29
|
"test-stackfully": "node ./cheer.js -service stackfully",
|
|
30
30
|
"test-transcription": "node ./cheer.js -service transcription",
|
|
31
|
+
"test-translate": "node ./cheer.js -service translate",
|
|
31
32
|
"say": "node ./say.js"
|
|
32
33
|
},
|
|
33
34
|
"repository": {
|
|
@@ -50,7 +51,8 @@
|
|
|
50
51
|
"packfully",
|
|
51
52
|
"atlas",
|
|
52
53
|
"spritesheet",
|
|
53
|
-
"classfully"
|
|
54
|
+
"classfully",
|
|
55
|
+
"translate"
|
|
54
56
|
],
|
|
55
57
|
"author": "Derek Detweiler <derek@makefullystudios.com>",
|
|
56
58
|
"contributors": [
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const
|
|
2
|
+
path = require('path'),
|
|
3
|
+
Cheer = require('./Cheer'),
|
|
4
|
+
MATRIX_EXTS = new Set(['csv', 'tsv']),
|
|
5
|
+
Translate = class Translate extends Cheer {
|
|
6
|
+
async prepare (data) {
|
|
7
|
+
const
|
|
8
|
+
{config} = this,
|
|
9
|
+
scriptPath = config.script;
|
|
10
|
+
|
|
11
|
+
this.matrixMode = false;
|
|
12
|
+
this.scriptPath = null;
|
|
13
|
+
|
|
14
|
+
if (scriptPath) {
|
|
15
|
+
const
|
|
16
|
+
ext = path.extname(scriptPath).slice(1).toLowerCase(),
|
|
17
|
+
basename = path.basename(scriptPath, path.extname(scriptPath));
|
|
18
|
+
|
|
19
|
+
this.scriptPath = scriptPath;
|
|
20
|
+
config.basename = config.basename ?? basename;
|
|
21
|
+
|
|
22
|
+
if (!config.format && !config.exports) {
|
|
23
|
+
config.format = MATRIX_EXTS.has(ext) ? ext : 'json';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (MATRIX_EXTS.has(ext)) {
|
|
27
|
+
this.matrixMode = true;
|
|
28
|
+
config.matrixFile = path.basename(scriptPath);
|
|
29
|
+
delete config.script;
|
|
30
|
+
} else {
|
|
31
|
+
await this.replaceConfigPathWithJSON('script', 'files');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return super.prepare(data);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeSend (archive) {
|
|
39
|
+
if (this.matrixMode && this.scriptPath) {
|
|
40
|
+
archive.file(this.scriptPath, {name: this.config.matrixFile});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return super.beforeSend(archive);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = Translate;
|
package/src/index.js
CHANGED
|
@@ -13,7 +13,8 @@ const
|
|
|
13
13
|
rhubarb: LipSync,
|
|
14
14
|
sharp: require('./classes/Sharp'),
|
|
15
15
|
stackfully: require('./classes/Stackfully'),
|
|
16
|
-
transcription: require('./classes/Transcription')
|
|
16
|
+
transcription: require('./classes/Transcription'),
|
|
17
|
+
translate: require('./classes/Translate')
|
|
17
18
|
},
|
|
18
19
|
getJSON = require('./helpers/getJSON'),
|
|
19
20
|
send = async function (contents) {
|