Konsolklient (CLI)

Crowdin CLI er et kommandolinjeværktøj, der giver dig mulighed for at håndtere og synkronisere dine lokaliseringsressourcer med dit Crowdin-projekt:

  • Automatisér opdateringsprocessen af kildefiler i dit Crowdin-projekt
  • Download oversættelser fra Crowdin og gem dem automatisk på de korrekte placeringer
  • Upload alle dine eksisterende oversættelser til Crowdin på minutter
  • Integrér Crowdin med GIT, SVN, Mercurial og flere.
Note: If you are using the old version of Crowdin CLI (2.0.31 or less) see Crowdin GitHub for full details.

Dette er en krydsplatform, der kører i en terminal på Linux-baserede og MacOS-operativsystemer eller i Kommandprompten på Windows. Det er også open source, og dens kildekoden er tilgængelig på GitHub.

Nyheder

  • Multibehandling for upload af kilde- og oversættelsesfiler
  • UX-forbedringer: Procesindikatorer, indlæsningstilstande, emojis
  • Interaktiv generering af opsætningsfil
  • Bash/Zsh command completion
  • Forbedret hjælpeskærm til kommandoer
  • Improved configuration file validation
  • More import options for upload command
  • More export options for download command
  • Based on the new RESTful Crowdin API v2
  • Bug fixes and other improvements

Krav

Tjek, at du har minimum Java 8 installeret. Skriv java-version-kommando i terminalen (Kommandoprompt i Windows) for at tjekke Java-versionen. F.eks. betyder java version “1.8.0_212”, at du har Java 8, opdatering 212 installeret.

Har du ikke Java installeret, skal du downloade det fra Oracles websted.

Installation

Homebrew til macOS

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

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

Windows

Download og kør installationsprogram til Windows.

Debian

Alle vores pakker signeres med Crowdin Signing Key.

Download og installér den offentlige signaturnøgle:

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

Og dit repositorie er klar til brug. Du kan installere Crowdin-CLI Debian-pakken med:

sudo apt-get update && sudo apt-get install crowdin

For at installere Crowdin-CLI manuelt:

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

RPM

Alle vores pakker signeres med Crowdin Signing Key.

Download og installér den offentlige signaturnøgle:

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

Installation fra RPM-arkivet

Opret en fil med navnet crowdin.repo i mappen /etc/yum.repos.d indeholdende:

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

Og dit repositorie er klar til brug. Du kan nu installere Crowdin-CLI med en af flg. kommandoer:

sudo yum install crowdin3 sudo dnf install crowdin3

For at installere Crowdin-CLI manuelt:

$ 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

Selvstændig version

Crowdin-CLI kan installeres som en selvstændig Java-applikation.

Installation på Linux og macOS

  1. Download crowdin-cli.zip vha. knappen ovenfor
  2. Udpak den
  3. Kør .install-crowdin-cli.sh i terminalen med sudo-rettigheder for at tilføje crowdin-kommandoen til din terminal

Installation på Windows

  1. Download crowdin-cli.zip vha. knappen ovenfor
  2. Uddrag dens indhold til det sted, hvor Crowdin-CLI ønskes gemt
  3. Åbn Kommandoprompt som Administrator
    1. Klik på Start
    2. Angiv cmd i feltet Start Søgning, og tryk dernæst på Ctrl+Shift+Enter
    3. Hvis Brugerkontokontrol-dialogboksen vises, bekræft, at den handling, den viser, er, hvad du vil gøre, og klik derefter på Fortsæt
  4. Kør setup-crowdin.bat-skriptet for at tilføje crowdin-kommandoen til kommandoprompten
  5. Genstart din kommandoprompt

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

Køre app’en

Benyt flg. metode til at køre app’en:

$ crowdin

Alternativ metode:

$ java -jar crowdin-cli.jar

CLI

Opsætning

At benytte Crowdin-CLI kræves en opsætningsfil. Det anbefales at navngive den crowdin.yml. Du kan oprette den vha. kommandoen:

$ crowdin lint

Når du kalder Crowdin-CLI i en terminal, skal du befinde dig i din projektrodmappe. Ellers er du nødt til at angive en opsætningsfilsti vvha. --config muligheden:

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

Kør crowdin hjælp for at få flere detaljer vedr. andre kommandoer.

Opsætningsfileksempel:

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

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

Afbenyttelse

Når opsætningsfilen er oprettet, er du klar til at begynde at benytte Crowdin-CLI til at håndtere dine lokaliseringsressourcer samt automatisere filsynkronisering.

Generelle kommandoer

To show help information about Crowdin CLI:

$ crowdin help

For at generere en skeletopsætningsfil:

$ crowdin lint

For at tjekke opsætningsfilen for generelle fejl:

$ crowdin lint

For at vise en liste over uploadede filer til Crowdin:

$ crowdin list project

Upload af Ressourcer

Sådan uploades kildefiler til Crowdin:

$ crowdin upload sources -b

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

$ crowdin upload sources --excluded-language uk fr

Sådan uploades en enkelt fil uden opsætning:

$ crowdin upload sources -s "..." -t "..." -T personal-token -i project-id

Benyt pladsholdere til relevante variabler.

For at vise en liste over filer, som vil blive uploadet til Crowdin:

$ crowdin upload sources --dryrun

For at uploade eksisterende oversættelser til Crowdin (oversættelser vil blive synkroniseret):

$ crowdin upload translations

For at vise detaljeret information om upload-kommandoen:

$ 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

Download af oversættelser

For at downloade seneste oversættelser fra Crowdin:

$ crowdin download

For at downloade seneste oversættelser til det specifikke sprog (sprogkoder):

$ crowdin download -l {language_code}

For at se en liste over de seneste oversættelser fra Crowdin:

$ crowdin download --dryrun

For at vise detaljeret information om upload-kommandoen:

$ 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>

Opsætning

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, 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

Opsætning

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.

Versionshåndtering

There is no need to run a specific command to create version branches if CLI is used. Versionsgrenen oprettes automatisk under fil-uploads.

Sådan uploades kildefiler til den angivne versionsgren:

$ crowdin upload sources -b {branch_name}

Sådan uploades oversættelser til den angivne versionsgren:

$ crowdin upload translations -b {branch_name}

Sådan downloades oversættelser fra den angivne versionsgren:

$ 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

Se også

Var denne artikel nyttig?