@crowdin/app-project-module 0.16.2 → 0.16.3
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 +36 -0
- package/out/handlers/manifest.js +22 -8
- package/out/models/index.d.ts +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -519,6 +519,42 @@ const configuration = {
|
|
|
519
519
|
crowdinModule.createApp(configuration);
|
|
520
520
|
```
|
|
521
521
|
|
|
522
|
+
Also custom file format module can support strings export.
|
|
523
|
+
|
|
524
|
+
```javascript
|
|
525
|
+
const crowdinModule = require('@crowdin/app-project-module');
|
|
526
|
+
const convert = require('xml-js');
|
|
527
|
+
|
|
528
|
+
const configuration = {
|
|
529
|
+
baseUrl: 'https://123.ngrok.io',
|
|
530
|
+
clientId: 'clientId',
|
|
531
|
+
clientSecret: 'clientSecret',
|
|
532
|
+
name: 'Sample App',
|
|
533
|
+
identifier: 'sample-app',
|
|
534
|
+
description: 'Sample App description',
|
|
535
|
+
dbFolder: __dirname,
|
|
536
|
+
imagePath: __dirname + '/' + 'logo.png',
|
|
537
|
+
customFileFormat: {
|
|
538
|
+
type: 'type-xyz',
|
|
539
|
+
stringsExport: true,
|
|
540
|
+
extensions: [
|
|
541
|
+
'.resx'
|
|
542
|
+
],
|
|
543
|
+
parseFile: async (file, req, client, context, projectId) => {
|
|
544
|
+
//parse logic
|
|
545
|
+
return { strings: [] };
|
|
546
|
+
},
|
|
547
|
+
buildFile: async (file, req, strings, client, context, projectId) => {
|
|
548
|
+
const isStringsExport = !!req.file.path;
|
|
549
|
+
//export logic
|
|
550
|
+
return { contentFile: {} }
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
crowdinModule.createApp(configuration);
|
|
556
|
+
```
|
|
557
|
+
|
|
522
558
|
### Custom MT
|
|
523
559
|
|
|
524
560
|
Example of [custom mt module](https://support.crowdin.com/crowdin-apps-modules/#custom-mt-machine-translation-module).
|
package/out/handlers/manifest.js
CHANGED
|
@@ -15,14 +15,28 @@ function handle(config) {
|
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
17
|
if (config.customFileFormat) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
if (config.customFileFormat.stringsExport) {
|
|
19
|
+
modules['custom-file-format'] = [
|
|
20
|
+
{
|
|
21
|
+
key: config.identifier + '-ff',
|
|
22
|
+
type: config.customFileFormat.type,
|
|
23
|
+
stringsExport: true,
|
|
24
|
+
extensions: config.customFileFormat.extensions,
|
|
25
|
+
url: '/process',
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
modules['custom-file-format'] = [
|
|
31
|
+
{
|
|
32
|
+
key: config.identifier + '-ff',
|
|
33
|
+
type: config.customFileFormat.type,
|
|
34
|
+
multilingual: !!config.customFileFormat.multilingual,
|
|
35
|
+
signaturePatterns: config.customFileFormat.signaturePatterns,
|
|
36
|
+
url: '/process',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
}
|
|
26
40
|
}
|
|
27
41
|
if (config.customMT) {
|
|
28
42
|
modules['custom-mt'] = [
|
package/out/models/index.d.ts
CHANGED
|
@@ -390,6 +390,14 @@ export interface CustomFileFormatLogic {
|
|
|
390
390
|
* Flag to automatically upload translations
|
|
391
391
|
*/
|
|
392
392
|
autoUploadTranslations?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Enable strings export
|
|
395
|
+
*/
|
|
396
|
+
stringsExport?: boolean;
|
|
397
|
+
/**
|
|
398
|
+
* File extensions (used for strings export)
|
|
399
|
+
*/
|
|
400
|
+
extensions?: string[];
|
|
393
401
|
/**
|
|
394
402
|
* Used for initial source file upload, source file update, and translation upload
|
|
395
403
|
*/
|
|
@@ -397,7 +405,7 @@ export interface CustomFileFormatLogic {
|
|
|
397
405
|
/**
|
|
398
406
|
* Used for translation download
|
|
399
407
|
*/
|
|
400
|
-
buildFile: (fileContent: string | object, req: Omit<ProcessFileRequest, 'jobType'
|
|
408
|
+
buildFile: (fileContent: string | object, req: Omit<ProcessFileRequest, 'jobType'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
401
409
|
}
|
|
402
410
|
export interface SignaturePatterns {
|
|
403
411
|
fileName?: string;
|
|
@@ -414,6 +422,7 @@ export interface ProcessFileRequest {
|
|
|
414
422
|
export interface ProcessFileRecord {
|
|
415
423
|
content?: string;
|
|
416
424
|
contentUrl?: string;
|
|
425
|
+
path?: string;
|
|
417
426
|
}
|
|
418
427
|
export declare enum ProcessFileJobType {
|
|
419
428
|
PARSE_FILE = "parse-file",
|
package/package.json
CHANGED