Skip to content

External QA Check

The External QA Check tool allows you to validate translations before they are delivered to the end-users. This tool is useful when you need to check translations for specific requirements, such as placeholders, forbidden words, or any other custom rules.

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',
externalQaCheck: {
batchSize: 500,
validate: async ({
client,
file,
project,
sourceLanguage,
strings,
targetLanguage,
translations,
context
}) => {
const validations = translations.map((translation) => {
const string = strings.find(string => string.id === translation.stringId);
if (string.text.includes('bk')) {
const checkRegexp = new RegExp(`\\W${targetLanguage.id}\\W${string.text}`, 'g');
return {
translationId: translation.id,
passed: checkRegexp.test(translation.text),
error: {
message: 'String contains "bk"'
}
};
}
return {
translationId: translation.id,
passed: true
};
});
return { validations };
}
}
};
crowdinModule.createApp(configuration);
ParameterDescriptionAllowed valuesDefault value
batchSizeThe number of translations to process at once.Integer-

This function is called for each batch of translations to check them against the specified rules.

  • client - Crowdin API client.
  • file - File object.
  • project - Project object.
  • sourceLanguage - Source language object.
  • strings - Array of strings.
  • targetLanguage - Target language object.
  • translations - Array of translations.
  • context - Context object.

The function should return an object with the following structure:

{
validations: [
{
translationId: number,
passed: boolean,
error?: {
message: string
}
}
]
}

A successful validation should have the passed property set to true. If the validation fails, set the passed property to false and provide an error message.

You can register multiple external QA checks in a single app by providing an array:

index.js
const configuration = {
// ... other configuration
externalQaCheck: [
{
name: 'Placeholder Check',
validate: async ({ strings, translations }) => ({
validations: translations.map((t) => ({ translationId: t.id, passed: true }))
})
},
{
name: 'Forbidden Words Check',
batchSize: 200,
validate: async ({ strings, translations }) => ({
validations: translations.map((t) => ({ translationId: t.id, passed: true }))
})
}
]
};