Skip to content

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.

index.js
import crowdinModule from '@crowdin/app-project-module';
const generatePreviewFile = (file, strings) => {
// preview file generation logic
return Buffer.from('');
};
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: import.meta.dirname,
imagePath: import.meta.dirname + '/logo.png',
filePostImport: [
{
filesFolder: `${import.meta.dirname}/db`,
signaturePatterns: {
fileName: "^.+\\..+$",
fileContent: ".*"
},
fileProcess: async ({ request, content: strings, client, context, projectId }) => {
return {
strings: [],
previewFile: generatePreviewFile(request.file, strings),
};
}
}
]
};
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.

This function is called before importing parsed strings into Crowdin.

  • request - Request object.
  • content - Strings to be processed (an array of ProcessFileString objects).
  • client - Crowdin API client.
  • context - Context object.
  • projectId - Crowdin project ID.

The function should return an object with the following properties:

{
strings: ProcessFileString[];
previewFile?: Buffer;
notModified?: boolean;
error?: string;
}

Description:

  • strings - the processed strings (an array of ProcessFileString objects).
  • previewFile - optional, content that will be displayed as a preview in the Crowdin Editor.
  • notModified - optional, should be set to true 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.