• Documentation
  • Transifex Live
  • Installing the Transifex Live JavaScript Snippet

Installing the Transifex Live JavaScript Snippet

The Transifex Live JavaScript snippet is needed in order to publish translations and make them visible your site’s visitors. You don’t need to install the snippet to start approving or translating strings if you plan to use the in-app (iFrame) version of Transifex Live. However, we recommend installing the snippet before doing anything else so that you can take advantage of the Transifex Live sidebar, which runs directly on your site.

Adding a website for translation

Before you can get the JavaScript snippet to add to your site, you’ll need to have a website/Live resource in your web project. The resource will hold your source content and translations. Here’s how to add one if you don’t have one yet:

  • Create a web project if you don’t have one yet.

  • Select your project from the project navigation in the Dashboard.

  • Click the Add website button in the right panel.

  • Type your website’s URL into the URL field and click Create resource.

Getting the snippet

Each site you translate with Transifex Live (i.e. each resource) has a unique snippet associated to that site’s URL.

Now that you have a web project and resource, you can get the snippet:

  • Navigate to the Dashboard and select the project with the resource you want to get the snippet for.

  • Click on Resources.

  • From the list of resources, click on the one you want to get the snippet for.

    tx-resource-list.png#asset:971

  • In the header, click Settings.

  • Copy the snippet from the popup.

    tx-live-snippet.png#asset:972

Installing the snippet

After you have copied the snippet, paste it before the </head> tag of each page you want to translate. And that’s it. You’ll now be able to trigger the Transifex Live sidebar on your site and approve strings for translation.

Some CMSes or publishing platforms might not let you edit the HTML directly. In such situations, look for a field where you can paste JavaScript (e.g. a Google Analytics snippet) and add the Live snippet there.

Using Transifex Live on a staging server

Staging servers are often used to test or preview things out before they go live. If you have a staging server, you can use the same JavaScript snippet for both your production (live) and staging sites. This lets you approve and translate content from the staging server before taking them live on your production server – without needing to do any duplicate work.

Simply return to the Settings popup you copied the snippet from, enter in your staging domain, and hit Save settings.

tx-staging-domain.png#asset:973