Crowdin Query Language (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 Symbol Esempio
Addition + 1 + 9
Subtraction - 11 - 1
Division / 20 / 2
Multiplication * 2 * 5
Negation - -10

Comparison Operators

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

Nome Symbol Alias Esempio
Between {{expression}} between {{expression}} and {{expression}} 5 between 1 and 10
Equal = 10 = 10
Not equal != 1 != 10; 1 ≠ 10
Greater > 10 > 1
Greater or equal >= 10 >= 1; 10 ≥ 1
Less < 1 < 10
Less or equal <= 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 Symbol Esempio
And and 1 < 10 and 10 > 1
Or 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 Symbol Esempio
Filter {{collection}} where {{predicate}} translations where (count of votes > 0)
Match {{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 Symbol Esempio
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 Symbol Esempio
Mention @user:{{string}}; @language:{{string}} @user:"crowdin"; @language:"en"
Member {{member}} of {{object}} count of translations
Identifier {{identifier}} text; identifier

Scalar Operators

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

Nome Symbol Esempio
Integer {{integer}} 10
Float {{float}} 10.01
Stringa {{string}} “crowdin"
Datetime {{datetime}} 'today'; '2021-03-16 00:00:00'

Group Operator

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

Nome Symbol Esempio
Group ( ) 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}

Type: integer

Description: Numeric identifier of your Crowdin project.

{croql}

Type: string

Description: CroQL expression.

  • 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}

Type: integer

Description: Numeric identifier of your Crowdin project.

{croql}

Type: string

Description: CroQL expression.

Contesto

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"
}
type is plain

Type: boolean

Description: The source string with plain text.

type is plural

Type: boolean

Description: The source string with plural forms.

type is icu

Type: boolean

Description: The source string with ICU.

type is asset

Type: boolean

Description: The source string is an asset.

testo

Type: string

Description: The source string text.

identifier

Type: string

Description: The source string identifier (key).

contesto

Type: 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

Type: 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

Type: array

Description: The source string screenshots.

translations

Type: array

Description: Translations of the source string.

testo

Type: string

Description: Translation text.

plural form

Type: 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

Type: integer

Description: Numeral identifier of the target language.

user

Type: integer

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

votes

Type: array

Description: Array of the votes added to the translation.

is up

Type: boolean

Description: Upvote.

is down

Type: boolean

Description: Downvote.

user

Type: 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

Type: array

Description: Array of the added translation approvals.

user

Type: 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.

Translation Context

{
  "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"
}
testo

Type: boolean

Description: Translation text.

plural form

Type: 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

Type: integer

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

votes

Type: array

Description: Array of the votes added to the translation.

is up

Type: boolean

Description: Upvote.

is down

Type: boolean

Description: Downvote.

user

Type: 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

Type: array

Description: Array of the added translation approvals.

user

Type: 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.

Questo articolo è stato utile?