Overview 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):
Installation Introduction 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: - Code:
<div class="fa_translate_container"> <span class="fa_translate fa_translate_fr">Voici la description du forum</span> <span class="fa_translate fa_translate_en">This is the description of this forum</span> </div> As you notice, the first line is in French and the second in English. The first line is a span with the class , the second is a span with the class 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 :
- Code:
<span class="fa_translate fa_translate_XX">Your text</span> |
- Show correspondence table:
Tip : To find matches, use your browser's search function (CTRL+F). Languages are listed in the language in question. Coded | Language | af | Africans | ak | Akan | am | Amharic | ar | العربية | ace | Asturianu | a-z | Azəri | be | Belarus | bg | български | bh | Bihari | good | Bengali | br | Brezhoneg | well | Tibetan | bs | Bosnian | that | Català | co | Corsican | cs | Cestina | there | Dansk | of | German | dv | Divhi | he | Ελληνικά | in | Français | oh | Esperanto | are | Spanish | and | Eesti | had | Euskara | fa | Farsi | fi | suomi | fo | Faroese | Fr | French | fy | Frisian | ga | Irish | gd | Scots Gaelic | gl | Galician | larp | Guarani | gu | Gujarati | Ha | Hausa | Hey | עברית | hey | हिन्दी | hr | Hrvatsky | uh | Magyar | hy | Armenian | ai | Interlingua | id | indonesian | ig | Igbo | is | Islenzka | it | Italiano | yea | 日本語 | jw | Javanese | what | ქართული | kk | Kazakh | miles | cambodian | kn | Kannada | kb | 한국말 | ku | Kurdi | ky | Kyrgyz | the | Latin | lg | Luganda | ln | Lingala | hey | Laothian | lt | Lietuvių | lv | Latviesu | mg | Malagasy | mid | Maori | mk | македонски | ml | Malayalam | min | Монгол | mo | moldavian | mr | Marathi | ms | Malay | mt | Maltese | born | Nepali | nl | dutch | no | Norsk (Nynorsk) | no | Norsk | ns | Northern Sotho | ok | Occitan | om | Oromo | gold | Oriya | not | Punjabi | please | Polsky | ps | Pashto | pt | Português | that | Quechuan | rm | romansh | rn | Kirundi | ro | romana | ru | Русский | rw | Kinyarwanda | her | Sakha | sc | Српски Ћирилица | sd | Sindh | if | Sinhalese | sk | Slovencina | sl | Slovenia | sn | Shona | so | Somali | square | Shqip | sr | српски | st | Sesotho | known | Sundanese | please | Svenska | sw | Swahili | your | Tamil | you | Telugu | tg | Tajik | th | ไทย | you | Tigrinya | tk | Turkmen | tl | Filipino | to | Tonga | tr | Turkce | tt | Tatarish | tw | 繁體中文 | ui | Uighur | uk | Українська | ur | Urdu | uz | Uzbek | vi | Tiếng Việt | cy | Cymraeg | xh | xhosa | yi | Yiddish | yo | Yoruba | zh | 中文简体 | you | Zulu |
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 " - Code:
es " and add consequently: - Code:
<div class="fa_translate_container"> <span class="fa_translate fa_translate_fr">Voici la description du forum</span> <span class="fa_translate fa_translate_en">This is the description of this forum</span> <span class="fa_translate fa_translate_es">Mon texte en espagnol</span> </div> Caution : lowercase letters are important! would not work, nor would .
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)
- Code:
.fa_translate { display: none; } 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.
Creation of the scriptFor the next step you need to go towards Administration Control Panel (ACP) Modules HTML & Javascript Javascript codes management and create a new code - upon verifying that Javascript codes management is enabled.
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: - Code:
var defaultTranslation = "en"; By default, the displayed language will be the English translation. You can replace it with any of your translations . If you have chosen French, English and Spanish, you can indicate either: , , or . Be sure to keep the quotation marks.
Notes | Approved by | Niko | | Approved on | February 8th, 2022 | | Tested on | Most recent browsers | | Difficulty level | / | | Source | Translation into several languages |
|