• Documentation
  • Javascript SDK
  • Uploading source content to Transifex

Uploading source content to Transifex


Transifex Native is currently in BETA. To learn more about the solution or to have a hands on experience please get in touch with us.

After the strings have been marked for translation in the code, you can push them to Transifex.

In order to be able to do so, first make sure that @transifex/cli library is installed either locally using the command

$ npm install @transifex/cli --save

or globally using

$ npm install -g @transifex/cli

Then call the command line using:

$ ./node_modules/.bin/txjs-cli push <SRC_FOLDER> --token=<PROJECT_TOKEN> --secret=<PROJECT_SECRET>

or for global installation

$ txjs-cli push <SRC_FOLDER> --token=<PROJECT_TOKEN> --secret=<PROJECT_SECRET>

Apart from passing credentials to the command line, you can also set them as environment variables:

$ txjs-cli push <SRC_FOLDER>

This command works in two phases:

  • First, it goes through all the files of the current directory (and subdirectories) and collects all translatable strings in memory
  • Then, it contacts Transifex and pushes the strings with all the metadata to the project (and resource) that is associated with the token you have given during setup

This way, the source strings reach Transifex and become available for translation.

Push command options

Here is a full list of command line options:

  $ txjs-cli push [PATTERN]

  PATTERN  [default: **/*.{js,jsx,ts,tsx}] file pattern to scan for strings

  -v, --verbose        Verbose output
  --cds-host=cds-host  CDS host URL
  --dry-run            Dry run, do not push to Transifex
  --purge              Purge content on Transifex
  --secret=secret      Native project secret
  --tags=tags          Globally tag strings
  --token=token        Native project public token

  Parse .js, .ts, .jsx and .tsx files and detect phrases marked for
  translation by Transifex Native toolkit for Javascript and
  upload them to Transifex for translation.

  To push content some environment variables must be set:
  TRANSIFEX_TOKEN=<Transifex Native Project Token>
  TRANSIFEX_SECRET=<Transifex Native Project Secret>

  or passed as --token=<TOKEN> --secret=<SECRET> parameters

  Default CDS Host is

  txjs-cli push -v
  txjs-cli push src/
  txjs-cli push /home/repo/src
  txjs-cli push "*.js"
  txjs-cli push --dry-run
  txjs-cli push --tags="master,release:2.5"
  txjs-cli push --token=mytoken --secret=mysecret
  TRANSIFEX_TOKEN=mytoken TRANSIFEX_SECRET=mysecret txjs-cli push