Skip to content

File Post-Export

The post-export app allows you to modify your files after exporting them from Crowdin. With this type of app, you can apply automated modifications to selected files.

index.js
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',
filePostExport: {
filesFolder: `${__dirname}/db`,
signaturePatterns: {
fileName: "^.+\\..+$",
fileContent: ".*"
},
fileProcess: async (req, contentFile, client, context, projectId) => {
contentFile = Buffer.from(
contentFile.toString().replace('<text-to-replace>','<content>')
);
return { contentFile };
}
}
};
crowdinModule.createApp(configuration);
Parameter
Description
filesFolderFolder where large files are temporarily stored.
signaturePatternsContains fileName and/or fileContent regular expressions used to detect file type when uploading a new source file via UI or API.
processAssetsSet to true to enable processing of assets (e.g., images, videos) within the application. By default, assets are not processed.

This function is called for each file that is exported from Crowdin.

  • req - Request object.
  • contentFile - File content.
  • client - Crowdin API client.
  • context - Context object.
  • projectId - Crowdin project ID.

The function should return the following object:

{
contentFile: Buffer | string,
notModified?: boolean,
error?: string
}

Description:

  • contentFile - should contain the modified file content.
  • notModified - optional, should be set to true if the file processor does not make any changes to the file.
  • error - optional, should contain an error message if the file processor encounters an error.