Categories
Maintaining the integrity of uppercase words in translations
Requires Crowdin account
var sourceUppercaseMatches = crowdin.source.match(/\b([A-Z]+)\b/g) || [];
var translationText = crowdin.translation;
var check = true;
var missingMatches = [];
for (var i = 0; i < sourceUppercaseMatches.length; i++) {
if (translationText.indexOf(sourceUppercaseMatches[i]) === -1) {
check = false;
missingMatches.push(sourceUppercaseMatches[i]);
}
}
var result = {
success: check
};
if (!check) {
result.message = 'The uppercase words ' + missingMatches.join(', ') + ' from the source text are missing in the translation';
}
return result;