如何为Bitrix CMS添加多语言功能及设置网站多语言属性
Hey there! I’ve worked with Bitrix CMS on several multi-language projects, so let’s break down exactly how to set this up for your existing site:
Step 1: Enable & Add Languages in the Backend
First, log into your Bitrix admin panel and navigate to System Settings > Language Management.
- Click the "Add Language" button. Fill in the required details:
- Language ID: Use standard codes like
enfor English,esfor Spanish,frfor French. - Language Name: The display name users will see (e.g., "English").
- Character Set: Stick with
UTF-8for universal compatibility. - You can upload official Bitrix language packages here if you don’t want to translate every string manually.
- Language ID: Use standard codes like
- After adding, make sure to set the default language (the one users see first) by toggling the "Default" option next to your preferred language.
Step 2: Turn On Multi-Language Support for Your Site
Head to System Settings > Sites > [Your Site] > Edit.
- Look for the "Multi-language support" section and toggle it to "On".
- Link the languages you added earlier to your site—this tells Bitrix which languages are available for this specific website.
Step 3: Configure Language Access Properties
Still in the site edit page, go to the Multi-language tab to set how users switch between languages. You have three common options:
- URL Parameter: Use a query string like
?lang=ento switch languages. Set the parameter name (default islang) and map each language to its code. - Path Prefix: Add a prefix to your URLs (e.g.,
/en/for English,/es/for Spanish). This is great for SEO. Just enter the prefix for each language here. - Independent Domain/Subdomain: Assign a unique domain or subdomain to each language (e.g.,
en.yourdomain.comoryourdomain.es). Enter the full domain for each language in this section.
Step 4: Add a Language Switcher to Your Template
To let users toggle languages, you’ll need to add a switcher to your site’s template. Here’s a simple PHP snippet you can insert into your header or footer:
<?php // Fetch active languages $langList = \Bitrix\Main\Language\LanguageTable::getList([ 'filter' => ['ACTIVE' => 'Y'], 'select' => ['LID', 'NAME'] ]); // Generate switcher links while ($lang = $langList->fetch()) { if ($lang['LID'] === LANGUAGE_ID) { // Highlight current language echo "<span class='active-lang'>{$lang['NAME']}</span>"; } else { // Create switch link with current page context $switchUrl = $APPLICATION->GetCurPageParam("lang={$lang['LID']}", ['lang']); echo "<a href='{$switchUrl}' class='lang-link'>{$lang['NAME']}</a>"; } // Add separator between languages if ($langList->current() !== null) echo " | "; } ?>
Style it with CSS to match your site’s design, and you’re good to go.
Step 5: Translate Your Site Content
- Static Text (Modules/Components): Go to System Settings > Language Files to edit translations for built-in modules and components. You can also use the "Translate" button directly in component settings for quick edits.
- Dynamic Content (News/Products): When creating or editing content (like news items or catalog products), look for the language tabs at the top of the editor. Fill in the translated content for each language you’ve enabled.
- Templates: If you have hardcoded text in your template files, replace it with language variables using
GetMessage("YOUR_VARIABLE_NAME"), then add the translations to your site’s language files.
Pro Tips
- Clear your site cache after making language changes—Bitrix caches a lot of content, so this ensures updates show up immediately.
- For SEO, make sure each language version has unique meta titles, descriptions, and URL structures (path prefixes or subdomains work best here).
- Test each language thoroughly to ensure all components, forms, and dynamic content load correctly.
内容的提问来源于stack exchange,提问作者Ilkin Guluzada

