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
Section titled “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
Section titled “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
Section titled “fileProcess Function”This function is called before importing parsed strings into Crowdin.
Parameters
Section titled “Parameters”req- Request object.strings- Strings to be processed.client- Crowdin API client.context- Context object.projectId- Crowdin project ID.
Return Value
Section titled “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 totrueif 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.