Set a Project (Local or Remote)
tx set command allows you to configure and edit your Transifex project files on your computer. This can be done using either local files or files already on Transifex.
Setting the auto-local can be used to set up your config file using files already on your computer. The project must already exist on the Transifex server, 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
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:
- If set command returns without error you can execute by putting
--executeon the end.
Auto-remote setup can be used to retrieve the configuration of a project that's already on 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 must have the following format:
If you would like to select a specific resource, use the following URL format:
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)
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.
Other Set commands
$ 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
--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.