@l10nmonster/helpers-lqaboss 3.0.0-alpha.11 → 3.0.0-alpha.13
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/flowCapture.js +3 -6
- package/lqabossProvider.js +5 -1
- package/lqabossTmStore.js +1 -1
- package/package.json +1 -1
package/flowCapture.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
1
2
|
import JSZip from 'jszip';
|
|
2
3
|
import puppeteer from 'puppeteer';
|
|
3
4
|
import { logInfo, logVerbose } from '@l10nmonster/core';
|
|
@@ -24,7 +25,7 @@ async function extractTextAndMetadataInPageContext() {
|
|
|
24
25
|
|
|
25
26
|
const textElements = [];
|
|
26
27
|
const START_MARKER_REGEX = /(?<![''<])\u200B([\uFE00-\uFE0F]+)/g;
|
|
27
|
-
const END_MARKER = '\
|
|
28
|
+
const END_MARKER = '\u200C';
|
|
28
29
|
|
|
29
30
|
if (!document.body) {
|
|
30
31
|
return { error: 'Document body not found.' };
|
|
@@ -221,12 +222,8 @@ export class FlowSnapshotter {
|
|
|
221
222
|
const job = {
|
|
222
223
|
sourceLang: tm.sourceLang,
|
|
223
224
|
targetLang: tm.targetLang,
|
|
224
|
-
tus:
|
|
225
|
+
tus: Object.values(await tm.getEntries(Array.from(guids))),
|
|
225
226
|
};
|
|
226
|
-
guids.forEach(guid => {
|
|
227
|
-
const tu = tm.getEntryByGuid(guid);
|
|
228
|
-
tu && job.tus.push(tu);
|
|
229
|
-
});
|
|
230
227
|
if (job.tus.length > 0) {
|
|
231
228
|
zip.file('job.json', JSON.stringify(job, null, 2));
|
|
232
229
|
}
|
package/lqabossProvider.js
CHANGED
|
@@ -5,6 +5,7 @@ import { providers, logVerbose, styleString, opsManager } from '@l10nmonster/cor
|
|
|
5
5
|
* @typedef {object} LQABossProviderOptions
|
|
6
6
|
* @extends BaseTranslationProvider
|
|
7
7
|
* @property {Object} delegate - Required file store delegate implementing file operations
|
|
8
|
+
* @property {string} [urlPrefix] - Prefix for the LQA Boss URL
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -12,15 +13,17 @@ import { providers, logVerbose, styleString, opsManager } from '@l10nmonster/cor
|
|
|
12
13
|
*/
|
|
13
14
|
export class LQABossProvider extends providers.BaseTranslationProvider {
|
|
14
15
|
#storageDelegate;
|
|
16
|
+
urlPrefix;
|
|
15
17
|
#opNames = {};
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Initializes a new instance of the LQABossProvider class.
|
|
19
21
|
* @param {LQABossProviderOptions} options - Configuration options for the provider.
|
|
20
22
|
*/
|
|
21
|
-
constructor({ delegate, ...options }) {
|
|
23
|
+
constructor({ delegate, urlPrefix, ...options }) {
|
|
22
24
|
super(options);
|
|
23
25
|
this.#storageDelegate = delegate;
|
|
26
|
+
this.urlPrefix = urlPrefix;
|
|
24
27
|
this.#opNames.startReviewOp = `${this.id}.startReviewOp`;
|
|
25
28
|
opsManager.registerOp(this.startReviewOp.bind(this), { opName: this.#opNames.startReviewOp, idempotent: false });
|
|
26
29
|
}
|
|
@@ -49,6 +52,7 @@ export class LQABossProvider extends providers.BaseTranslationProvider {
|
|
|
49
52
|
const filename = `${jobResponse.jobGuid}.lqaboss`;
|
|
50
53
|
await this.#storageDelegate.saveFile(filename, buffer);
|
|
51
54
|
logVerbose`Saved LQABoss file ${filename} with ${tus.length} guids and ${buffer.length} bytes`;
|
|
55
|
+
jobResponse.statusDescription = `Created LQA Boss file${this.urlPrefix ? ` at ${this.urlPrefix}/${filename}` : ''}`;
|
|
52
56
|
jobResponse.tus = []; // remove tus so that job is cancelled and won't be stored
|
|
53
57
|
return jobResponse;
|
|
54
58
|
}
|
package/lqabossTmStore.js
CHANGED