The custom quality assurance (QA) checks help customers and translators to correct errors in spelling, punctuation, terminology, formatting, and more. Code Snippet is a piece of code that helps to create custom QA checks and integrate them to Crowdin.
Code Snippet is Javascript-based. It Includes a crowdin
object and a number of properties. To create the code snippet, use this object template for code input:
object crowdin {
object file {
string name,
string fullName,
string branch,
string type
}
string sourceLanguage,
string targetLanguage,
object context {
string context,
?int maxLength,
?string pluralForm,
?string identifier
},
string contentType,
string source,
string translation
}
Find the example of a custom QA check code snippet in Crowdin Script Editor. Use the link to see the structure of code snippet, edit it with your data and verify your code is correct.
The code snippet request includes the keys listed below:
contentType – string can include one of the 3 types:
See the example of code snippet request:
{
"file": {
"name": "strings.json",
"fullName": "backend/strings.json",
"branch": "master",
"type": "json"
}
"sourceLanguage": 'en',
"targetLanguage": 'de',
"context": {
"context": "backend.string.example.plain",
"maxLength": 10,
"pluralForm": 'one',
"identifier": "6a1821e6499ebae94de4b880fd93b985"
},
"contentType": 'application/vnd.crowdin.text+plural',
"source": '{"one":"Password", "other":"Passwords"}',
"translation": 'das Passwort '
}
After running the code snippet, it should return the response whether the custom QA checks have passed successfully or failed:
success
property indicating whether QA checks have passed. For instance:{
"success": true
}
{
"success": false,
"message": "The sentence starts with space, please remove 1 space at the beginning of the translation.",
"fixes": [
{
"from_pos": 0,
"to_pos": 1,
"replacement": ""
}
]
}
fixes
property (an array of objects) since it can save a lot of time and effort for translators.{
"from_pos": 0,
"to_pos": 1,
"replacement": ""
}
The from_pos
is a character position in the translation
string where the replacement starts. The to_pos
is the end of character position. The replacement
property is the text that should be placed between from_pos
and to_pos
.