Often our users need to have multiple languages in own Bitrix24 self-hosted version
. This post will describe the nuances and options available in the Bitrix platform, as well as set forth a few examples.
To start, let’s determine what phrases are truly parts of the product’s source code and which are not. Everything that you can see is either content (static or dynamic) or product phrases. In the image below, the highlighted sections are content. Everything else is source (and thus will be listed in the translation).
Non-highlighted phrases are the source code.
Bitrix24’s self-hosted versions are provided in 3 languages: English, German, and Russian (available English-German, English-Russian, English) Our partners
provide and support other localizations of the product in other languages.
To have your start working with one of the localizations, you need to add a new language to the system and upload the translation packet through updates (documentation
If you need a different language (one not listed) then you will need to create a new language in the system and perform the translation yourself. Here are the details of how to do that:
Managing interface languages
Content has no relationship to the Bitrix product distribution kit, its localizations, additional languages, etc. That is, content can be entered into the site in one, or any number of, languages.
What else do you need to know
The front end of Bitrix products, naturally, is what can be seen by visitors to the site or intranet. The back end (Control Panel) is a special area containing the system administration interface.
The back end (which includes the top panel shown below) has a ‘switch’ to let you change languages in the back end of the product for the given user.
The various mechanisms, including the soft buttons, that allow changing languages in the front end are not part of the product’s regular configuration. An example of one way to add language buttons is set out below.
Language switch in the front end
Let’s look at one way to put in a language switch in the front end. This switch will change the language displayed in system phrases of the product only in the front end. Each user can choose the language for himself or herself.
1. Add the following code to the /bitrix/php_interface/dbconn.php
setcookie("USER_LANG", $_GET["user_lang"], time()+9999999, "/");
2. In the <head> section, the header (/bitrix/templates/<template>\header.php
) of the site template needs to have this code added:
function replaceQueryParam(param, newval, search)
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
var query = search.replace(regex, "$1").replace(/&$/, '');
return (query.length > 2 ? query + "&" : "?") + (newval ? param + "=" + newval : '');
window.location = replaceQueryParam('user_lang', document.getElementsByName('Lang').value, window.location.search);
3. Then we add the visual output (the language switch) to the template using this code:
<?echo CLanguage::SelectBox('Lang', LANGUAGE_ID,'','action_lang()');?>
The switch can be added as in either the header or footer of the template, depending on the design. For more details about design, follow these links: Bitrix Web Online Help
& Templates management
The language switch does not translate content to the needed language, all it does is change the source code phrases to the given language.
Note: when this language switch method is used, several intranet areas (such as email templates, etc.) may stay in initial site language. Also when switching the language from the public part of your intranet also switches the language used in administrative part of the intranet.
Switching languages of content
If you need to divide content by language, then you need to use a ‘language mirror’ of the site or multiple sites: Adding support for multiple sites
In the first case, duplicate content is created in the second language. Static content (pages and sections) in this case needs to be separated by folders, for example:
To have dynamic content draw from the proper sources, separate sources in each language must be established.
For example, to have a News page in the right language, the component needs to point to an infoblock which has news items written in that language.
The language switch must point to a folder with content in the other language.
When using the multi-site capability of the Bitrix platform, a new site is created with its own content and objects (infoblocks, polls, banners, training courses, etc.) in the given language. The advantages of this method and configuration help can be found in the link shown above.