Using Transifex Client on the Raspberry Pi & Android phone

Okay, here is the first draft. You can use it and modify it.


Transifex CLI on Android and Raspberry Pi

The transifex-client provides a command-line access to the translations of your Transifex projects. It is also open-source. This is of benefit for the company in ways nobody would be able to predict. This blog post shows an example.

Since January 2022, a the former transifex-client Python library is superceeded by the Transifex-CLI implemented in Go. The Transifex-CLI provides the tx command to update and configure translations of projects such as apps and websites. Since the CLI is open-source, people can tinker with it and adapt it to their use-cases. One of these is to use the CLI on Android.

The Transifex-CLI is provided through a binary file tx. It allows you to to setup the translations for projects on your local file system. These binary files are released by Transifex on GitHub for each new version for Windows, Linux and MacOS. It is possible to build the client yourself so that systems which are not officially supported can also be used. Two of these systems are the famous Raspberry Pi and the Android phone and luckily, they tend to have the same processor: A binary file which runs on the Raspberry Pi 3 with its armv7l architecture also runs on Android phone with the same processor architecture.

Android Setup

This section aims to help you setup the Transifex-CLI on your Android phone.

On an Android Phone there are a series of open-source apps from F-Droid that can be used in conjuction with the Transifex-CLI. The command line interface can be provided by UserLAnd or Termux, if you do not have a Bluetooth Keyboard, also Hacker’s Keyboard is recommended to have access to the arrow keys.

After installing UserLAnd, one can create an Ubuntu environment. Termux runs straight on the Android phone and as such does not need setup.
The following picture shows the Transifex-CLI as it pushes new source files to a project. This is where we want to get to.

After having setup UserLAnd or Termux, you will need to retrieve the binary file. You can compile this yourself, as shown in the section about the Raspberry Pi or download the binary compiled by Nicco Kunzmann from GitHub. These commands should get the binary working on your phone:

  1. Make sure you have the correct processor:
    $ uname -m
    armv7l
    
  2. Download the Transifex-CLI’s tx binary file - you can also point the URL to your Raspberry Pi.
    wget -O tx 'https://github.com/niccokunzmann/transifex-client-armv7l-binary/blob/master/tx?raw=true'
    
  3. Move the tx binary into your $PATH so it is acessible as the tx command.
    mkdir -p ~/.local/bin
    mv tx ~/.local/bin
    chmod +x ~/.local/bin/tx
    echo 'export PATH="$PATH:~/.local/bin"' >> ~/.bashrc
    source ~/.bashrc
    

Now, you are ready to go. You can get help by the client, add resources and pull source files and push translations. The Transifex-CLI source repository shows in detail how to proceed.

On UserLAnd, you can access your SD-card at /host-rootfs/sdcard/. If you like to edit files with other apps, it is recommended that you store your resources there.

If you like to translate files, you might also want to edit them. These open-source apps may help you further:

  • Acode is a code editor which will also show syntax errors for common formats. This is useful when creating new translations as it points out your mistakes editing the files.
  • MGit to interact with Git repositories as they may not yet use the Transifex GitHub integration.
  • OctoDroid to browse GitHub repositories such as the Transifex CLI and report issues.

It is well possible to access the Transifex API on an Android phone using the Transifex-CLI. Access to the SD-card and a variety of open-source apps allow you to create and update resources locally and on Transifex.

Compiling Transifex-CLI on a Raspberry Pi

Compiling the Transifex CLI on a Raspberry Pi is possible with the Docker build it provides. Following this section, you should be left with a working Transifex-CLI on your Raspberry Pi.

The first step is to install Docker. There are various tutorials available online, such as this one on phoenixnap.

After you have installed Docker, you can install git and download the Transifex-CLI.

sudo apt-get install git
git clone --depth=1 https://github.com/transifex/cli.git

Once you have done this, you can build the Transifex CLI according to its documentation:

cd cli
make docker-build

This will generate your tx file. You can store that in your path as mentioned above for the Android phone. With this, you can manage the translations stored in your Transifex project locally on your Raspberry Pi.

Summary

Having created an open-source client for their API, Transifex has allowed hobbyists and enthusiasts to tinker with it and adapt it to their use-cases. As a result, users on Android phones and the Raspberry Pi can synchronize translations. This was not a standard use-case targeted by the management but an open policy with their source code has allowed Transifex niche users to expand the reach of the company.

This is a blog post from the Transifex community by Nicco Kunzmann.