Product
Blog Setting up multiple languages in Bitrix24 Self-hosted

Setting up multiple languages in Bitrix24 Self-hosted

Bitrix24 tips and updates
Vlad Kovalskiy
5 min
17337
Updated: April 5, 2023
Vlad Kovalskiy
Updated: April 5, 2023
Setting up multiple languages in Bitrix24 Self-hosted
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).

3160f95a97d51f7243a3a5d38050e60b.png

Non-highlighted phrases are the source code.

Product phrases


Bitrix24’s self-hosted versions are provided in several languages: English, German (available English-German, 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 & Integration.

About content


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.

d44d5da28b9e604d1a2b00df30d20bdb.png

 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.

57215b8f0801c956aa456f6a78f887d6.png

1. Add the following code to the /bitrix/php_interface/dbconn.php file:

<?
$arLang = array("en", "pl", "la");
if (isset($_GET["user_lang"]) && in_array($_GET["user_lang"], $arLang))
{
   setcookie("USER_LANG", $_GET["user_lang"], time()+9999999, "/");
   define("LANGUAGE_ID", $_GET["user_lang"]);
}
elseif(isset($_COOKIE["USER_LANG"]) && in_array($_COOKIE["USER_LANG"], $arLang))
{
   define("LANGUAGE_ID", $_COOKIE["USER_LANG"]);
}
?>

2. In the <head> section, the header (/bitrix/templates/<template>\header.php) of the site template needs to have this code added:

<sc ript>
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 : '');
}
function action_lang()
{
      window.location = replaceQueryParam('user_lang', document.getElementsByName('Lang')[0].value, window.location.search);
}
</sc ript>

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:

En
...About
...Company
...News
De
...Über uns
...Mitarbeiter
...News

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.

Most Popular
Enhance Your Data Analysis With Jinja Templates In BI Builder
Bitrix24's Seamless Drive Integration and Collaborative Editing Explained
New BI Builder In Bitrix24 CRM
Bitrix24 Spring 2024 Live Webinars
Meet Bitrix24 CoPilot Pro
Table of Content
Product phrases About content What else do you need to know Language switch in the front end Switching languages of content
You may also like
articles
webinars
glossary

Free. Unlimited. Online.

Bitrix24 is a place where everyone can communicate, collaborate on tasks and projects, manage clients and do much more.

Start for free
You may also like
Product Properties In Deals
Bitrix24 tips and updates
Product Properties In Deals
1 min
Bitrix24 Plans: Which One To Choose
Bitrix24 tips and updates
Bitrix24 Plans: Which One To Choose
3 min