Skip to content

Custom MT

This module helps you connect machine translation engines not yet supported by Crowdin.

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',
customMT: {
withContext: true,
translate: async (client, context, projectId, source, target, strings) => {
const translations = ['hello', 'world'];
if (source === 'fr') {
throw 'Source language is not supported by the model';
}
return translations;
},
validate: (client) => {
console.log('validate');
}
}
};
crowdinModule.createApp(configuration);
ParameterDescriptionAllowed valuesDefault value
withContextIf true, strings will be received as objects.true, falsefalse

Called when the module is requested to translate strings.

  • client - Crowdin API client.
  • context - Context object.
  • projectId - Crowdin project ID (optional and could be null).
  • source - Source language.
  • target - Target language.
  • strings - Array of strings to translate.

The function must return an array of translated strings.

This function is optional. It is called when the module is initialized to validate if the module is correctly configured.

  • client - Crowdin API client.

The function must return nothing.

In case of an error, the function must throw an error with a message. The message will be displayed in the Crowdin UI.