|Management of several languages|
DescriptionThe structure of your forum already provides for effective language management, since each user can choose from more than a hundred languages in his profile. However, all the texts you insert cannot be translated, and are therefore in the language you write.
This tutorial allows you to provide the same text in several languages, and to display the text in the language of the user who consults your forum . It can be used in the description of the forums, on the home page , or even in your HTML pages (provided you check the Use the top and bottom of the forum box ). This trick can also be used in posts, if HTML is enabled there .
DemonstrationWhen the user visits the forum having chosen French as the language:
When the user visits the forum having chosen Spanish as the language:
When the user visits the forum having chosen a language not provided for in the translations (display of the default language):
Creation of the different versionsFor our example, we will use this trick in the description of a forum and we will provide an English text and a French text.
It is possible to add as many texts as there are languages supported by Forumotion (you will find a table below).
Insert the following code at the desired location:
The line will be displayed according to these two letters, which indicates the language used by the user. If you wish to add other languages, all you have to do is look in the table below for the corresponding two-letter code , and add a line like this, taking care to replace XX with the two-letter code obtained, before closing
Thus, if I want to add the language "Spanish" among the texts, I just have to find the line corresponding to this language, determine that the code is "
Caution : lowercase letters are important!
This step can be repeated with different texts for each location where a text needs to be translated . You can therefore repeat the operation for all the descriptions of your forums, for example, the rest of the tutorial will not change anything.
Hide these different versions by defaultOnce this first step is completed, you may notice that all versions are displayed simultaneously, which is not the expected effect. It is therefore necessary to hide all the texts before deciding which one to display. To do this, add to your custom Administration control panel (ACP) ► Display ► Images and colors ► Colors ► Stylesheet (CSS)
Display text in user's languageAll our texts are hidden by default, since only the text understood by the user should be displayed. To determine the user's language, we use the language that the user has chosen in his profile. It will therefore be enough to change the language of the profile so that the translated texts also change.
Determine a default languageIt is essential to foresee the hypothesis in which the user chooses a language other than those which you would have foreseen. Thus, if your forum is translated into English, French and Spanish, it is imperative to provide a default language if the user has chosen the "Italian" language in his profile, otherwise he would not see any text.
Our newly created script provides for this, and you can modify this:
|This resource belong to this community unless differently stated.|
No reproduction possible without our agreement, in accordance with article L122-1 of the CPI.