Translations Alignment
The translations alignment app lets you align translations with source strings after export. It receives source strings and translations, and should return aligned translations mapped to source string IDs.
Translations Alignment 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', fileTranslationsAlignmentExport: { filesFolder: `${__dirname}/db`, signaturePatterns: { fileName: "^.+\\..+$", fileContent: ".*" }, fileProcess: async (req, content, client, context, projectId) => { // content.sourceStrings and content.translationStrings can be arrays of strings objects or Buffers
// Example minimal response: alignments for a subset of source strings return { strings: [ { sourceStringId: 1, text: 'Aligned translation for string #1' }, { sourceStringId: 2, text: 'Aligned translation for string #2' } ] }; } }};
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. |
storeFile | Optional handler to store large responses and return a URL to download them. |
fileProcess Function
This function is called for running translations alignment.
Parameters
req- Request object.content- Object containing two fields:sourceStringsandtranslations(arrays or Buffers).client- Crowdin API client.context- Context object.projectId- Crowdin project ID.
Return Value
Return an object with the following structure:
{ translations?: { sourceStringId: number, text: string | { one: string, other?: string, few?: string, many?: string } }[], error?: string}Description:
translations- aligned translations mapped to the source string IDs. If the response is large, the module will store it and return a URL internally.error- optional, should contain an error message if the processor encounters an error.