Configuration File
The various Crowdin tools use a crowdin.yml
configuration file that specifies the resources to be managed, including the files to be uploaded to Crowdin and the locations of the corresponding translations.
Configuration File Structure
A valid crowdin.yml
configuration file has the following structure, so please ensure that you fill out all the needed information:
- Head of the file with project credentials, preferences, and access information.
- One files array element that describes a set of source and translation files you will manage.
- Required fields in the files array:
source
that defines filters for the source files andtranslation
with instructions on where to store the translated files or where to look for translations you already have if you want to upload them while setting up the CLI.
Writing a Simple Configuration File
A typical configuration file looks similar to the following:
Name | Description |
---|---|
project_id | Crowdin Project numeric ID |
api_token | Crowdin Personal Access Token. The token owner should have at least Manager permissions in the project |
base_path optional | Path to your project directory on a local machine relative to the crowdin.yml configuration file |
base_url optional | Crowdin API base URL. Optional for crowdin.com. For Crowdin Enterprise use the https://{organization-name}.api.crowdin.com |
preserve_hierarchy optional | If set to true , the directory structure will be preserved on the server. If set to false , the directory structure will be flattened. |
source | Filter for the source files. Wildcards are supported. |
translation | Path to store the translated files. Wildcards are supported. |
API Credentials from Environment Variables
You could load the API Credentials from an environment variable, for example:
If mixed, api_token and project_id are prioritized:
General Configuration
The sample configuration provided above has source and translation attributes containing standard wildcards (also known as globbing patterns) to make it easier to work with multiple files.
Here are patterns you can use:
* (asterisk)
Matches any character in the file or directory name. If you specify *.json
, it will include all files like messages.json
, about_us.json
, and anything that ends with .json
.
** (doubled asterisk)
Matches any string recursively (including subdirectories). Note that you can use **
in both the source and translation patterns. When you use **
in the translation pattern, it always includes a sub-path from the source for a given file. For example, you can use source: /en/**/*.po
to recursively upload all *.po
files to Crowdin Enterprise. The translation pattern will be /%two_letters_code%/**/%original_file_name%
.
? (question mark)
Matches any single character.
[set]
Matchesany single character in a set. Behaves exactly like character sets in Regexp, including set negation ([^a-z]
).
\ (backslash)
Escapes the next metacharacter.
Placeholders
Crowdin CLI allows to use the following placeholders to put appropriate variables into the resulting file name:
Name | Description |
---|---|
%original_file_name% | Original file name |
%original_path% | Take parent folder names in the Crowdin Enterprise project to build file path in the resulting bundle |
%file_extension% | Original file extension |
%file_name% | File name without extension |
%language% | Language name (e.g., Ukrainian) |
%two_letters_code% | Language code ISO 639-1 (e.g., uk) |
%three_letters_code% | Language code ISO 639-2/T (e.g., ukr) |
%locale% | Locale (e.g., uk-UA) |
%locale_with_underscore% | Locale (e.g., uk_UA) |
%android_code% | Android Locale identifier used to name “values-” directories |
%osx_code% | OS X Locale identifier used to name “.lproj” directories |
%osx_locale% | OS X locale used to name translation resources (e.g., uk, zh-Hans, zh_HK) |
You can also define the path for files in the resulting archive by putting a slash (/
) at the beginning of the pattern.
Usage of Wildcards
Structure of files and directories on the local machine:
Directorybase_path
Directoryfolder
- 1.xml
- 1.txt
- 123.txt
- 123_test.txt
- a.txt
- a1.txt
- crowdin?test.txt
- crowdin_test.txt
- 1.xml
- 1.txt
- 123.txt
- 123_test.txt
- a.txt
- a1.txt
- crowdin?test.txt
- crowdin_test.txt
- 3.txt
Example 1. Usage of wildcards in the source path:
Example 2. Usage of wildcards for ignoring files:
Renaming Translations File
If you need to rename a file with translations after the export, you can easily do this with the help of the parameter translation_replace
.
For example, if the file is named strings_en.po
, it can be renamed to strings.po
. For this, add a new parameter (at the same level as the translation parameter) to the configuration file:
In this case, _en
will be erased from the file name.
Ignoring Files and Directories
From time to time, there are files and directories you don’t need to translate in Crowdin. In such cases, local per-file rules can be added to the config file in your project.
You can also use wildcards to ignore files.
Excluding Target Languages for Source Files
By default, the source files are available for translation into all target languages of the project. If some source files shouldn’t be translated into specific target languages, you can exclude them with the help of the parameter excluded_target_languages
.
Configuration file example:
Multilingual Spreadsheet
If a CSV or XLS/XLSX file contains the translations for all target languages, you should specify appropriate language codes in the scheme.
CSV file example:
Configuration file example:
If your CSV or XLS/XLSX file contains columns that should be skipped on import, use none
for such columns in the scheme, for example:
Scheme Constants
To form the scheme for your CSV or XLS/XLSX file, use the following constants:
identifier
– Column contains string identifiers.source_phrase
– Column contains source strings.source_or_translation
– Column contains source strings, but the same column will be filled with translations when the file is exported. When uploading existing translations, the values from this column will be used as translations.translation
– Column contains translations.context
– Column contains comments or context information for the source strings.max_length
– Column contains max.length limit values for the translations of the strings.labels
– Column contains labels for the source strings.none
– Column that will be skipped on import.
Saving Directory Structure on Server
You can use the preserve_hierarchy
option to preserve or flatten the directory structure of your source files in the Crowdin project.
Example of the configuration file using the preserve_hierarchy
option:
Let’s say the file/folder structure on your machine looks like this:
Directorylocale
Directoryen
Directoryemails/
- …
Directoryapp
- foo.po
- bar.po
If you don’t use the "preserve_hierarchy": true
option in your configuration file at all or use it with the false
value, all shared directories will be skipped, and the file structure in Crowdin will be represented as follows:
Directory(root)/
- foo.po
- bar.po
Using the "preserve_hierarchy": true
option, the file structure in Crowdin will be represented as follows:
Directorylocale
Directoryen
Directoryapp
- foo.po
- bar.po
The directories that don’t contain any files for translation won’t be created in Crowdin (i.e., as the emails
directory in the example above).
Uploading Files to Specified Path with Specified Type
This feature adds support for two optional parameters in the yml file section: dest
and type
. It’s typically used for projects where the uploaded name must be different so that Crowdin can detect the type correctly.
The dest
parameter allows you to specify a file name in Crowdin. It works for multiple files at once and supports the following placeholders: %original_file_name%
, %original_path%
, %file_extension%
, %file_name%
.
Example of the configuration file with both parameters:
Changed Strings Update
You can use the update_option
parameter to preserve translations for changed strings during the file update. If it is not set, translations for changed strings will be lost. Useful for typo fixes and minor changes in source strings.
Depending on the value, update_option
is used to preserve translations and preserve/remove validations of changed strings during file update.
Acceptable values:
update_as_unapproved
- preserve translations of changed strings and remove validations of those translations if they existupdate_without_changes
- preserve translations and validations of changed strings
Example of the configuration with the update_option
parameter:
Custom Segmentation
Upload your XML, HTML, MD, or any other source files without a key-value structure with your own segmentation rules. If not specified, the pre-defined segmentation rules (SRX 2.0) are used for automatic content segmentation.
Example of the configuration file custom segmentation:
Import Options
You can use additional parameters to customize the import process for specific file types.
XML Files Import Options
Option | Type | Description |
---|---|---|
translate_content optional | bool | Defines whether to translate texts placed inside the tags. Acceptable values are 0 or 1. Default is 1. |
translate_attributes optional | bool | Defines whether to translate tags’ attributes. Acceptable values are 0 or 1. Default is 1. |
content_segmentation optional | bool | Defines whether to split long texts into smaller text segments. |
translatable_elements optional | array | This is an array of strings, where each item is the XPaths to DOM element that should be imported. |
Example of the configuration with additional parameters:
Other Files Import Options
Option | Type | Description |
---|---|---|
content_segmentation optional | bool | Defines whether to split long texts into smaller text segments. Only for TXT, DOCX, DITA, IDML, MEDIAWIKI, HTML, Front Matter HTML, Markdown, Front Matter Markdown, XML, XLIFF, XLIFF 2.0 |
Example of the configuration with additional parameters:
Export Options
You can use additional parameters to customize the export process for specific file types.
Java .properties File Format
Escape Quotes
Defines whether a single quote should be escaped by another single quote or backslash in exported translations. You can add the escape_quotes
per-file option.
Acceptable values:
0
- do not escape single quote1
- escape single quote with another single quote2
- escape single quote with a backslash3
- escape single quote with another single quote only in strings containing variables (default)
Escape Special Characters
Defines whether any special characters (=
, :
, !
and #
) should be escaped by a backslash in exported translations.
You can add the escape_special_characters
per-file option.
Acceptable values:
0
- do not escape special characters1
- escape special characters by a backslash (default)
Example of the configuration:
Configuration File for VCS Integrations
VCS integrations require the same configuration file as the CLI tool, meaning the same structure is supported. The only difference is that you should not store the project credentials in the file header for security reasons. Also, you can use a few additional parameters.
Pull Request Title and Labels
The default pull request title is New Crowdin updates
. To specify your custom pull request title and add labels to the pull request, you can use the following parameters in the configuration file: pull_request_title
, pull_request_labels
.
Commit Message
Each time translations are committed the default message is shown New translations {fileName} ({languageName})
.
You can use the commit_message
parameter to add Git tags (e.g., to skip builds).
To replace the default commit message, use the append_commit_message
parameter with the false
value. You can also add two optional placeholders: %original_file_name%
and %language%
to use the appropriate file name and language variables accordingly.
Export Languages
By default, all the languages are exported. If you need to export some specific languages, use the export_languages
parameter to specify them.
Pull Request Assignee
If you need to assign a pull request to particular users, use the pull_request_assignees
parameter to specify them.
GitHub/GitHub Server:
GitLab/GitLab Self-Managed:
Pull Request Reviewer
If you need to request a pull request review from particular users, use the pull_request_reviewers
parameter to specify them.
GitHub/GitHub Server:
GitLab/GitLab Self-Managed:
Bitbucket:
Bitbucket Server:
Azure Repos:
Adding Labels to Source Strings
To add existing or new labels to the source strings, use the labels
parameter.
Labels will be added to the source strings only during the initial upload to the Crowdin project.
The strings uploaded to the Crowdin project before the use of the labels
parameter won’t be labeled.
If you remove the label added during the initial upload directly in Crowdin, it won’t be re-added on the next syncs.
Example:
Read more about Labels.
Language Mapping
Often software projects have custom names for locale directories. Crowdin allows you to map your own languages to be recognizable in your projects.
Let’s say your locale directories are named en
, uk
, fr
, de
. All of them can be represented by the %two_letters_code%
placeholder. Still, you have one directory named zh_CH
. You can also override language codes for other placeholders like %android_code%
, %locale%
, etc.
Read more about Language Mapping configuration for CLI.
To make it work with Crowdin without changes in your project, you can set up Language Mapping via UI.
Using One Configuration File for VCS Integrations and CLI
There are cases when it’s necessary to use VCS integration and CLI for one project. Mostly, in this kind of situation, you’d need to have two separate configuration files, one for VCS integration and another for CLI. However, you can use a single configuration file for both cases.
Since the VCS integration configuration file doesn’t contain project_id
and api_token
credentials required for CLI, you can pass them directly in the command using the following parameters: -i/--project-id
, -T/--token
.
As a result, your command for downloading translations via CLI will look like the following:
Alternatively, you may use Environment Variables or Split Project Configuration and API Credentials.