Javascript

Our JavaScript SDK offers a one line integration solution for any web site. The SDK detects new content on your site, synchronizes it with our service and downloads the latest translations back to your site. It also provides in-app translation tools that allow your translators to translate your site in-context and get immediate feedback on their progress.

Before Getting Started

Make sure you have a Translation Exchange account, and have created a project in your dashboard.

1. Install the Translation Exchange Script

Copy and paste the following javascript code between the <head> and </head> tags of your website. If you are using a third party web app builder like Squarespace or Wix, use one of our Integration Guides.

<script src="https://cdn.translationexchange.com/tools/tml/stable/tml.min.js"></script>  
<script>  
tml.init({  
    key: "YOUR-PUBLIC-KEY",
    translateBody: true,
    translateTitle: true
});
</script>  

Make sure to replace YOUR-PUBLIC-KEY with your project's key. You can find your project credentials in the Integration and API Keys section of the dashboard.

2. Add a Language Selector

To add a language selector create an HTML element on your page with a data-tml-language-selector attribute and indicate which language selector you want to use:

<div data-tml-language-selector="default"></div>  

There are a few language selectors to choose from. You can view all the available selectors or learn how to create your own in the Language Selectors section of the docs.

3. Enable Translation Mode

Once the script has been added to your page you can start using translation mode. To activate translation mode, press CTRL+Shift+i on your keyboard.

Once translation mode has been activated, the content of your application will be synchronized with the Translation Exchange Service and your strings will appear in your Dashboard.

Make sure to browse your entire application while in translation mode to ensure that all your content gets sent to the Translation Exchange service.

Now that your strings have been synchronized, you can start translating while in Translation mode or go to your dashboard to order professional translations.

4. Publish Your Translations

You will always be able to see your most up to date translations while in translation mode but translations must be published to be seen by your users. Go to the Releases section of the Translation Exchange Dashboard and press the Publish Translations button.

Your translations will be uploaded to our CDN (Content Delivery Network) and available to your users