File Pre-Export
The pre-export app allows you to modify the strings before the file export. This type of app works with both the source strings and their respective translations.
File Pre-Export Processing Module Read more on the Crowdin Developer Portal.
Sample
const crowdinModule = require('@crowdin/app-project-module');
const configuration = { baseUrl: 'https://123.ngrok.io', clientId: 'clientId', clientSecret: 'clientSecret', name: 'Sample App', identifier: 'sample-app', description: 'Sample App description', dbFolder: __dirname, imagePath: __dirname + '/' + 'logo.png', filePreExport: { filesFolder: `${__dirname}/db`, signaturePatterns: { fileName: "^.+\\..+$", fileContent: ".*" }, fileProcess: async (req, strings, client, context, projectId) => { return { strings: [] }; } }};
crowdinModule.createApp(configuration);
Configuration
Parameter | Description |
---|---|
filesFolder | Folder where large files are temporarily stored. |
signaturePatterns | Contains fileName and/or fileContent regular expressions used to detect file type when uploading a new source file via UI or API. |
fileProcess
Function
This function is called before exporting the file.
Parameters
req
- Request object.strings
- Strings to be processed.client
- Crowdin API client.context
- Context object.projectId
- Crowdin project ID.
Return Value
The function should return an object with the following properties:
{ strings: string[]; error?: string; notModified?: boolean;}
Description:
strings
- the processed strings.notModified
- optional, should be set totrue
if the file processor does not make any changes to the file.error
- optional, and should contain an error message if the file processor encounters an error.