GTranslate TDN Documentation

Free setup is available

Please contact us and we will do the configuration for you for free.

Update: Now you can run Setup Wizard on your User Dashboard to configure GTranslate.

1. Choose URL structure

You can use sub-domain URL structure (http://es.example.com) or sub-directory URL structure (http://example.com/fr/) with your subscription. If you have Enterprise subscription and want to host your language on a top level country domain name (http://example.fr), please contact us.

Note: For Shopify shops you can only use sub-domain URL structure.

Configuring sub-directory URLs

WordPress: If you are using WordPress install GTranslate plugin and turn on "Sub-directory URL structure" option from GTranslate Settings page. Go to step 3.

You will need to have PHP and Apache on your server to use this option. If you have other than Apache web-server, please contact us.

  1. Download GTranslate URL add-on and unzip it
  2. Edit gtranslate/config.php file to set correct main_lang language code
  3. Upload gtranslate folder into www root directory
  4. Edit/create .htaccess file in www root directory and add the following into the top of the file:
    # gtranslate config
    RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ /$1/$3 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ /gtranslate/gtranslate.php?glang=$1&gurl=$2 [L,QSA]
    RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)$ /$1/ [R=301,L]
    
    

 

Configuring sub-domain URLs

To have sub-domain URLs you just need to add DNS CNAME records for each language. You will receive the list of CNAME records in the instructions email after you complete your order. After they are added your translations will be live in a couple of minutes. Go to step 2.

2. Add language selector

Download and add our GTranslate Free language selector to your website and use Sub-Domain or Sub-Directory URL structure option depending on your choice.

3. Final checks

If you have URL Translation feature available in your subscription and would like to turn it on, please follow Enable URL Translation instructions.

If you are using sub-domain URL structure and you have SSL on your website, let us know, so we can generate Let's Encrypt certificate for you or send us your wildcard SSL certificate and RSA private key files to be installed on our servers.

Note: Do not do both sub-directory and sub-domain configurations at the same time.

If you are having any issues, we can make the configuration for you, please contact us.


Adding a CNAME record

DNS is the component of the Internet which converts human-readable domain names (such as example.com) into computer-readable IP addresses (such as 192.0.32.10). It does this according to DNS zone files that reside on your server and tie domain names to IP addresses.

CNAME record stands for "canonical name record." This record creates an alias, allowing a querying server to continue the DNS lookup under the new name.

It may take up to 48 hours to add the record. Usually it takes less than 5 minutes. You can use nslookup command line tool to test if the record has been added.

You will receive the list of CNAME records in the instructions email after you complete your order.

You can check this great resource about how to add cname records which includes specifics for majority of domain registrars.

cPanel hosting

  1. Sign into your cPanel account
  2. Open Simple DNS Zone Editor under Domains.

    alt

  3. Select your domain from the drop-down box and in the section labeled Add a CNAME Record type in the Name (the language code) and CNAME of the record (GTranslate server name) and click Add CNAME Record button.

    alt

Plesk hosting

  1. Go to DNS Settings page.
  2. Add Record

    alt

  3. Select CNAME record type.

  4. Type in the Domain name (the language code) and Canonical name (GTranslate server name) of the record. Press the OK button to add the record.

  5. alt

Other control panels

If you cannot find the DNS management in your hosting panel, please consult your hosting how to add new DNS record. They should be able to do it for you if there is no place to manage your DNS records in the hosting control panel.

Enable URL Translation

WordPress: Turn on "URL Translation" option from GTranslate plugin Settings page.

Shopify: Turn on "URL Translation" option from GTranslate app Settings page.

Joomla, Drupal and Other platforms:

To enable URL translation feature for your website you need to add the following code into the head tag of your pages.

<meta name="uri-translation" content="on" />

Make sure it is on top of other tags inside head tag.

Editing Translations

In order to edit the translations you need to go to the language you want to edit and then add ?language_edit=1 to the URL. If you already have ? in the URL you need to add &language_edit=1 to the URL. For example to edit a text on home page in Spanish language you need to go to http://es.example.com/?language_edit=1 | http://example.com/es/?language_edit=1 which will open the edit interface.

You will be able to visually see the difference of already edited texts and automatically translated texts in edit mode. The texts with the red pencil icons are edited texts. Automatically translated texts are with the green pencil icons.

With the arrow icon you can edit the translated URLs.

Detecting selected language

If you want to code something special for individual language you can detect the current selected language and write your code based on that.

You can find the current selected language code from X-GT-Lang request header. If your site is written in PHP you can find it in _SERVER['HTTP_X_GT_LANG'] variable.

Redirect sub-directory URL structure to sub-domain URL structure

Add this rule on top of other rules in your .htaccess file.

RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ http://$1.domain.com/$2 [R=301,L,QSA]

Enable JSON format translation

In modern web applications data is being transferred through AJAX requests using JSON format. To be able to translate JSON we need to know which keys we may translate to not break the application. Let's say you have the following JSON data which needs to be translated:

{
    "name":"test",
    "description":"test description",
    "id":500,
    "months": ["January","February","March"],
    "content":"<i>Hello world</i>",
    "user": {
        "login":"test",
        "bio":"test user"
    }
}

You need to specify the keys to be translated in the JSON object by using special key gt_translate_keys. Like this:

{
    "name":"test",
    "description":"test description",
    "id":500,
    "months": ["January","February","March"],
    "content":"<i>Hello world</i>",
    "gt_translate_keys": ["name", "description", {"key": "months", "format": "list"}, {"key": "content", "format": "html"}],
    "user": {
        "login":"test",
        "bio":"test user",
        "gt_translate_keys": [{"key": "bio", "format": "text"}]
    }
}

As you can see from this example, gt_translate_keys should be array. It may simply specify the name of the key which value should be translated or specify also the format of the value. Possible formats are list, html or text which is the default format if not specified.

After it is translated it will look like this:

{
    "name":"тест",
    "description":"тестовое описание",
    "id":500,
    "months": ["Январь","Февраль","Март"],
    "content":"<i>Привет мир</i>",
    "user": {
        "login":"test",
        "bio":"тестовый пользователь"
    }
}

Try GTranslate with a free 15 day trial