Idioma de consulta do Crowdin (CroQL)

Crowdin Query Language (CroQL) is a tool for Crowdin APIv2 that allows you to retrieve needed localization resources from Crowdin based on specific conditions. Using CroQL, you can filter source strings and their translations for a specific target language.

Operators

Main CroQL operators are listed below. Use and combine them to set specific conditions for retrieving the needed content from Crowdin. To form your CroQL query, you can use the elements from the tables below.

Arithmetic Operators

The arithmetic operators are used to perform mathematic operations with any numeric data types.

Nome Símbolo Exemplo
Adição + 1 + 9
Subtração - 11 - 1
Divisão / 20 / 2
Multiplicação * 2 * 5
Negation - -10

Comparison Operators

The comparison operators are used to compare values and return true or false.

Nome Símbolo Aliases Exemplo
Between {{expression}} between {{expression}} and {{expression}} 5 between 1 and 10
Igual = 10 = 10
Diferente != 1 != 10; 1 ≠ 10
Maior que > 10 > 1
Maior ou igual >= 10 >= 1; 10 ≥ 1
Menos < 1 < 10
Menor ou igual <= 1 <= 10; 1 ≤ 10;

Logical Operators

The logical operators are used to combine multiple boolean expressions or values and provide a single boolean output.

Nome Símbolo Exemplo
E and 1 < 10 and 10 > 1
Ou or 1 < 10 or 10 > 1
Xor xor 1 < 10 xor 10 > 1
Not not not 1 < 10

Filtration Operators

The filtration operators are used to filter the objects based on the specified condition.

Nome Símbolo Exemplo
Filtro {{collection}} where {{predicate}} translations where (count of votes > 0)
Corresponder {{object}} with {{predicate}} user with (login = "crowdin")

Conditional (Ternary) Operator

The ternary operator is used to check a condition specified in the first value, and if it’s true returns the second value, but if it’s false returns the third value.

Nome Símbolo Exemplo
Ternary If {{condition}} then {{expression}} else {{expression}} If 1 < 10 then "less" else "greater"

Fetch Operators

The fetch operators are used for retrieving data from the objects.

Nome Símbolo Exemplo
Menção @user:{{string}}; @language:{{string}} @user:"crowdin"; @language:"en"
Membro {{member}} of {{object}} count of translations
Identificador {{identifier}} text; identifier

Scalar Operators

The scalar operators are used to declare values for further processing.

Nome Símbolo Exemplo
Inteiro {{integer}} 10
Float {{float}} 10.01
String {{string}} “crowdin"
Data e Hora {{datetime}} 'today'; '2021-03-16 00:00:00'

Group Operator

The group operator is used to determine the execution order of operators.

Nome Símbolo Exemplo
Grupo ( ) 1 < 10 and (20 > 10 or 10 > 5)

Query Examples

  • To retrieve a list of strings that have no Ukrainian translations with approvals or votes, your query might look like this:
count of translations where ( language = @language:"uk" and ( count of approvals > 0 or count of votes > 0 ) ) = 0

Use your query in the following endpoint:

GET https://api.crowdin.com/api/v2/projects/{projectId}/strings?croql={croql}
Note: Before executing the request, make sure to URL encode your CroQL expression.
{projectId}

Tipo: integer

Descrição: Identificador numérico do seu projeto no Crowdin.

{croql}

Tipo: string

Descrição: expressão CroQL.

  • To retrieve translations made by the user with a crowdin username or ones with ≥ 100 upvotes, your query might look like this:
user = @user:"crowdin" or count of votes where ( is up ) >= 100

Use your query in the following endpoint:

GET https://api.crowdin.com/api/v2/projects/{projectId}/languages/uk/translations?croql={croql}
Note: Before executing the request, make sure to URL encode your CroQL expression.
{projectId}

Tipo: integer

Descrição: Identificador numérico do seu projeto no Crowdin.

{croql}

Tipo: string

Descrição: expressão CroQL.

Contexto

CroQL can be used in the following contexts: the source string context and translation context. Use the following examples as a foundation when forming your CroQL queries.

Source String Context

{
  "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",
  "is visible": true,
  "is hidden": false,
  "comments": [
    {
      "has issue": false,
      "has unresolved issue": false
    }
  ],
  "screenshots": [],
  "translations": [
    {
      "text": "Швидкий старт",
      "plural form": "none",
      "provider is tm": false,
      "provider is mt": true,
      "language": 52,
      "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"
    }
  ],
  "added": "2021-04-08 12:33:27",
  "updated": "2021-04-08 12:33:27"
}
tipo está plain

Type: boolean

Descrição: O texto de origem com texto simples.

o tipo é plural

Type: boolean

Descrição: O texto de origem com formas plurais.

tipo é icu

Type: boolean

Description: The source string with ICU.

tipo é asset

Type: boolean

Description: The source string is an asset.

texto

Tipo: string

Description: The source string text.

identifier

Tipo: string

Description: The source string identifier (key).

contexto

Tipo: string

Description: The source string context.

is visible

Type: boolean

Description: The source string is visible.

is hidden

Type: boolean

Description: The source string is hidden.

comments

Tipo: array

Description: The source string comments.

has issue

Type: boolean

Description: The source string has an issue.

has unresolved issue

Type: boolean

Description: The source string has an unresolved issue.

screenshots

Tipo: array

Description: The source string screenshots.

translations

Tipo: array

Description: Translations of the source string.

texto

Tipo: string

Description: Translation text.

plural form

Tipo: string

Description: Translation plural form.

provider is tm

Type: boolean

Description: Translation provided via translation memory.

provider is mt

Type: boolean

Description: Translation provided via machine translation engine.

language

Tipo: integer

Description: Numeral identifier of the target language.

user

Tipo: integer

Description: Numeral identifier of the user who added a translation.

votes

Tipo: array

Description: Array of the votes added to the translation.

is up

Type: boolean

Description: Upvote.

is down

Type: boolean

Description: Downvote.

user

Tipo: integer

Description: Numeral identifier of the user who added a vote for translation.

added

Type: datetime

Description: Date when a vote for translation was added.

approvals

Tipo: array

Description: Array of the added translation approvals.

user

Tipo: integer

Description: Numeral identifier of the user who approved a translation.

added

Type: datetime

Description: Date when a translation approval was added.

updated

Type: datetime

Description: Date when a translation was updated.

added

Type: datetime

Description: Date when a source string was added.

updated

Type: datetime

Description: Date when a source string was updated.

Contexto de tradução

{
  "text": "Швидкий старт",
  "plural form": "none",
  "provider is tm": false,
  "provider is mt": true,
  "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"
}
texto

Type: boolean

Description: Translation text.

plural form

Tipo: string

Description: Translation plural form.

provider is tm

Type: boolean

Description: Translation provided via translation memory.

provider is mt

Type: boolean

Description: Translation provided via machine translation engine.

user

Tipo: integer

Description: Numeral identifier of the user who added a translation.

votes

Tipo: array

Description: Array of the votes added to the translation.

is up

Type: boolean

Description: Upvote.

is down

Type: boolean

Description: Downvote.

user

Tipo: integer

Description: Numeral identifier of the user who added a vote for translation.

added

Type: datetime

Description: Date when a vote for translation was added.

approvals

Tipo: array

Description: Array of the added translation approvals.

user

Tipo: integer

Description: Numeral identifier of the user who approved a translation.

added

Type: datetime

Description: Date when a translation approval was added.

updated

Type: datetime

Description: Date when a translation was updated.

Este artigo foi útil?