3

This is a scenario.

I have this website, as an example: www.service.com which serves default English content. The site has also several domain aliases which have the word service in another languages.

So the idea is: how to make sure, when a user that accesses the website using for example Italian alias www.servizio.com is presented with the main website content, but only in Italian language, or Italian section of the website?

I know this largely depends on how the website is structured in terms of dealing with multi-language support.

But let's assume it isn't about languages at all. Let's assume the Italian example from above should see some other content or even page, which is also accessible (or navigable) through the main version.

Since aliases preserve the URL, is my best bet to check for the host (URL), then proceed to serve whatever content should be served based on it?

1

Script Translate, IP Translate WordPress Translate

There are various ways to do this. Two of the most popular are to do the following:

  1. Check the IP of the visitor and redirect to a subdomain which is written in their language. Example: https://gb.example.com or https://de.example.com.
  2. Use a script to translate the site language into the user's language, either automatically or by choice. Some scripts will translate the language based on your own translations, or use a service such as Google Translate.

Detecting Languages Via Google Cloud API

use Google\Cloud\Translate\TranslateClient;

// $text = 'The text whose language to detect.  This will be detected as en.';

$translate = new TranslateClient();
$result = $translate->detectLanguage($text);
print("Language code: $result[languageCode]\n");
print("Confidence: $result[confidence]\n");

WordPress Plugins

If you are using WordPress, you can find many good plugins such as Translator Revolution to do this for you with many customisable options.

My Personal Preference

Personally, I prefer a site that first translates to my computer's language and gives me the choice to change. I don't like sites that demand I use the language based on my location. This is no good if you are on holiday for example.


enter image description here

Further Readin:

Google Translate AI Invents Its Own Language to Translate With

Google Translate is getting brainier. The online translation tool recently started using a neural network to translate between some of its most popular languages – and the system is now so clever it can do this for language pairs on which it has not been explicitly trained. To do this, it seems to have created its own artificial language.

Five Best Language Translation Tools

When you need to translate one language to another, there are lots of technology options that can help. In this week's Hive Five, we're looking at five of the best translation tools, based on your nominations.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.