• Documentation
  • CLI Client
  • Set a Project (Local or Remote)

Set a Project (Local or Remote)

The tx set command allows you to configure and edit your Transifex project files (ie. the configuration of the Transifex Client) on your computer. This can be done using either local files or files already on Transifex.

Auto-local setup

Setting up your config files using auto-local is the typical workflow. You can use this when you have certain local paths to source/target language files and you want to associate those with a resource on Transifex. The typical workflow is to issue one auto-local command for each source file (and target file expression) in order to associate it with a single resource on Transifex.

The project must already exist on the Transifex server (usually, an empty one), so if you haven't already created it, login to the web interface and do so before continuing.

$ tx set --auto-local -r <project_slug.resource_slug> '<expr>'
--source-lang en --type PO [--source-file <file>]
  • project_slug.resource_slug: Your project and resource 'slugs', separated by a dot. These are the strings found on your project's URL and together they uniquely identify your translatable resource. For example, if you have a URL such as www.transifex.com/projects/p/myproject/resource/myresource/, the unique slug will be myproject.myresource.
  • source_lang: This is the source language of your resource, such as 'en' for English. This is the language you selected, when you created your project at Transifex.
  • expr: An 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, for example: translations/po/<lang>.po.
  • type: This flag sets the type of the resources in your project. In this case, to PO. See the section File formats for details about the i18n type of each format available.
  • If your source file doesn't follow the common naming schema, you can specify a custom path for the source file using the '--source-file file' option.
    Common name schema: translations/<project_slug.resource_slug>/<lang>.<type>
  • If set command returns without error you can execute by putting --execute on the end.

Here's an example with a sample directory structure and a tx set command.

ui/locale/ui.pot
ui/locale/fr/ui.po
ui/locale/de/ui.po

$ tx set --auto-local -r myproj.myresource 'ui/locale/ui.po \
--source-lang en --type PO --source-file ui/locale/ui.pot

Auto-remote Setup

Typically, when running tx set, we already know where the location for the local files (eg. in `translations/<lang>/foo.yml`).

In some cases though, we might already have a bunch of files in Transifex (uploaded in some other way) but no Transifex Client configuration. You could run a number of auto-local commands, or, you can run a single auto-remote command instead. Auto-remote is a shortcut that takes a Transifex URL and creates a simple, standard local directory structure. It's handy to quickly download files from Transifex.

The command below can be used to initialize a local project for the remote project or resource specified by the given URL. Once configured, this will allow you to push and pull files from your Transifex project.

$ tx set --auto-remote <url>

URL Configuration

URL must have the following format:

https://www.transifex.com/<organization_slug>/<project_slug>/

If you would like to select a specific resource, use the following URL format:

https://www.transifex.com/<organization_slug>/<project_slug>/<resource_slug>/

Sample project setup and upload

For instance, let's say you have a class open-source git-hosted Gettext-i18nized project. Here's a set of commands you might use to create a resource off your master branch:

$ git clone http://git.example.com/git/myproject.git
$ cd myproject
$ tx init
$ tx set --auto-remote  https://www.transifex.com/projects/p/<myproject>/resource/<myresource>/
$ tx set --auto-local -r <myproject>.<myresource> 'po/<lang>.po' --source-lang en \
--type PO --source-file po/<myproject>.pot
$ tx push -s -t
Pushing 'el' translations (file: po/el.po)
Pushing 'gu' translations (file: po/gu.po)
Pushing 'mr' translations (file: po/mr.po)

Note

There is no requirement for your resource file name to match your resource name, but the consistency might benefit others who come along later.

Keep in mind that the --auto-local option overwrites your existing .tx/config file.

$ tx set --source -r <project_slug.resource_slug> -l <lang> <file>

This command simply sets the source file and the source language of a specific resource. It can be used to initialize new resources or update existing ones.

$ tx set -r <project_slug.resource_slug> -l <lang> <file>

This command can be used to set individual translation files mapped to a certain language. This is useful when your translation files don't use a common naming schema and the --auto-local command cannot be used.

You can also use the set command to set the type of each resource with the -t or --type option. For example:

$ tx set -t <type> -r <project_slug.resource_slug>

This command sets the type of the resource to the selected type.

$ tx set -t <type>

This one sets the type of all resources in your project to the selected type.

Of course, you can use the -t option in combination with the --auto-local option, too.

See the section File formats for details about the i18n type of each format available.

Furthermore, the set command has a minimum-perc option, which you can set the minimum percentage option, either globally or for a specific resource of your project with. The value of this option specifies the minimum percentage a translation of a resource must be completed in a language in order to download it. For example:

$ tx set --minimum-perc=20

This command set the minimum percentage at 20% completion.

Similarly, it has a mode option to define the mode for the downloaded files.