自定义品质保证 (QA) 检查可帮助客户和翻译员更正拼写、标点符号、术语、格式等方面的错误。 代码片段是一段可帮助创建自定义品质保证检查并将其集成到 Crowdin 的代码。
代码片段基于 Javascript。 它包含一个 crowdin
对象和一些属性。 要创建代码片段,请使用此对象模板输入代码:
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
}
在 Crowdin 脚本编辑器 中找到自定义品质保证检查代码片段的示例。 使用链接查看代码片段的结构,使用您的数据对其进行编辑并验证您的代码是否正确。
代码片段请求包含下面列出的键值:
contentType – 字符串可以包括 3 种类型之一:
参见代码片段请求示例:
{
"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 '
}
运行代码片段后,它应该返回自定义品质保证检查是否成功通过的响应:
success
属性,指示品质保证检查是否已通过。 就像这样:{
"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
属性(对象数组),因为它可以为译者节省大量时间和精力。{
"from_pos": 0,
"to_pos": 1,
"replacement": ""
}
from_pos
是 translation
字符串中开始替换的字符位置。 to_pos
是字符的结束位置。 replacement
属性是应该放在 from_pos
和 to_pos
之间的文本。