Skip to the content.

Website Translation

To translate a website, I followed these successful & unsuccessful steps.

Processes will be explained with details in the following.

Download Website

wget -A html --random-wait --convert-links --adjust-extension --page-requisites --no-clobber --no-parent --no-check-certificate --level 1 -U "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a2) Gecko/20110613 Firefox/6.0a2" -r https://www.website.com/

# or simply
wget -mkEpnp --level 1 --no-check-certificate -r https://www.website.com/

Copy Files to DirectAdmin (Client Server)

cd /path/of/downloaded/files/
scp -r ./* $username@$ip:/home/$username/domains/$domainname/public_html/

Translate with GTranslate

  1. You need to select your plan and subscribe GTranslate.
  2. You will receive an email including username and password when you subscribe.
  3. According to these informations login the dashboard.
  4. In Setup Wizard, complete the steps according to your case (remember to choose URL Structure and define CNAME records properly in step 2).

How to Set CNAME Records Properly in DirectAdmin

  1. Add the html file content (obtained at the end of step 3) in a proper place to your index.html file.

Sample html content to add flags and dropdown which will be added to index.html for Türkçe, English, and Hindi should be:

<!-- GTranslate: https://gtranslate.io/ -->
<a
  href="#"
  onclick="doGTranslate('en|en');return false;"
  title="English"
  class="gflag nturl"
  style="background-position:-0px -0px;"
  ><img
    src="//gtranslate.net/flags/blank.png"
    height="16"
    width="16"
    alt="English" /></a
><a
  href="#"
  onclick="doGTranslate('en|hi');return false;"
  title="Hindi"
  class="gflag nturl"
  style="background-position:-500px -100px;"
  ><img
    src="//gtranslate.net/flags/blank.png"
    height="16"
    width="16"
    alt="Hindi" /></a
><a
  href="#"
  onclick="doGTranslate('en|tr');return false;"
  title="Turkish"
  class="gflag nturl"
  style="background-position:-100px -500px;"
  ><img
    src="//gtranslate.net/flags/blank.png"
    height="16"
    width="16"
    alt="Turkish"
/></a>

<style type="text/css">
  <!--
  a.gflag {
    vertical-align: middle;
    font-size: 16px;
    padding: 1px 0;
    background-repeat: no-repeat;
    background-image: url(//gtranslate.net/flags/16.png);
  }

  a.gflag img {
    border: 0;
  }

  a.gflag:hover {
    background-image: url(//gtranslate.net/flags/16a.png);
  }
  -->
</style>

<br /><select onchange="doGTranslate(this);">
  <option value="">Select Language</option>
  <option value="en|en">English</option>
  <option value="en|hi">Hindi</option>
  <option value="en|tr">Turkish</option>
</select>

<script type="text/javascript">
  /* <![CDATA[ */
  function doGTranslate(lang_pair) {
    if (lang_pair.value) lang_pair = lang_pair.value;
    if (lang_pair == "") return;
    var lang = lang_pair.split("|")[1];
    var plang = location.hostname.split(".")[0];
    if (
      plang.length != 2 &&
      plang.toLowerCase() != "zh-cn" &&
      plang.toLowerCase() != "zh-tw"
    )
      plang = "en";
    location.href =
      location.protocol +
      "//" +
      (lang == "en" ? "" : lang + ".") +
      location.hostname
        .replace("www.", "")
        .replace(RegExp("^" + plang + "\\."), "") +
      location.pathname +
      location.search;
  }
  /* ]]> */
</script>

How to Enable URL Translation

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

How to Edit Translations

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

For more information, visit the GTranslate’s Documentation

Translate with LibreTranslate (Free But Poor Results)

sudo apt install python3-pip -y
pip install libretranslate
reboot
libretranslate --host $IP --port 5000
# to find the value of $IP, run `ipconfig` command on your server.
# if you are using a virtual machine as a remote server, you need to go through "Settings | Network" and set the value of "Attached to:" as "Bridged Adapter" on VirtualBox App which will create an IP address of your virtual machine from your DHCP source. Then, press "OK".
# at the end, you will be able to connect from your local computer in browser with "$IP:5000"
# check the connection on client server
telnet $IP $port
# if the result is 'connected' then there is no problem

NOTE: Downloaded files will be under /tmp/libretranslate-files-translate on client server.