Crowdin CLI - це консольний додаток для інтеграції вашого проекту з Crowdin, що дозволяє автоматизувати управління і синхронізацію ресурсних файлів і перекладів:
Crowdin-cli - крос-платформовий додаток. Ви можете використовувати його в терміналах Linux або MacOS X, а також в командному рядку операційних системах Windows. Також його open-source та вихідний код доступні за адресою GitHub.
upload
download
Переконайтеся, що у вас встановлена Java 8 або новіше. Для перевірки версії Java введіть команду java -version
в терміналі (командний рядок в Windows). Наприклад, версія Java “1.8.0_212” означає, що у вас встановлена Java 8 оновлення 212.
Якщо у вас не встановлена Java, завантажте її з веб-сайту Oracle {:target=”_blank”}.
Щоб встановити CLI Crowdin за допомогою homebrew (менеджер пакетів для MacOS):
$ brew tap crowdin/crowdin
$ brew install crowdin@3
Завантажте та запустіть інсталятор для Windows.
Ми підписуємо всі наші пакети за допомогою ключа підпису Crowdin.
Завантажити та встановити відкритий ключ підпису:
wget -qO - https://artifacts.crowdin.com/repo/GPG-KEY-crowdin | sudo apt-key add -
Використовуючи наступну команду, створіть файл crowdin.list у каталозі /etc/apt/sources.list.d:
echo "deb https://artifacts.crowdin.com/repo/deb/ /" > /etc/apt/sources.list.d/crowdin.list
І ваше сховище готове до використання. Ви можете встановити пакет Crowdin CLI Debian командою:
sudo apt-get update && sudo apt-get install crowdin3
Щоб встановити Crowdin CLI вручну:
$ wget https://artifacts.crowdin.com/repo/deb/crowdin3.deb -O crowdin.deb $ sudo dpkg -i crowdin.deb
Ми підписуємо всі наші пакети за допомогою ключа підпису Crowdin.
Завантажити та встановити відкритий ключ підпису:
rpm --import https://artifacts.crowdin.com/repo/GPG-KEY-crowdin
Встановлення зі сховищ RPM
Створіть в каталозі /etc/yum.repos.d файл з ім’ям crowdin.repo, що містить:
[crowdin] name=Crowdin repository baseurl=https://artifacts.crowdin.com/repo/rpm gpgcheck=1 gpgkey=https://artifacts.crowdin.com/repo/GPG-KEY-crowdin enabled=1
І ваше сховище готове до використання. Тепер ви можете встановити Crowdin CLI за допомогою однієї з наступних команд:
sudo yum install crowdin3 sudo dnf install crowdin3
Щоб встановити Crowdin CLI вручну:
$ wget https://artifacts.crowdin.com/repo/rpm/crowdin3.rpm -O crowdin.rpm $ sudo rpm -U crowdin3.rpm
Visit the Crowdin CLI package page on Arch Linux user repository.
Installing from the NPM repository
npm i -g @crowdin/cli
Crowdin-cli можна встановити як окремий Java-додаток.
./install-crowdin-cli.sh
в терміналі з правами sudo, щоб додати команду crowdin
в свій терміналsetup-crowdin.bat
для додавання команди crowdin
в командний рядокCrowdin CLI provides a possibility to work with a proxy server. Each time you run a command, Crowdin CLI checks whether the operating system has the configured environment variables.
Supported environment variables:
HTTP_PROXY_HOST
– the name or the IP address of the host at which the proxy server is located HTTP_PROXY_PORT
– the port used by the proxy server for listening HTTP_PROXY_USER
– the username used for authentication on a proxy server HTTP_PROXY_PASSWORD
– the password used for authentication on a proxy server
Використовуйте наступну команду для запуску додатка:
$ crowdin
Альтернативний метод:
$ java -jar crowdin-cli.jar
Для використання Crowdin CLI, вам потрібно мати файл конфігурації. We recommend to name it crowdin.yml. Ви можете створити його, виконавши команду:
$ crowdin init
Під час виклику Crowdin CLI в терміналі, ви повинні знаходитися в кореневому каталозі проекту. В іншому випадку, вам доведеться вказати шлях до файлу конфігурації параметром --config
:
$ crowdin upload sources --config /path/to/your/config/file
Запустіть crowdin help
щоб отримати більш детальну інформацію про інші команди.
Приклад файлу конфігурації:
"project_id": "projectId" #open project settings and go to API section
"api_token": "personal-access-token" #open profile settings and go to API & SSO > New Token > create Token
"base_path": "." #path to your project directory on a local machine
"base_url": "https://crowdin.com"
"preserve_hierarchy": true
"files": [
{
"source": "/en/**/*.json", #source files filter
"translation": "/%two_letters_code%/**/%original_file_name%" #where translations are stored
}
]
Для отримання додаткової інформації про те, як налаштувати Crowdin CLI, подивіться статтю файл конфігурації.
Після створення файлу конфігурації ви будете готові приступити до використання Crowdin CLI для керування ресурсами локалізації, а також зможете автоматизувати синхронізацію ваших файлів.
Для виведення на екран довідкової інформації:
$ crowdin help
Щоб створити шаблон файлу конфігурації:
$ crowdin init
Щоб перевірити файл конфігурації на наявність загальних помилок:
$ crowdin lint
Щоб відобразити список завантажених в Crowdin файлів:
$ crowdin list project
Щоб завантажити вихідні файли в Crowdin:
$ crowdin upload sources
Щоб завантажити один файл без конфігурації:
$ crowdin upload sources -s path/to/your/file -t file/export/pattern -T personal-token -i project-id --base-url https://crowdin.com
Використовуйте наповнювачі щоб підставити відповідні змінні.
Щоб відобразити список файлів, які будуть завантажені в Crowdin:
$ crowdin upload sources --dryrun
Щоб завантажити існуючі переклади в Crowdin (переклади будуть синхронізовані):
$ crowdin upload translations
Щоб показати детальну інформацію про команду upload
:
$ crowdin upload --help
To add existing or new labels to the source strings:
$ crowdin upload sources -s "..." -t "..." --label "main-menu" --label "application"
Read more about Labels.
To download source files from Crowdin:
$ crowdin download sources
Щоб завантажити останні версії перекладів з Crowdin:
$ crowdin download
Щоб завантажити останні переклади для певної мови (коди мов):
$ crowdin download -l {language_code}
Щоб відобразити список останніх перекладів з Crowdin:
$ crowdin download --dryrun
Щоб показати детальну інформацію про команду download
:
$ crowdin download --help
There is a possibility to download the latest translations from Crowdin to the specified target file (Android XML or iOS Strings) regardless of the source file format in Crowdin.
To download the latest translations from Crowdin to the target file:
$ crowdin download targets <name>
Add the targets
section to your crowdin.yml
configuration file with the following structure:
targets: [
{
name: "android",
files: [
{
file: "targets/%two_letters_code%/android.xml",
sources: [
"file.xlsx"
],
labels: [
"mobile",
"ui"
]
}
]
}
]
name
- the name of your target. Will be used for downloading specific targets.files
- the section that describes the resulting files that appear in your system after the download. Each target supports the downloading of multiple files.file
- the resulting file pattern. Currently, only Android XML (.xml) and iOS Strings (.strings) file formats are supported.sources
- the source files in Crowdin, whose translations should be exported. Alternatively, you can specify either branches
or directories
.labels
- Labels for the strings filtering (Optional).As a result, the file.xlsx
translations (filtered by labels mobile
and ui
) will be downloaded to targets/%two_letters_code%/android.xml
file.
There is a possibility to configure and download pseudo-localized translation files.
To download an archive with pseudo-localized translation files:
$ crowdin download --pseudo
Add the pseudo_localization
section to your crowdin.yml
configuration file with the following structure:
pseudo_localization: {
length_correction: 25,
prefix: "",
suffix: "",
character_transformation: "cyrillic"
}
Read more about Pseudo-localization.
Немає необхідності запускати певну команду для створення гілок версій засобу синхронізації. Гілка версії буде створена автоматично під час завантаження файлів.
Щоб завантажити вихідні файли до зазначеної версію гілки:
$ crowdin upload sources -b {branch_name}
Щоб завантажити переклади в зазначену версію гілки:
$ crowdin upload translations -b {branch_name}
Щоб завантажити переклади з вказаною версії гілки:
$ crowdin download -b {branch_name}
There is a possibility to manage (add, edit, delete) source strings for the following file types: CSV, RESX, JSON, Android XML, iOS strings, PROPERTIES.
To show a list of source strings in the current project (use the --verbose
option to see more information):
$ crowdin string list
To create a new source string (use -h
option to see all possible command options):
$ crowdin string add
To delete source string:
$ crowdin string delete
To edit existing source string:
$ crowdin string edit
You can check the translation and proofreading progress for a project using the following commands.
To show both translation and proofreading progress for a project:
$ crowdin status
To show translation progress for a project:
$ crowdin status translation
To show proofreading progress for a project:
$ crowdin status proofreading
Also, you can use the --verbose
option to see more information.
There is a possibility to upload and download glossaries.
To show a list of glossaries (use the --verbose
option to show term lists for glossaries):
$ crowdin glossary list
To upload glossary from a file (in TBX file format) either to the specified glossary or to a new one:
$ crowdin glossary upload
To upload glossary from a file (in CSV or XLS/XLSX file format) either to the specified glossary or to a new one:
$ crowdin glossary upload <file> --scheme term_en=0 --scheme description_en=1 --scheme partOfSpeech_en=2 --first-line-contains-header
To form the scheme for your CSV or XLS/XLSX glossary file, use the following constants:
term_{language_code}
– Column contains terms. {column_number}
– Column number. Numbering starts from 0. description_{language_code}
– Column contains term descriptions. partOfSpeech_{language_code}
– Column contains part of speech for terms. where {language_code}
– Language code for the specified language. See the full list of Supported Languages. --first-line-contains-header
– used to skip the import of the first row (header).
To download glossary to a file (in TBX, CSV, or XLS/XLSX file format) from the specified glossary:
$ crowdin glossary download
There is a possibility to upload and download translation memories.
To show a list of translation memories:
$ crowdin tm list
To upload translation memory from a file (in TMX file format) either to the specified translation memory or to a new one:
$ crowdin tm upload
To upload translation memory from a file (in CSV or XLS/XLSX file format) either to the specified translation memory or to a new one:
$ crowdin tm upload <file> --scheme en=0 --scheme fr=1 --first-line-contains-header
To form the scheme for your CSV or XLS/XLSX translation memory file, use the following constants:
{language_code}
– Column contains translation memory elements for the specified language. {column_number}
– Column number. Numbering starts from 0. where {language_code}
– Language code for the specified language. See the full list of Supported Languages. --first-line-contains-header
– Used to skip the import of the first row (header).
To download translation memory to a file (in TMX, CSV, or XLS/XLSX file format) from the specified translation memory:
$ crowdin tm download