Crowdin 查询语言 (CroQL)
Crowdin Query Language (CroQL) 是适用于 Crowdin 编辑器、Crowdin Enterprise 编辑器以及 Crowdin 和 Crowdin Enterprise API 的工具,可让您根据特定条件检索所需的本地化资源。 使用 CroQL,您可以筛选源字符串及其针对特定目标语言的翻译、翻译记忆片段和术语库术语。
您可以通过以下 API 方法使用 CroQL:
主要的 CroQL 运算符如下所示。 使用和组合它们,为从 Crowdin 检索所需的内容设置具体条件。 要构建您的 CroQL 查询,可以使用以下表格中的元素。
算术运算符用于对任何数值数据类型进行数学运算。
| 名称 | 符号 | 示例 |
|---|---|---|
| 加法 | * | 1 + 9 |
| 减法 | - | 11 - 1 |
| 除法 | / | 20 / 2 |
| 乘法 | * | 2 * 5 |
| 取反 | - | -10 |
比较运算符用于比较值并返回 true 或 false。
| 名称 | 符号 | 別名 | 示例 |
|---|---|---|---|
| 在…之间 | {{expression}} between {{expression}} and {{expression}} | 5 between 1 and 10 | |
| 相等 | = | 10 = 10 | |
| 不等 | != | ≠ | 1 != 10; 1 ≠ 10 |
| 大于 | > | 10 > 1 | |
| 大于或等于 | >= | ≥ | 10 >= 1; 10 ≥ 1 |
| 小于 | < | 1 < 10 | |
| 小于或等于 | <= | ≤ | 1 <= 10; 1 ≤ 10 |
| 包含 | {{string}} contains {{string}} | "Hello World" contains "Hello"; "Hello World" contains text; text contains "Hello World"; context contains text |
逻辑运算符用于组合多个布尔表达式或值,并提供一个布尔值输出。
| 名称 | 符号 | 示例 |
|---|---|---|
| 与 | and | 1 < 10 and 10 > 1 |
| 或 | or | 1 < 10 or 10 > 1 |
| 异或 | xor | 1 < 10 xor 10 > 1 |
| 非 | not | not 1 < 10 |
过滤运算符用于根据指定的条件过滤对象。
| 名称 | 符号 | 示例 |
|---|---|---|
| 过滤 | {{collection}} where {{predicate}} | translations where (count of votes > 0) |
| 匹配 | {{object}} with {{predicate}} | user with (login = "crowdin") |
三元运算符用于检查第一个值中指定的条件,如果是 true 则返回第二个值,如果是 false 则返回第三个值。
| 名称 | 符号 | 示例 |
|---|---|---|
| 三元 | If {{condition}} then {{expression}} else {{expression}} | If 1 \< 10 then "less" else "greater" |
Fetch 运算符用于从对象中获取数据。
| 名称 | 符号 | 示例 |
|---|---|---|
| 提及 | @user:{{string}}; @language:{{string}} | @user:"crowdin"; @language:"en" |
| 成员 | {{member}} of {{object}} | count of translations |
| 标识符 | {{identifier}} | text; identifier |
标量运算符用于声明用于进一步处理的值。
| 名称 | 符号 | 示例 |
|---|---|---|
| 整数 | {{integer}} | 10 |
| 浮点数 | {{float}} | 10.01 |
| 字符串 | {{string}} | ”crowdin” |
| 日期时间 | {{datetime}} | ’today’; ‘2021-03-16 00:00:00’ |
分组运算符用于确定运算符的执行顺序。
| 名称 | 符号 | 示例 |
|---|---|---|
| 分组 | ( ) | 1 < 10 and (20 > 10 or 10 > 5) |
在本节中,您可以找到 CroQL 查询的实用示例,帮助您理解和使用 Crowdin 中的查询功能。 这些示例可以帮助您学习如何创建自己的查询,根据各种条件(如翻译状态、用户活动和字符串属性)检索特定的数据集。
这些查询用于检索源字符串的相关信息。
-
没有带审批或投票的乌克兰语译文的字符串:
count of translations where ( language = @language:"uk" and ( count of approvals > 0 or count of votes > 0 ) ) = 0 -
只有一条译文的字符串:
count of translations = 1 -
只有来自某一特定用户的译文的字符串:
count of translations > 0 and count of translations = count of translations where (user = @user:"crowdin") -
至少有一条不来自特定用户的译文的字符串:
count of translations where (user != @user:"crowdin") > 0 -
所有译文均不来自特定用户的字符串:
count of translations > 0 and count of translations = count of translations where (user != @user:"crowdin") -
按标识符和 Crowdin 项目中文件的数字 ID 筛选的字符串:
identifier = "key" and id of file = 777 -
按 Crowdin 项目中文件的数字 ID 筛选的含有未解决问题的字符串:
id of file = 777 and count of comments where (has unresolved issue) > 0 -
不是重复项且有一条或多条译文的隐藏字符串:
is hidden and not is duplicate and count of translations > 0 -
有一条或多条审批的字符串:
count of languages summary where (approvalsCount >= 1) > 0 -
用户名为
crowdin的用户发表了评论的字符串:count of comments where (user = @user:"crowdin") > 0 -
源文本中包含 “ABC” 但译文中不包含 “ABC” 的字符串:
text contains "ABC" and (count of translations where (text contains "ABC") = 0)
这些查询用于根据分配给源字符串的字段检索相关信息。
-
具有特定字段名称和精确字段值的字符串:
使用场景:查找 “Priority” 字段设置为 “High” 的字符串。
count of fields where (name = "Priority" and value = "High") > 0 -
具有特定字段别名且值包含特定词语的字符串:
使用场景:查找 “category” 别名包含 “mobile” 一词的字符串。
count of fields where (slug = "field-category" and value contains "mobile") > 0 -
按名称应用了特定字段的字符串:
使用场景:查找所有分配了 “Department” 字段的字符串,无论值是什么。
count of fields where (name = "Department") > 0 -
按别名应用了特定字段的字符串:
使用场景:使用 “Owner” 字段的特定系统标识符查找字符串。
count of fields where (slug = "field-internal-owner") > 0 -
字段名称包含特定词语的字符串:
使用场景:查找包含任何与 “Status” 相关字段的字符串(例如:Legal Status、Review Status)。
count of fields where (name contains "Status") > 0 -
任意字段具有非空值的字符串:
使用场景:查找已填写任何元数据的字符串。
count of fields where (value != "") > 0 -
具有非空值的文本类型字段的字符串:
使用场景:用于确保元数据注释或描述已实际填写。
count of fields where (type = "text" and value != "") > 0 -
匹配多个特定字段名称且值包含特定词语的字符串:
使用场景:检查 “Platform” 或 “Environment” 字段是否包含 “Production” 一词。
count of fields where ((name = "Platform" or name = "Environment") and value contains "Production") > 0
在 Crowdin API 中使用字符串和字段查询
在以下 Crowdin API 端点中使用您的查询:
GET https://api.crowdin.com/api/v2/projects/{projectId}/strings?croql={croql}GET https://{organization_domain}.api.crowdin.com/api/v2/projects/{projectId}/strings?croql={croql}| 参数 | 详细信息 |
|---|---|
{projectId} | 类型: integer描述: Crowdin 项目的数字标识符。 |
{croql} | 类型: string描述: CroQL 表达式。 |
这些查询用于检索译文的相关信息。
- 由用户名为
crowdin的用户提交的译文,或获得 ≥ 100 个赞成票的译文:user = @user:"crowdin" or count of votes where ( is up ) >= 100
在 Crowdin API 中使用译文查询
在以下 Crowdin API 端点中使用您的查询:
GET https://api.crowdin.com/api/v2/projects/{projectId}/languages/uk/translations?croql={croql}GET https://{organization_domain}.api.crowdin.com/api/v2/projects/{projectId}/languages/uk/translations?croql={croql}| 参数 | 详细信息 |
|---|---|
{projectId} | 类型: integer描述: Crowdin 项目的数字标识符。 |
{croql} | 类型: string描述: CroQL 表达式。 |
这些查询用于检索翻译记忆片段的相关信息。
-
包含至少一条使用过一次或多次的记录的翻译记忆片段:
count of records where (usageCount > 0) > 0 -
包含至少一条由用户名为
crowdin的用户创建的记录的翻译记忆片段:count of records where (createdBy = @user:"crowdin") > 0
在 Crowdin API 中使用翻译记忆片段查询
在以下 Crowdin API 端点中使用您的查询:
GET https://api.crowdin.com/api/v2/tms/{tmId}/segments?croql={croql}GET https://{organization_domain}.api.crowdin.com/api/v2/tms/{tmId}/segments?croql={croql}| 参数 | 详细信息 |
|---|---|
{projectId} | 类型: integer描述: Crowdin 项目的数字标识符。 |
{croql} | 类型: string描述: CroQL 表达式。 |
这些查询用于检索术语库术语的相关信息。
-
由用户名为
crowdin的用户为乌克兰语创建的术语:user = @user:"crowdin" and language = @language:"uk" -
包含 “ABC” 且词性设置为名词的术语:
text contains "ABC" and partOfSpeech = "noun" -
标记为不推荐或已过时的术语:
status = "not_recommended" or status = "obsolete" -
类型为缩写词且包含备注的术语:
type = "abbreviation" and note contains "tooltip" -
在特定日期之后添加的术语:
createdAt > '2024-12-01 00:00:00' -
词元等于 “cancel” 且为英语的术语:
lemma = "cancel" and language = @language:"en" -
包含参考 URL 的术语:
url contains "https://"
在 Crowdin API 中使用术语库术语查询
在以下 Crowdin API 端点中使用您的查询:
GET https://api.crowdin.com/api/v2/glossaries/{glossaryId}/terms?croql={croql}GET https://{organization_domain}.api.crowdin.com/api/v2/glossaries/{glossaryId}/terms?croql={croql}| 参数 | 详细信息 |
|---|---|
{glossaryId} | 类型: integer描述: Crowdin 术语库的数字标识符。 |
{croql} | 类型: string描述: 用于筛选术语库术语条目的 CroQL 表达式。 |
- 已添加的字符串:
added between '2023-12-06 13:44:14' and '2023-12-07 13:44:14'
- 已更新的字符串:
updated between '2023-12-06 13:44:14' and '2023-12-07 13:44:14'
- 字符串类型:
type is plain or type is icu
- 评论:
count of comments > 0
- 截图:
count of screenshots > 0
- QA 问题:
count of languages summary where (has qa issues) > 0
- 未翻译:
count of languages summary = 0
- 部分翻译(复数形式):
count of languages summary where (is partially translated) > 0
- 已翻译:
count of languages summary where (is translated) > 0
- 翻译者:
count of translations where (user = @user:"crowdin") > 0
- 未由以下用户翻译:
count of translations where (user != @user:"crowdin") > 0
- 与源字符串相同:
count of languages summary where (has translation as source) > 0
- 已修改的源字符串:
count of languages summary where (is source changed after translation) > 0
- 已更新的译文:
count of languages summary where ( translation updated between '2023-12-06 13:44:14' and '2023-12-07 13:44:14') > 0
- 投票:
count of languages summary where (rating > 0) > 0
- 主字符串:
not is duplicate
- 仅限重复项:
is duplicate
- 共享译文的重复项:
is duplicate and count of languages summary where (has shared translation) > 0
- 有独立译文的重复项:
is duplicate and count of languages summary where (not has shared translation and is translated) > 0
- 已翻译,未审批:
count of languages summary where (is translated and not is approved) > 0
- 部分审批(复数形式):
count of languages summary where (is partially approved) > 0
- 已审批:
count of languages summary where (is approved) > 0
- 审批者:
count of translations where (count of approvals where (user = @user:"crowdin") > 0) > 0
- 未由以下用户审批:
count of translations where (count of approvals where (user != @user:"crowdin") > 0) > 0
- 审批后有新译文:
count of languages summary where (has translation after approval) > 0
- 由 MT 翻译:
count of languages summary where (is translated by mt) > 0
- 由翻译记忆翻译:
count of languages summary where (is translated by tm) > 0
- 由翻译记忆或 MT 翻译:
count of languages summary where (is auto translated) > 0
- 预翻译:
- 已使用:不可用
- 未使用:不可用
- 排序方式:不可用
- 口头表达:不可用
- 口头表达范围:不可用
CroQL 可以在以下上下文中使用:源字符串上下文、译文上下文和翻译记忆 (TM) 片段上下文。 使用以下示例作为构建 CroQL 查询的基础。
{ "type is plain": true, "type is plural": false, "type is icu": false, "type is asset": false, "text": "Quick Start", "identifier": "quick_start", "context": "quick_start", "max length": 0, "is visible": true, "is hidden": false, "is duplicate": false, "isPassedWorkflow": true, "fields": { "priority": "High", "legal-status": "approved" }, "file": { "id": 32, "name": "sample.csv", "title": "Sample", "type": "csv", "context": "Some useful context information" }, "branch": { "id": 7, "name": "main", "title": "Main" }, "comments": [ { "has issue": false, "has unresolved issue": false, "user": 1 } ],20 collapsed lines
"screenshots": [], "translations": [ { "text": "Швидкий старт", "plural form": "none", "is pre translated": true, "provider": "tm", "language": "uk", "user": 1, "votes": [ { "is up": true, "is down": false, "user": 2, "added": "2021-04-09 13:44:14" } ], "approvals": [ { "user": 2, "added": "2021-04-09 13:44:14" } ], "updated": "2021-04-09 10:23:17" }31 collapsed lines
], "languages summary": [ { "language": "en", "is translated": false, "is partially translated": false, "is approved": false, "is partially approved": false, "translation updated": false, "is auto translated": false, "is translated by tm": false, "is translated by mt": false, "is source changed after translation": false, "has translation as source": false, "has translation after approval": false, "has shared translation": false, "has qa issues": false, "has empty translation qa issues": false, "has translation length qa issues": false, "has tags mismatch qa issues": false, "has spaces mismatch qa issues": false, "has variables mismatch qa issues": false, "has punctuation mismatch qa issues": false, "has character case mismatch qa issues": false, "has special characters mismatch qa issues": false, "has incorrect translation qa issues": false, "has spelling qa issues": false, "has icu syntax qa issues": false, "has terms qa issues": false, "has duplicate translation qa issues": false, "has ftl syntax qa issues": false, "has android syntax qa issues": false, "has custom qa issues": false, "rating": 1, "approvalsCount": 1 } ], "labels": [ { "id": 1, "title": "label title", "is system": false } ], "added": "2021-04-08 12:33:27", "updated": "2021-04-08 12:33:27"}type is plain | 类型: 描述: 纯文本的源字符串。 |
type is plural | 类型: 描述: 带有复数形式的源字符串。 |
type is icu | 类型: 描述: 带有 ICU 的源字符串。 |
type is asset | 类型: 描述: 源字符串是资产。 |
text | 类型: 描述: 源字符串文本。 |
identifier | 类型: 描述: 源字符串标识符(键)。 |
context | 类型: 描述: 源字符串上下文。 |
max length | 类型: 描述: 源字符串最大长度。 |
is visible | 类型: 描述: 源字符串可见。 |
is hidden | 类型: 描述: 源字符串已隐藏。 |
is duplicate | 类型: 描述: 源字符串是重复项。 |
isPassedWorkflow | 类型: 描述: 仅限 Crowdin Enterprise。 源字符串已通过项目工作流。 |
fields | 类型: 描述: 仅限 Crowdin Enterprise。 包含分配给字符串的自定义属性(字段)的对象。 |
file | 类型: 描述: 源字符串文件。 |
branch | 类型: 描述: 源字符串分支。 |
comments | 类型: 描述: 源字符串评论。 |
has issue | 类型: 描述: 源字符串存在问题。 |
has unresolved issue | 类型: 描述: 源字符串存在未解决的问题。 |
user | 类型: 描述: 添加评论的用户的数字标识符。 |
screenshots | 类型: 描述: 源字符串截图。 |
translations | 类型: 描述: 源字符串的译文。 |
text | 类型: 描述: 译文文本。 |
plural form | 类型: 描述: 译文复数形式。 |
is pre translated | 类型: 描述: 通过自动翻译添加的译文。 |
provider | 类型: 允许的值: 描述: 通过翻译记忆或机器翻译引擎提供的译文。 |
language | 类型: 描述: 以字符串形式指定的语言标识符。 使用语言代码,例如,乌克兰语使用 |
user | 类型: 描述: 添加译文的用户的数字标识符。 |
votes | 类型: 描述: 添加到译文的投票数组。 |
is up | 类型: 描述: 赞成票。 |
is down | 类型: 描述: 反对票。 |
user | 类型: 描述: 为译文投票的用户的数字标识符。 |
added | 类型: 描述: 为译文添加投票的日期。 |
approvals | 类型: 描述: 已添加的译文审批数组。 |
user | 类型: 描述: 审批译文的用户的数字标识符。 |
added | 类型: 描述: 添加译文审批的日期。 |
updated | 类型: 描述: 译文更新的日期。 |
languages summary | 类型: 描述: 源字符串的顶级译文(优先级最高的译文)。 |
language | 类型: 描述: 以字符串形式指定的语言标识符。 使用语言代码,例如,乌克兰语使用 |
is translated | 类型: 描述: 源字符串已翻译。 |
is partially translated | 类型: 描述: 源字符串已部分翻译。 |
is approved | 类型: 描述: 源字符串已审批。 |
is partially approved | 类型: 描述: 源字符串已部分审批。 |
translation updated | 类型: 描述: 源字符串译文已更新。 |
is auto translated | 类型: 描述: 源字符串已由翻译记忆或 MT 翻译。 |
is translated by tm | 类型: 描述: 源字符串已由翻译记忆翻译。 |
is translated by mt | 类型: 描述: 源字符串已由 MT 翻译。 |
is source changed after translation | 类型: 描述: 翻译后源字符串已更改。 |
has translation as source | 类型: 描述: 源字符串的译文与源文本相同。 |
has translation after approval | 类型: 描述: 源字符串在审批后有新译文。 |
has shared translation | 类型: 描述: 源字符串的重复项具有来自主字符串的共享译文。 |
has qa issues | 类型: 描述: 源字符串存在 QA 问题。 |
has empty translation qa issues | 类型: 描述: 源字符串存在空译文 QA 问题。 |
has translation length qa issues | 类型: 描述: 源字符串存在译文长度 QA 问题。 |
has tags mismatch qa issues | 类型: 描述: 源字符串存在标签不匹配 QA 问题。 |
has spaces mismatch qa issues | 类型: 描述: 源字符串存在空格不匹配 QA 问题。 |
has variables mismatch qa issues | 类型: 描述: 源字符串存在变量不匹配 QA 问题。 |
has punctuation mismatch qa issues | 类型: 描述: 源字符串存在标点符号不匹配 QA 问题。 |
has character case mismatch qa issues | 类型: 描述: 源字符串存在字符大小写不匹配 QA 问题。 |
has special characters mismatch qa issues | 类型: 描述: 源字符串存在特殊字符不匹配 QA 问题。 |
has incorrect translation qa issues | 类型: 描述: 源字符串存在错误译文 QA 问题。 |
has spelling qa issues | 类型: 描述: 源字符串存在拼写 QA 问题。 |
has icu syntax qa issues | 类型: 描述: 源字符串存在 ICU 语法 QA 问题。 |
has terms qa issues | 类型: 描述: 源字符串存在术语 QA 问题。 |
has duplicate translation qa issues | 类型: 描述: 源字符串存在重复译文 QA 问题。 |
has ftl syntax qa issues | 类型: 描述: 源字符串存在 FTL 语法 QA 问题。 |
has android syntax qa issues | 类型: 描述: 源字符串存在 Android 语法 QA 问题。 |
has custom qa issues | 类型: 描述: 源字符串存在自定义 QA 问题。 |
rating | 类型: 描述: 源字符串译文评分。 |
approvalsCount | 类型: 描述: 译文审批数量。 |
labels | 类型: 描述: 源字符串标签。 |
id | 类型: 描述: 标签的数字标识符。 |
title | 类型: 描述: 标签标题。 |
is system | 类型: 描述: 系统标签(带有源文件名的标签,会自动添加到基于字符串的项目中的字符串)。 |
added | 类型: 描述: 源字符串的添加日期。 |
updated | 类型: 描述: 源字符串的更新日期。 |
{ "text": "Швидкий старт", "plural form": "none", "is pre translated": true, "provider": "tm", "user": 1, "votes": [ { "is up": true, "is down": false, "user": 2, "added": "2021-04-09 13:44:14" } ], "approvals": [ { "user": 2, "added": "2021-04-09 13:44:14" } ], "updated": "2021-04-09 10:23:17"}text | 类型: 描述: 译文文本。 |
plural form | 类型: 描述: 译文复数形式。 |
is pre translated | 类型: 描述: 通过自动翻译添加的译文。 |
provider | 类型: 允许的值: 描述: 通过翻译记忆或机器翻译引擎提供的译文。 |
user | 类型: 描述: 添加译文的用户的数字标识符。 |
votes | 类型: 描述: 添加到译文的投票数组。 |
is up | 类型: 描述: 赞成票。 |
is down | 类型: 描述: 反对票。 |
user | 类型: 描述: 为译文投票的用户的数字标识符。 |
added | 类型: 描述: 为译文添加投票的日期。 |
approvals | 类型: 描述: 已添加的译文审批数组。 |
user | 类型: 描述: 审批译文的用户的数字标识符。 |
added | 类型: 描述: 添加译文审批的日期。 |
updated | 类型: 描述: 译文更新的日期。 |
{ "records": [ { "id": 1, "text": "Перекладений текст", "usageCount": 77, "createdBy": 1, "updatedBy": 1, "createdAt": "2027-09-16T13:48:04+00:00", "updatedAt": "2027-09-16T13:48:04+00:00" } ]}records | 类型: 描述: 翻译记忆片段记录的数组。 |
id | 类型: 描述: 记录的数字标识符。 |
text | 类型: 描述: 记录的译文文本。 |
usageCount | 类型: 描述: 翻译记忆记录的使用次数。 |
createdBy | 类型: 描述: 创建翻译记忆记录的用户的数字标识符。 |
updatedBy | 类型: 描述: 更新翻译记忆记录的用户的数字标识符。 |
createdAt | 类型: 描述: 翻译记忆记录的创建日期。 |
updatedAt | 类型: 描述: 翻译记忆记录的更新日期。 |
{ "id": 101, "user": 12, "subject": "User Interfact", "definition": "A command used to save user progress in the application.", "url": "https://example.com/concept/save", "note": "Commonly used in forms and toolbars.", "translatable": true, "createdAt": "2027-09-16T13:48:04+00:00", "updatedAt": "2027-09-16T13:48:04+00:00"}id | 类型: 描述: 术语库概念的数字标识符。 |
user | 类型: 描述: 创建概念的用户的数字标识符。 |
subject | 类型: 描述: 概念所属的领域或知识范围(例如,UI、开发、医疗保健)。 |
definition | 类型: 描述: 概念的一般解释或定义。 |
url | 类型: 描述: 链接到包含更多概念信息的资源的 URL。 |
note | 类型: 描述: 为译者提供的补充信息或说明。 |
translatable | 类型: 描述: 指示该概念是否可以翻译成其他语言。 |
createdAt | 类型: 描述: 概念创建的日期和时间。 |
updatedAt | 类型: 描述: 概念最后更新的日期和时间。 |
{ "id": 301, "text": "Cancel", "description": "A command to stop or abort an operation.", "language": "en", "user": 42, "partOfSpeech": "verb", "status": "admitted", "type": "abbreviation", "gender": "neuter", "note": "Often used in confirmation dialogs.", "lemma": "cancel", "url": "https://example.com/term/cancel", "concept": 101, "createdAt": "2027-09-16T13:48:04+00:00", "updatedAt": "2027-09-16T13:48:04+00:00"}id | 类型: 描述: 术语库术语的数字标识符。 |
text | 类型: 描述: 术语本身,以指定语言表示。 |
description | 类型: 描述: 术语的附加解释或含义。 |
language | 类型: 描述: 以字符串形式指定的语言标识符。 使用语言代码,例如,乌克兰语使用 |
user | 类型: 描述: 添加术语的用户的数字标识符。 |
partOfSpeech | 类型: 允许的值: 描述: 术语的语法类别。 |
status | 类型: 允许的值: 描述: 指示术语的审批或使用级别。 |
type | 类型: 允许的值: 描述: 按结构或用途对术语进行分类。 |
gender | 类型: 允许的值: 描述: 术语的语法性别,如适用。 |
note | 类型: 描述: 为译者提供的额外指导或与术语相关的备注。 |
lemma | 类型: 描述: 术语的基本形式。 |
url | 类型: 描述: 术语的参考链接。 |
concept | 类型: 描述: 术语所属概念的 ID。 |
createdAt | 类型: 描述: 术语创建的日期和时间。 |
updatedAt | 类型: 描述: 术语最后更新的日期和时间。 |