Website displayed in multi language

| posted in: Localization | 0


How a website can be displayed in more than one language?

Ideamine 7 is project where the content on the website can be displayed in English or in Russian depending upon the language chosen by the user.

Below are the steps on how it is done

Create a .po file

Using the poEdit tool you can parse the .po file to create the .mo file

In the .po file you need to mention the id and the value

If the site is needed in two different language then you need to have two .po files.Which have the same id but different values

Below is an example where the id is the same but value is mentioned in English and in Russian

Value in English

msgid “label_please_enter_first_name”

msgstr “Please enter first name”

Value in Russsian

msgid “label_please_enter_first_name”

msgstr “Пожалуйста, введите имя”

Using phptal in HTML you can call this id, which is replaced by the value that you give in the .mo file

Below is an example on how you call this id

${php: this.translate(label_please_enter_first_name ‘)}

In ideamine 7 we have created two .po files , one for English and one for Russian

In Ideamin7 we have two login forms on the home page. One in English and one in Russian . Depending upon the form used, a session variable is set to that particular language and  the site is displayed in that particular language.

Depending upon the value of the session variable, that particular mo file is called in in the translator.php

If the user wants to switch the language he can do so by clicking on the preferred language in the dropdown which is provided  at the top on every page.Doing so will change the value of the session variable to that particular language.

Previous Post

Leave a Reply