There are two configuration files the client uses. Both are text files you can edit by hand. In this article, we’ll go over the structure of each file so you’ll know what to look for if you do need to edit them. Before you can see anything in the two files, you should run the
tx init and
tx config commands first.
~/.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] api_hostname = https://api.transifex.com hostname = https://www.transifex.com password = api_token/password username = api/your_username
There are a few things to note:
- If you're using an API token, use
apias your username and the token as the password.
- If you update your Transifex credentials, you should also update this file.
If for some reason you need to override the system-wide credentials, you can add a separate
.transifexrc file to the local directory where your translation files are. However, you should be careful to not share the file with others since it contains your credentials, i.e. don’t track the file with git.
.tx/config file file is used to map files in a local repo/directory to resources in Transifex. This file is stored in the
.tx folder in your repo’s root directory.
[main] host = https://www.transifex.com [project_slug.resource_slug] file_filter = locale/<lang>/ui.po source_file = locale/ui.pot source_lang = en type = PO trans.pt_PT = locale/tier2/pt_PT/ui.po trans.fr_CA = locale/tier2/fr_CA/ui.po
.tx/config file is separated into multiple sections: one for global settings called
[main] at the top, then sections after that for project resource-specific settings.
- [main]: This section has configuration settings shared across multiple projects and resources.
- host: This should be left as
https://www.transifex.comand match the
- [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 resources. For example, if you have a URL such as
www.transifex.com/myorganization/myproject/myresource/, the resource identifier will be
- file_filter: A path expression which reflects the file/directory structure of your translation files. The expression must be in quotes and contain the <lang> keyword, denoting where the file paths differentiate per language, e.g.
- source_file: This points to the location of the source file.
- source_lang: This is the source language of your project, such as
enfor English. This is the language you selected when you created your project.
- type: This sets the type of the resources in your project, e.g. to PO. See the File formats section for details about the i18n type of each format available.
- trans.<lang>: This is used for translation files that don't follow a common naming schema and can’t be tracked by the
- minimum_perc: The minimum translation completion percentage a resource must be at in order for the client to pull the translations. (Optional)
If you ever need to change the language of a file or correct the file path for a specific translation, you can edit the
.tx/config 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.
By default, Transifex uses ISO 639-1 language codes. If you use language codes other than the standard ISO ones, the client lets you 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
Language mapping only works with one-to-one relations. It will not work with many-to-one setups.
The remote code is the language code supported by Transifex. And the local code is your language code.
lang_map = pt_PT: pt-pt, pt_BR: pt-br
You can use the
lang_map option globally by placing it in the
[main] section or use it for a specific resource. If you use it on a resource level, it’ll extend or override the global mappings.
[main] host = https://www.transifex.com lang_map = pt_PT: pt-pt, pt_BR: pt-br [project_slug.resource_slug] file_filter = locale/<lang>/ui.po source_file = locale/ui.pot source_lang = en lang_map = fr_CA: fr-ca type = PO
Be sure to include the space between the colon and desired language code, e.g.
lang_map = pt_BR: pt-br.
With the above configuration, you will, for example, be able to pull the Brazilian Portuguese translations with this command:
$ tx pull -l pt_BR