GTranslate: A Simple WordPress Translation Plugin Using Google Translate
I’ve hesitated to use machine translations of my site in the past. I’d love to have translators all over the planet to assist in translating my site for different audiences, but there’s no way I would recoup those costs.
That said, I noticed that my site content is shared internationally quite a bit – and many people are using Google Translate to read my content in their native language. That makes me optimistic that the translation may be good enough now that Google continues to improve using machine learning and artificial intelligence.
With that in mind, I wanted to add a plugin that offered translation using Google Translate, but I wanted something more comprehensive than a dropdown that translated the site. I want search engines to actually see and index my content internationally, which requires a couple of features:
- Metadata – when search engines crawl my site, I want
hreflang
tags in my header to provide search engines with the different URL paths for each language. - URL – within WordPress, I want the permalinks to incorporate the translation language in the path.
My hope, of course, is that it will open my site up to a much wider audience, and there’s a great return on investment as I can increase my affiliate and advertising revenue – without requiring the effort of manual translation.
GTranslate WordPress Plugin
The GTranslate plugin and accompanying service incorporate all these features as well as many other options:
- Dashboard – A comprehensive service dashboard for configuration and reporting.
- Machine Translation – Instantaneous Google and Bing automated translation.
- Search Engine Indexing – Search engines will index your translated pages. As a result, people can find a product you sell by searching in their native language.
- Search Engine Friendly URLs – Have a separate URL or Subdomain for each language—for example https://fr.martech.zone/.
- URL Translation – The URLs of your website can be translated, which is very important for multilingual SEO. You will be able to modify the translated URLs. You can use the GTranslate platform to identify the translated URL.
- Translation Editing – Edit the translations manually with GTranslate’s inline editor directly from the context. This is necessary for some things… for example, I wouldn’t want my company name, DK New Media, translated.
- In-line Editing – You can also utilize syntax within your article to replace links or images based on a language.
<a href="https://martech.zone" data-gt-href-fr="http://fr.martech.zone">Example</a>
The syntax is similar for an image:
<img src="original.jpg" data-gt-src-ru="russian.jpg" data-gt-src-es="spanish.jpg" />
And if you don’t want a section translated, you can add a class of notranslate.
<span class="notranslate">Do not translate this!</span>
- Usage Statistics – You can see your translation traffic and the number of translations on your dashboard.
- Subdomains – You can opt into having a subdomain for each language. I chose this rather than the URL path because it was less taxing on my webserver. The subdomain method is incredibly fast and just points directly to Gtranslate’s cached, translated page.
- Domain – You can have a separate domain for each language. For example, if you use a .fr top-level domain (tld), your site may rank higher in search engine results in France.
- Collaborators – If you’d like individuals to assist with manual translation, they can have access to GTranslate and add manual edits.
- Inline Edits – Navigate to your page and add
?language_edit=1
to the page URL to bring up an inline editor.
- Edit History – View and edit your history of manual edits.
- Seamless Updates – There is no need to check for software updates and install them. We care about further updates. You enjoy the up-to-date service every day
- Languages – Afrikaans, Albanian, Amharic, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Catalan, Cebuano, Chichewa, Chinese (Simplified), Chinese (Traditional), Corsican, Croatian, Czech, Danish, Dutch, English, Esperanto, Estonian, Filipino, Finnish, French, Frisian, Galician, Georgian, German, Greek, Gujarati, Haitian, Hausa, Hawaiian, Hebrew, Hindi, Hmong, Hungarian, Icelandic, Igbo, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kazakh, Khmer, Korean, Kurdish, Kyrgyz, Lao, Latin, Latvian, Lithuanian, Luxembourgish, Macedonian, Malagasy, Malayalam, Malay, Maltese, Maori, Marathi, Mongolian, Myanmar (Burmese), Nepali, Norwegian, Pashto, Persian, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian, Shona, Sesotho, Sindhi, Sinhala, Slovak, Slovenian, Samoan, Scots Gaelic, Somali, Spanish, Sundanese, Swahili, Swedish, Tajik, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Uzbek, Vietnamese, Welsh, Xhosa, Yiddish, Yoruba, Zulu
Sign Up for a GTranslate 15-Day Trial
GTranslate and Header Permissions
If you’ve opted to configure GTranslate using subdomains, you may have an issue where assets like fonts on your site aren’t loading correctly. To correct this, you’ll need a plugin to update your HTTP Headers to enable Allow-Control-Allow-Origin to share the resources across subdomains.
Or you can utilize this code (updating your domain) to your child theme’s functions.php
to automatically share resources across any subdomain:
// Add a policy for allowing assets to each of the subdomains.
function add_cors_http_header() {
// Get the HTTP origin of the request
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
// Check if the origin ends with '.martech.zone' or is 'martech.zone'
if (preg_match('/(\.martech\.zone|martech\.zone)$/', parse_url($origin, PHP_URL_HOST))) {
header("Access-Control-Allow-Origin: $origin");
}
// Other headers
header("Access-Control-Allow-Methods: GET");
header("Cache-Control: max-age=604800, public"); // One-week caching
$expires = gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'; // One-week expiration
header("Expires: $expires");
header("Vary: Accept-Encoding");
}
add_action('init', 'add_cors_http_header');