Posted by Dave on

Auto-translating a web page

Auto-translating a web page

This page was originally set up in 2015 when looking at using REST to invoke web site translations. My original code is still available on the test web site and below but Google & Babelfish have changed their APIs. I decided to refactor the page in 2022. The changes in the google API have been significant and my ambitions of including popular first languages in the UK led me to implement the gtranslate widget in 2022. This post has some use if you want to copy the version 2 code, but I have marked the page as ‘deprecated’.

Translation

This section of the post is in three parts. The original  post, when I updated it to add some more popular languages in use in the UK and thirdly about implementing the plugin/widget. These are documented in the following order, the recent hand crafted solution, shown on one of my test sites, my searching for a widget, and then the old code, which you can hide, as it uses a retired google translate API.

Version 2

I made some changes today in the translation code, you’ll need to check the code; it moves the site to a google domain and translates the URL too, even when a domain changes.

Here is the current Polish code;

<A HREF=”https://test-davelevy-info.translate.goog/?_x_tr_sch=http&_x_tr_sl=en&_x_tr_tl=pl&_x_tr_hl=en-US&_x_tr_pto=wapp”
TITLE=”polski, tłumaczenie Google”><IMG SRC=”images/pl.png” ALT=”Polish” WIDTH=”16″ HEIGHT=”11″ BORDER=”0″></A>

I developed this by hand, and the test site now has an extra four translation buttons, which is a bit of a pain. So I had a look to see if there are any plugins,

Plugins

I found these articles,

    1. 9 Best WordPress Translation Plugins for Multilingual Websites from wpbeginner, who have always been good in the past.
    2. https://blog.hubspot.com/website/best-language-translation-plugins-for-wordpress, from blog.hubspot.com by Amanda Sellars, she does 11, but repeats the popular ones from wpbeginner.
    3. gtranslate, a wordpress plugin, 5 Stars, 300,000+ installs and over 2300 reviews, and is recommended by wpbeginner
    4. Google website translator also looks interesting; a one off fee published by someone, or a collective called prisna.



Stylist

The stylist implementation just involved capturing some of the bullet item i.e. list item within a class name, so that the local stylist rules could be applied. I was looking at Stylist because the of the Neverwinter Vault but that’s gone now.


Comments ( 4 )

  1. Reading Danilo Poccia’s Italian language blog | Well Red
    […] is quite easy. Other colleagues experimented with this technique and use case and I wrote it up at http://wiki.davelevy.info/auto-translating-a-web-page/ after running it on my test site for several […]
  2. ReplyAuthorDave
    Much of this has gone away which I discovered when tidying up my broken links. I have left the links in place in case I want to come back to it.
  3. ReplyAuthorDave
    I added the 2nd to 4th most popular languages in the UK to http://test.davelevy.info, Polish, Punjabi and Urdu. I have hidden the old code, published the current code, and documented some plugins, which look a better answer.
  4. ReplyAuthorDave
    On changing the theme, I needed to upgrade the featured image and did so; in doing so I tidied up the text, especially the excerpt text. This page is marked as deprecated as I now use the gtranslate widget.

This site uses Akismet to reduce spam. Learn how your comment data is processed.