From Fedora Project Wiki

Updated for

This page has been updated for Fedora 23.

This page explains how to pull translated files from Zanata in order to review and correct them with more or less automated tools and then pushing them back to Zanata. It describes how to set up the tool to do that in an efficient way.

Context

Translation on Zanata is rather good and efficient. Nevertheless, when comes the time of reviewing the translation, getting the translated files locally in order to use some specialized and automated tools may be of greet help in the whole process. This page explain how to setup and use the zanata-client command line tool to do so.

Setting up the Tool Necessary to Pull from and Push to Zanata

Installing the Zanata Command Line Client

The necessary command line tool to pull and push from Zanata is the Zanata command line client (CLI) available in the zanata-client package. Please install it with:

su -c 'dnf -y install zanata-client' 

Configuring the Zanata Client

User Configuration

To allow the user to be authenticated by the Zanata server, the zanata-cli presents the user's credentials it finds in the ~/.config/zanata.ini file to the server. Thus, the first thing to do is to create this ~/.config/zanata.ini file and add the user's credential in it. Fortunately, the Zanata server provides a very convenient way of doing so.

To create your configuration file:

  1. Use your favorite text editor to create the ~/.config/zanata.ini file.
  2. Login into the Zanata server and navigate to the user's Settings page – click on the user's avatar in the top-right corner and, in the drop down menu that opens, chose Settings.
  3. Click the <> Client link.
  4. Ensure an API key is displayed. If not, click on the Generate API Key button to create one.
  5. Copy the content of the Configuration[zanata.ini] text-box.
  6. Past the copied lines into the ~/.ini/zanata.ini file and save it.

Project Version Configuration

These steps must be repeated for each project-version before using any zanata-cli commands for the project version.

Project configuration stores information specific to a project version in the ~/<project dir path>/zanata.xml file – where <project dir path> should be replaced by the name of the project version's local directory . It helps the user to shorten the zanata-cli commands by providing default values for options to these commands.

Downloading the Configuration File

The ~/<project dir path>/zanata.xml can be customized after a base for it has been downloaded from the Zanata server. To download this configuration base, please, once connected to the server, do the followings:

  1. Navigate the project version page – the one that presents a list of languages for the project version.
  2. Click on the v … link just below the user's avatar in the top-right part of the page.
  3. Click on the Download Configuration File link and save the file into your ~/<project dir path> folder.

The downloaded file should look like the following:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://zanata.org/namespace/config/">
  <url>https://fedora.zanata.org/</url>
  <project>fedora-installation-guide</project>
  <project-version>f23</project-version>
  <project-type>podir</project-type>

</config>

Customizing the Configuration File

Locale

While using the Zanata CLI, if no further indication about the locale is provided with the command, the po and pot files of every Zanata recognized language will be downloaded. In order to systematically add a locale indication to the command, the zanata.xml file of the project version can be customized. To limit the download to your locale, please add the following lines into the <config> xml element in your zanata.xml file:

<locales>
  <locale><YOURLOCALE><locale>
<locales>

where <YOURLOCALE> has to be replaced with your language code (e.g. fr).

Getting the Files from Zanata

To get the files for your language from Zanata use the following command from your project version folder:

zanata-cli pull --pull-type both

After the downloading, you should find the .pot files and a <YOURLOCALE> folder into the project version folder where <YOURLOCALE> is your language code. Change to the <YOURLOCALE> folder to use the search and replace commands described below.

Modifying the Translated Files Locally

Once the .po files have been downloaded locally, the user can use any tool he likes to edit the .po files before pushing them back to Zanata.

Available tools

At the moment the following tools are available:

  • po_typo_purifier.py : a tool to check translated messages against typographic rules declared in a configuration file.

Saving your Work into Zanata

To push back your modified translated files into the Zanata server, use the following command:

zanata-cli push --push-type trans --merge-type auto