Consola do Cliente (CLI)

O Crowdin CLI é uma ferramenta de linha de comando que permite-te gerir e sincronizar os teus recursos de localização com o teu projeto do Crowdin:

  • Automatizar o processo de atualização dos teus ficheiros de origem no teu projeto do Crowdin
  • Transfere as traduções do Crowdin e automaticamente, guarda-as nos locais corretos
  • Enviar todas as traduções existentes para o Crowdin em minutos
  • Integrate Crowdin with GIT, SVN, Mercurial, and more.

Este é uma multiplataforma e é executado num terminal em sistemas operacionais baseados em Linux e MacOS ou nas Linhas de Comando (Command Prompt) no Windows. It’s also open-source and it’s source code available at GitHub.

Novidades

  • Multithreading for source and translation files upload
  • UX improvements: process indicators, loading states, emojis
  • Interactive generation of a configuration file
  • Bash/Zsh command completion
  • Improved help screen for commands
  • Improved configuration file validation
  • More import options for upload command
  • More export options for download command
  • Based on new RESTful Crowdin API v2
  • Bug fixes and other improvements

Requisitos

Verifica que tens Java 8 ou mais recente, instalado. Digita o comando java -version no terminal (Linha de Comando (Command Prompt) no Windows) para verificar a versão do Java. Por exemplo, java version “1.8.0_212” significa que tens Java 8 Update 212 instalado.

Se não tiveres o Java instalado, transfere-o do site do Oracle.

Instalação

Homebrew para macOS

To install the Crowdin CLI with homebrew (the package manager for macOS):

$ brew tap crowdin/crowdin
$ brew install crowdin@3

Windows

Transfere e executa o instalador para Windows.

Debian

Assinámos todos os pacotes com a Chave de Assinatura do Crowdin.

Transfere e instala a chave de assinatura pública:

wget -qO - https://artifacts.crowdin.com/repo/GPG-KEY-crowdin | sudo apt-key add -

Using the following command, create the crowdin.list file in the /etc/apt/sources.list.d directory:

echo "deb https://artifacts.crowdin.com/repo/deb/ /" > /etc/apt/sources.list.d/crowdin.list

And your repository is ready for use. Podes instalar o pacote do Debian do Crowdin CLI com:

sudo apt-get update && sudo apt-get install crowdin3

Para instalar o Crowdin CLI, manualmente:

$ wget https://artifacts.crowdin.com/repo/deb/crowdin3.deb -O crowdin.deb $ sudo dpkg -i crowdin.deb

RPM

Assinámos todos os pacotes com a Chave de Assinatura do Crowdin.

Transfere e instala a chave de assinatura pública:

rpm --import https://artifacts.crowdin.com/repo/GPG-KEY-crowdin

Instalção do repositório RPM

Create a file called crowdin.repo in the /etc/yum.repos.d directory containing:

[crowdin] name=Repositório do Crowdin baseurl=https://artifacts.crowdin.com/repo/rpm gpgcheck=1 gpgkey=https://artifacts.crowdin.com/repo/GPG-KEY-crowdin enabled=1

And your repository is ready for use. You can now install Crowdin CLI with one of the following commands:

sudo yum install crowdin3 sudo dnf install crowdin3

Para instalar o Crowdin CLI, manualmente:

$ wget https://artifacts.crowdin.com/repo/rpm/crowdin3.rpm -O crowdin.rpm $ sudo rpm -U crowdin3.rpm

Arch Linux

Visit the Crowdin CLI package page on Arch Linux user repository.

NPM

Installing from the NPM repository

npm i -g @crowdin/cli

Versão Autónoma (Standalone)

O Crowdin CLI pode ser instalado como uma aplicação autónoma de Java.

Instalação no Linux e macOS

  1. Transfere o crowdin-cli.zip ao usar o botão acima
  2. Descompacta-o
  3. Run ./install-crowdin-cli.sh in the terminal with sudo rights in order to add crowdin command to your terminal

Instalação no Windows

  1. Transfere o crowdin-cli.zip ao usar o botão acima
  2. Extrai o conteúdo para o local onde queres que o Crowdin CLI seja armazenado
  3. Abre as Linhas de Comando como Administrador (botão direito do mouse)
    1. Clica Iniciar
    2. In the Start Search box, type cmd, and then press Ctrl+Shift+Enter
    3. Se a caixa de diálogo Controlo de Conta de Utilizador (User Account Control), aparecer, confirma que a ação exibida é a desejada e, em seguida, clica em Continuar
  4. Executa o script setup-crowdin.bat para adicionar o comando crowdin para a Linha de Comando
  5. Reinicia a tua Linha de Comando

Using Crowdin CLI with Proxy Server

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

Executar a Aplicação

Usa o seguinte método para executar a aplicação:

$ crowdin

Método alternativo:

$ java -jar crowdin-cli.jar

CLI

Configuração

To use Crowdin CLI you need to have a configuration file. We recommend to name it crowdin.yml. You can create it running the command:

$ crowdin init

When calling Crowdin CLI in terminal you should be in your project root directory. Otherwise, you will have to specify a configuration file path using the --config option:

$ crowdin upload sources --config /path/to/your/config/file

Executa crowdin help para obter mais detalhes sobre outros comandos.

Exemplo de ficheiro de configuração:

"project_id": "projectId"                 #open project and go to Resources > Integrations & API > Integration tool
"api_token": "personal-access-token"      #open project and go to Resources > Integrations & API > Integration tool
"base_path": "."                          #path to your project directory on a local machine
"base_url": "https://{organization-name}.crowdin.com"
"preserve_hierarchy": true

"files": [
  {
      "source": "/en/**/*.json",                                          #source files filter
      "translation": "/%two_letters_code%/**/%original_file_name%"        #where translations are stored
  }
]

For more information how to configure Crowdin CLI, read the Configuration File article.

Utilização

Assim que o ficheiro de configuração tiver sido criado, estás pronto para começar a usar o Crowdin CLI para gerir os teus recursos de localização e automatizar a sincronização de ficheiros.

Comandos Gerais

To show help information about Crowdin CLI:

$ crowdin help

Para gerar um esqueleto de ficheiro de configuração:

$ crowdin init

Para verificar o ficheiro de configuração por erros gerais:

$ crowdin lint

Para exibir uma lista de ficheiros enviados ao Crowdin:

$ crowdin list project

Enviar Recursos

Para enviar ficheiros de origem para o Crowdin:

$ crowdin upload sources

To specify the target languages the source files shouldn’t be translated into:

$ crowdin upload sources --excluded-language uk fr

Para enviar um único ficheiro sem configuração:

$ crowdin upload sources -s "..." -t "..." -T personal-token -i project-id --base-url 'your-organization-url'

Use placeholders to put appropriate variables.

Para exibir uma lista de ficheiros que serão enviados ao Crowdin:

$ crowdin upload sources --dryrun

Para enviar traduções existentes para o Crowdin (as traduções serão sincronizadas):

$ crowdin upload translations

Para mostrar informações detalhadas sobre o comando 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.

Downloading Sources

To download source files from Crowdin:

$ crowdin download sources

Transferir Traduções

Para transferir as traduções mais recentes do Crowdin:

$ crowdin download

Para transferir as traduções mais recentes para o idioma especificado (códigos de idioma):

$ crowdin download -l {language_code}

Para exibir uma lista das traduções mais recentes do Crowdin:

$ crowdin download --dryrun

Para mostrar informações detalhadas sobre o comando download:

$ crowdin download --help

Downloading Translations to a Target File

Regardless of the initial source file format, there is a possibility to download translation files in the Android XML, iOS Strings, and XLIFF formats.

It’s beneficial when localizing mobile app content or when the final translation file format differs from the initial source format. You can use beforehand generated source files or send strings to your Crowdin project directly from design tools. When translations are finished, you can download them in the needed format and easily integrate them into the codebase.

To launch custom exporters and download files in the necessary format:

$ crowdin download targets <name>

Configuração

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 supported file formats are the following: Android XML (.xml), iOS Strings (.strings), and XLIFF. New file formats are coming soon.
  • sources - the source files in Crowdin Enterprise, 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.

Downloading Pseudo-localization

There is a possibility to configure and download pseudo-localized translation files.

To download an archive with pseudo-localized translation files:

$ crowdin download --pseudo

Configuração

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

Gestão de Versões

There is no need to run a specific command to create version branches if CLI is used. The version branch will be created automatically during the files upload.

Para enviar ficheiros de origem para a ramificação de versão especificada:

$ crowdin upload sources -b {branch_name}

Para enviar traduções para a ramificação de versão especificada:

$ crowdin upload translations -b {branch_name}

Para transferir as traduções da ramificação de versão especificada:

$ crowdin download -b {branch_name}

Source Strings Management

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

Translation and Proofreading Progress

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.

Glossary Management

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

Translation Memory Management

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

Ver Também

Este artigo foi útil?