@l10nmonster/helpers-translated 3.1.0 → 3.1.1
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 +22 -0
- package/laraProvider.js +6 -4
- package/mmtProvider.js +8 -3
- package/package.json +4 -3
- package/tsconfig.json +18 -0
- package/.releaserc.json +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## @l10nmonster/helpers-translated [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-translated@3.1.0...@l10nmonster/helpers-translated@3.1.1) (2025-12-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
|
|
7
|
+
|
|
8
|
+
## @l10nmonster/helpers-translated [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-translated@3.1.0...@l10nmonster/helpers-translated@3.1.1) (2025-12-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
* **@l10nmonster/core:** upgraded to 3.1.1
|
|
22
|
+
|
|
1
23
|
# @l10nmonster/helpers-translated [3.1.0](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-translated@3.0.0...@l10nmonster/helpers-translated@3.1.0) (2025-12-20)
|
|
2
24
|
|
|
3
25
|
|
package/laraProvider.js
CHANGED
|
@@ -3,7 +3,6 @@ import { Credentials, Translator } from '@translated/lara';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {object} LaraProviderOptions
|
|
6
|
-
* @extends ChunkedRemoteTranslationProviderOptions
|
|
7
6
|
* @property {string} keyId - The Lara API key id. This is required.
|
|
8
7
|
* @property {Promise<string>|string} [keySecret] - The Lara API key secret. Optional, but often needed for authentication.
|
|
9
8
|
* @property {string | Array<string>} [adaptTo] - An optional single translation memory ID or an array of IDs to adapt translations to.
|
|
@@ -24,6 +23,7 @@ export class LaraProvider extends providers.ChunkedRemoteTranslationProvider {
|
|
|
24
23
|
* @param {LaraProviderOptions} options - Configuration options for the provider.
|
|
25
24
|
*/
|
|
26
25
|
constructor({ keyId, keySecret, adaptTo, glossaries, ...options }) {
|
|
26
|
+
// @ts-ignore - spread loses type info but parent class handles validation
|
|
27
27
|
super({ maxChunkSize: 60, ...options }); // maximum number of strings sent to Lara is 128 including notes
|
|
28
28
|
this.#keyId = keyId;
|
|
29
29
|
this.#keySecret = keySecret;
|
|
@@ -36,11 +36,13 @@ export class LaraProvider extends providers.ChunkedRemoteTranslationProvider {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async #getLara() {
|
|
39
|
-
|
|
39
|
+
// @ts-ignore - keySecret can be a function or value, TypeScript doesn't narrow correctly
|
|
40
|
+
const resolvedSecret = await (typeof this.#keySecret === 'function' ? this.#keySecret() : this.#keySecret);
|
|
41
|
+
const credentials = new Credentials(this.#keyId, resolvedSecret);
|
|
40
42
|
return new Translator(credentials);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
prepareTranslateChunkArgs({ sourceLang, targetLang, xmlTus, instructions }) {
|
|
45
|
+
prepareTranslateChunkArgs({ sourceLang, targetLang, xmlTus, jobGuid, chunkNumber, instructions }) {
|
|
44
46
|
const payload = xmlTus.map(xmlTu => {
|
|
45
47
|
const textBlock = [];
|
|
46
48
|
textBlock.push({ text: `bundle: ${xmlTu.bundle} key: ${xmlTu.key} notes: ${xmlTu.notes ?? ''}`, translatable: false });
|
|
@@ -48,7 +50,7 @@ export class LaraProvider extends providers.ChunkedRemoteTranslationProvider {
|
|
|
48
50
|
return textBlock;
|
|
49
51
|
}).flat(1);
|
|
50
52
|
const translateOptions = instructions ? { ...this.#translateOptions, instructions: [...this.#translateOptions.instructions, instructions] } : this.#translateOptions;
|
|
51
|
-
return { payload, sourceLang, targetLang, translateOptions };
|
|
53
|
+
return { payload, sourceLang, targetLang, xmlTus, jobGuid, chunkNumber, translateOptions };
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
async startTranslateChunk(args) {
|
package/mmtProvider.js
CHANGED
|
@@ -3,7 +3,6 @@ import { ModernMT as MMTClient } from 'modernmt';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {object} MMTProviderOptions
|
|
6
|
-
* @extends ChunkedRemoteTranslationProviderOptions
|
|
7
6
|
* @property {string} [id] - Global identifier (by default 'MMTBatch' or 'MMTRealtime')
|
|
8
7
|
* @property {Promise<string>|string} apiKey - The ModernMT API key.
|
|
9
8
|
* @property {string} [webhook] - The webhook URL for batch translation.
|
|
@@ -26,6 +25,7 @@ export class MMTProvider extends providers.ChunkedRemoteTranslationProvider {
|
|
|
26
25
|
*/
|
|
27
26
|
constructor({ id, apiKey, webhook, chunkFetcher, hints, glossaries, ignoreGlossaryCase, multiline = true, ...options }) {
|
|
28
27
|
id ??= webhook ? 'MMTBatch' : 'MMTRealtime';
|
|
28
|
+
// @ts-ignore - spread loses type info but parent class handles validation
|
|
29
29
|
super({ id, ...options });
|
|
30
30
|
if (webhook) {
|
|
31
31
|
if (chunkFetcher) {
|
|
@@ -51,8 +51,11 @@ export class MMTProvider extends providers.ChunkedRemoteTranslationProvider {
|
|
|
51
51
|
return {
|
|
52
52
|
sourceLang,
|
|
53
53
|
targetLang,
|
|
54
|
+
xmlTus,
|
|
55
|
+
jobGuid,
|
|
56
|
+
chunkNumber,
|
|
54
57
|
q: xmlTus.map(xmlTu => xmlTu.source),
|
|
55
|
-
hints:this.baseRequest.hints,
|
|
58
|
+
hints: this.baseRequest.hints,
|
|
56
59
|
contextVector: undefined,
|
|
57
60
|
options: this.baseRequest.options,
|
|
58
61
|
webhook: this.baseRequest.webhook,
|
|
@@ -67,7 +70,9 @@ export class MMTProvider extends providers.ChunkedRemoteTranslationProvider {
|
|
|
67
70
|
async startTranslateChunk(args) {
|
|
68
71
|
const { sourceLang, targetLang, q, hints, contextVector, options, webhook, batchOptions } = args;
|
|
69
72
|
try {
|
|
70
|
-
|
|
73
|
+
// @ts-ignore - apiKey can be a function or value, TypeScript doesn't narrow correctly
|
|
74
|
+
const resolvedKey = await (typeof this.#apiKey === 'function' ? this.#apiKey() : this.#apiKey);
|
|
75
|
+
const mmt = new MMTClient(resolvedKey, 'l10n.monster/MMT', '3.0');
|
|
71
76
|
if (webhook) {
|
|
72
77
|
const response = await mmt.batchTranslate(webhook, sourceLang, targetLang, q, hints, contextVector, batchOptions);
|
|
73
78
|
return { enqueued: response };
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@l10nmonster/helpers-translated",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Helpers to integrate with Translated.com",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "node --test"
|
|
8
|
+
"test": "node --test",
|
|
9
|
+
"typecheck": "tsc --noEmit"
|
|
9
10
|
},
|
|
10
11
|
"author": "Diego Lagunas",
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"peerDependencies": {
|
|
13
|
-
"@l10nmonster/core": "3.1.
|
|
14
|
+
"@l10nmonster/core": "3.1.1"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@translated/lara": "^1.4.0",
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.base.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"*.js",
|
|
5
|
+
"**/*.js"
|
|
6
|
+
],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"node_modules",
|
|
9
|
+
"**/node_modules",
|
|
10
|
+
"test/**",
|
|
11
|
+
"tests/**",
|
|
12
|
+
"**/*.test.js",
|
|
13
|
+
"**/*.spec.js",
|
|
14
|
+
"dist/**",
|
|
15
|
+
"ui/**",
|
|
16
|
+
"types/**"
|
|
17
|
+
]
|
|
18
|
+
}
|
package/.releaserc.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": [
|
|
3
|
-
"main",
|
|
4
|
-
{
|
|
5
|
-
"name": "next",
|
|
6
|
-
"prerelease": "alpha"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "beta",
|
|
10
|
-
"prerelease": "beta"
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"tagFormat": "@l10nmonster/helpers-translated@${version}",
|
|
14
|
-
"plugins": [
|
|
15
|
-
"@semantic-release/commit-analyzer",
|
|
16
|
-
"@semantic-release/release-notes-generator",
|
|
17
|
-
{
|
|
18
|
-
"path": "@semantic-release/changelog",
|
|
19
|
-
"changelogFile": "CHANGELOG.md"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "@semantic-release/npm",
|
|
23
|
-
"npmPublish": false
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"path": "@semantic-release/git",
|
|
27
|
-
"assets": ["CHANGELOG.md", "package.json"],
|
|
28
|
-
"message": "chore(release): @l10nmonster/helpers-translated@${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|