File Post-Import
The post-import app allows you to modify the strings parsed from your files after the file import. This type of app works with both the source strings and their respective translations.
File Post-Import 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', filePostImport: { filesFolder: `${__dirname}/db`, signaturePatterns: { fileName: "^.+\\..+$", fileContent: ".*" }, fileProcess: async (req, strings, client, context, projectId) => {
return { strings: [], previewFile: generatePreviewFile(req.file, 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 importing parsed strings into Crowdin.
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[]; previewFile?: string; notModified?: boolean; error?: string;}
Description:
strings
- the processed strings.previewFile
- optional, content that will be displayed as a preview in the Crowdin Editor.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.