• Documentation
  • CLI Client
  • Configuration

Configuration

Configuration options for the client follow standard UNIX practices adopted by Version Control System tools. The two configuration files the client uses are simple text files you can edit by hand. In this article, we'll go over the structure of each config file so you'll know what to look for if you need to edit a file by hand. Before you edit anything, we recommend you first set up a project (remote).

.transifexrc

~/.transifexrc stores your Transifex.com credentials. This config file is unique per user, and it's stored in your home directory.

[https://www.transifex.com]
username = your_username/api
token =
password = p@ssw0rd/api_token
hostname = https://www.transifex.com

There are a few things to note:

  • The token variable should be left blank. 
  • If you're using an API token, the username should be set to "api" and not your username.
  • If you update your Transifex credentials, you should also update this file.

You can have a .transifexrc file in your project directory. This could be useful in cases where you want to override the system-wide credentials. However, you should be careful to not share the file with others since it contains your account details. For example, you shouldn't track the file with git.

HttpNotAuthorized error

If you get an "HttpNotAuthorized: Authorization Required" error message after you run a tx command, this means the Transifex Client cannot access the projects needed. Check for two things:

1. Whether the credentials in your ~/.transifexrc file are correct. Edit the file directly to update the information if needed.

2. Whether the account associated with the username/API token in your config file has permission to access the project. You can verify this by logging in to Transifex and checking whether the project shows up in the dashboard. If you're trying to push files, then you must also be a Project Maintainer.

.tx/config

The Transifex client uses a per-project config file to store the project's details and the file-to-resource mappings. This file is stored in .tx/config in your project's root directory. It has the following structure:

[main]
host = https://www.transifex.com

[project_slug.resource_slug]
source_file = po/myproj.pot
source_lang = en
type = PO
file_filter = po/<lang>.po
trans.fi = translations/fi/LC_MESSAGES/django.po

Note

When you first initialize a project, only the [main] part of the .tx/config file will be completed.

The .tx/config file contains project-wide options, such as the default Transifex host for all projects, which can be overridden on a resource level. Here's what each of the sections and options in the mean:

  • [main]: This section contains information shared across projects and resources.
  • [host]: This should be left as https://www.transifex.com to match your credentials config in your ~/transifexrc file.
  • [project_slug.resource_slug]: Your project and resource slugs, separated by a dot. These slugs are found in your project's URL; together, they uniquely identify your translatable resources.
  • source_file: This points to the source file directly.
  • source_lang: This is the source language of the resource.
  • type: The i18n type of the resource. Transifex natively supports a number of file formats, also referred to as resource types. While Transifex does its best to guess your file type based on the file extension and content, we ultimately requires you to specify the resource type. For a list of the available resource types, please refer to Supported File Formats.
  • file_filter: Here, we put the expression used to identify translation files in this project. (Optional)
  • trans.<lang>: This is used for translation files that don't follow a common naming schema and the file expression cannot be used to track them. (Optional)
    Common name schema: translations/<project_slug.resource_slug>/<lang>.<type>
  • minimum_perc: The minimum percentage a translation must be completed up to for the client to consider whether it should pull it or not. (Optional)

If you ever need to change the language of a file or correct the file path for a specific translation, you can edit this file directly. However, Transifex doesn't offer a way to revert your configuration changes. So be sure to back up the original file before making edits.

Language mappings

By default, Transifex uses ISO 639-1 language codes. If you use language codes other than the standard ISO ones, the Transifex Client offers a quick and easy way to set up custom one-to-one language mappings. You'll just need to add a lang_map section to the .tx/config file and structure it as follows:

lang_map = REMOTE_CODE: LOCAL_CODE, REMOTE_CODE: LOCAL_CODE 

For example:

lang_map = el: el_GR, sr@latin: sr_latin

You can even combine global mappings, which apply to all resources and are placed in the [main] section of your configuration file, with resource-specific language mappings, which extend the global mapping with the local ones. For example:

[main]
host = https://www.transifex.com
lang_map = el: el-GR, de: de-DE

[foo.bar]
file_filter = translations/foo.bar/<lang>.po
source_lang = en
lang_map = fr: fr-FR

Be sure to include the space between the colon and desired language code, e.g. lang_map = el: el-GR.

With the above configuration, you'll be able to pull the Greek translations with this command:

tx pull -l el

Language mapping only works with one-to-one relations. It will not work with many-to-one setups.