Forgot Password
 Register
View: 116|Reply: 2

How to add language Russian Português Vietnamese to Discuz! X5.0

[Copy Link]
Posted on 2026-04-07 10:11:08 | Show all floors |Read Mode
In Discuz! Open X5.0, the language package located in /source/i18n/ , so if you wanna add more language packages to the Discuz forum, Let's follow these steps:

1. Make translations for the origional package of SC_UTF8/TC_UTF8 , and save it in a new folder RU_UTF8, PT_UTF8, VI_UTF8 ...etc.
2. Upload the language packages into source/i18n/
3. Go to Admin Dashboard --> Tools --> Update Caches --> let's the Forum read the information of available language packages from server/hosting.
4. Back to Templages --> Language packages --> Enable the language package on the forum.
5. Now your forum will be the muli-language supported site:




Preview in : https://demo.discuzstore.com
Reply

Use Props Report

 Thread Author| Posted on 2026-04-09 16:04:21 | Show all floors
How to add Country Flags beside Language Package names:
1.Add this function into function_core.php:


  1. function getFlagByLangDir($langDir) {
  2.     static $flagMap = array(
  3.         'default' => 'en',   // default language =>
  4. 'br' => 'br',
  5.         'en' => 'en',
  6. 'es' => 'es',
  7.         'cn' => 'cn',
  8.         'tc' => 'cn',
  9.         'de' => 'de',
  10.         'fr' => 'fr',
  11.         'ru' => 'ru',
  12. 'in' => 'in',
  13.         'kr' => 'kr',
  14.         'vn' => 'vn'

  15.     );
  16.    
  17.     return isset($flagMap[$langDir]) ? $flagMap[$langDir] : 'en';
  18. }
Copy Code


2. Change the template file: template/discuzx5/cells/common/header/i18n_switch.htm


  1. <div><!--{if !empty($_G['setting']['i18n']) && !empty($_G['setting']['i18nLang'])}-->
  2. <style>
  3. .header-i18n {
  4.     position: relative;
  5.     margin-left: 15px;
  6.     cursor: pointer;
  7. }

  8. .i18n-icon {
  9.     display: flex;
  10.     align-items: center;
  11.     padding: 6px 10px;
  12.     background: #f5f5f5;
  13.     border-radius: 4px;
  14.     transition: all 0.3s;
  15. }

  16. .i18n-icon:hover {
  17.     background: #e8e8e8;
  18. }

  19. .current-lang {
  20.     display: flex;
  21.     align-items: center;
  22.     gap: 6px;
  23. }

  24. .flag-icon {
  25.     width: 22px;
  26.     height: 16px;
  27.     display: inline-block;
  28.     background-size: cover;
  29.     border-radius: 2px;
  30. }

  31. /* Country Flags List */
  32. .flag-cn { background-image: url(/static/image/flag/cn.gif); }
  33. .flag-en { background-image: url(/static/image/flag/en.gif); }
  34. .flag-tw { background-image: url(/static/image/flag/tw.gif); }
  35. .flag-jp { background-image: url(/static/image/flag/jp.gif); }
  36. .flag-kr { background-image: url(/static/image/flag/kr.gif); }
  37. .flag-de { background-image: url(/static/image/flag/de.gif); }
  38. .flag-fr { background-image: url(/static/image/flag/fr.gif); }
  39. .flag-es { background-image: url(/static/image/flag/es.gif); }
  40. .flag-ru { background-image: url(/static/image/flag/ru.gif); }
  41. .flag-it { background-image: url(/static/image/flag/it.gif); }
  42. .flag-pt { background-image: url(/static/image/flag/pt.gif); }
  43. .flag-br { background-image: url(/static/image/flag/br.gif); }
  44. .flag-in { background-image: url(/static/image/flag/in.gif); }
  45. .flag-sa { background-image: url(/static/image/flag/sa.gif); }
  46. .flag-th { background-image: url(/static/image/flag/th.gif); }
  47. .flag-vn { background-image: url(/static/image/flag/vn.gif); }

  48. /* Default Country Flag */
  49. .flag-default { background-image: url(/static/image/flag/en.gif); }

  50. .i18n-dropdown {
  51.     position: absolute;
  52.     top: 100%;
  53.     right: 0;
  54.     margin-top: 8px;
  55.     min-width: 160px;
  56.     background: #fff;
  57.     border: 1px solid #e1e1e1;
  58.     border-radius: 8px;
  59.     box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  60.     opacity: 0;
  61.     visibility: hidden;
  62.     transform: translateY(-10px);
  63.     transition: all 0.2s;
  64.     z-index: 1000;
  65. }

  66. .header-i18n:hover .i18n-dropdown {
  67.     opacity: 1;
  68.     visibility: visible;
  69.     transform: translateY(0);
  70. }

  71. .poptip-arrow {
  72.     position: absolute;
  73.     top: -6px;
  74.     right: 20px;
  75.     width: 10px;
  76.     height: 10px;
  77.     background: #fff;
  78.     border-left: 1px solid #e1e1e1;
  79.     border-top: 1px solid #e1e1e1;
  80.     transform: rotate(45deg);
  81. }

  82. .i18n-content {
  83.     margin: 0;
  84.     padding: 8px 0;
  85.     list-style: none;
  86. }

  87. .i18n-item {
  88.     margin: 0;
  89.     padding: 0;
  90. }

  91. .i18n-item a {
  92.     display: flex;
  93.     align-items: center;
  94.     gap: 10px;
  95.     padding: 8px 15px;
  96.     color: #333;
  97.     text-decoration: none;
  98.     font-size: 13px;
  99.     transition: background 0.2s;
  100. }

  101. .i18n-item a:hover {
  102.     background: #f5f5f5;
  103. }

  104. .i18n-item.active a {
  105.     color: #ff6600;
  106.     background: #fff5e8;
  107. }

  108. .i18n-item.active .flag-icon {
  109.     box-shadow: 0 0 0 1px #ff6600;
  110. }

  111. .dzicon-arrowdown {
  112.     font-size: 12px;
  113.     margin-left: 5px;
  114. }
  115. </style>

  116. <div class="header-i18n">
  117.     <div class="i18n-icon">
  118.         <div class="current-lang">
  119.             <i class="flag-icon flag-<!--{echo getFlagByLangDir($_G['setting']['i18nCurrent'])}-->"></i>
  120.             <span>{$_G['setting']['i18nLang'][$_G['setting']['i18nCurrent']]}</span>
  121.             <i class="dzicon dzicon-arrowdown">▼</i>
  122.         </div>
  123.     </div>
  124.     <div class="i18n-dropdown poptip-popper">
  125.         <div class="poptip-arrow"></div>
  126.         <ul class="i18n-content">
  127.             <!-- default language -->
  128.             <li class="i18n-item <!--{if $_G['setting']['i18nCurrent'] == 'default'}-->active<!--{/if}-->">
  129.                 <a href="misc.php?mod=i18n&key=default">
  130.                     <i class="flag-icon flag-en"></i>
  131.                     <span>{lang default}</span>
  132.                 </a>
  133.             </li>
  134.             <!-- Load language package list -->
  135.             <!--{loop $_G['setting']['i18nLang'] $_langDir $_langName}-->
  136.             <!--{if $_langDir != 'default'}-->
  137.             <li class="i18n-item <!--{if $_G['setting']['i18nCurrent'] == $_langDir}-->active<!--{/if}-->">
  138.                 <a href="misc.php?mod=i18n&key=$_langDir">
  139.                     <i class="flag-icon flag-<!--{echo getFlagByLangDir($_langDir)}-->"></i>
  140.                     <span>$_langName</span>
  141.                 </a>
  142.             </li>
  143.             <!--{/if}-->
  144.             <!--{/loop}-->
  145.         </ul>
  146.     </div>
  147. </div>

  148. <script>
  149. // Language-Flag map
  150. function getFlagByLangDir(langDir) {
  151.     var flagMap = {
  152.         'default': 'en',
  153. <span style="white-space:pre">                </span>'br' : 'br',
  154.         'en' : 'en',
  155. <span style="white-space:pre">        </span>    'es' : 'es',
  156.         'cn' : 'cn',
  157.         'tc' : 'cn',
  158.         'de' : 'de',
  159.         'fr' : 'fr',
  160.         'ru' : 'ru',
  161.     <span style="white-space:pre">        </span>'in' : 'in',
  162.         'kr' : 'kr',
  163.         'vn' : 'vn'

  164.     };
  165.     return flagMap[langDir] || 'en';
  166. }

  167. document.addEventListener('DOMContentLoaded', function() {
  168.   
  169. });
  170. </script>
  171. <!--{/if}--></div>
Copy Code
3. Don't forget to upload the flag image files: /static/image/flag/





See the result in (brasileiro) : https://demo.discuzstore.com/misc.php?mod=i18n&key=br
Reply

Use Props Report

 Thread Author| Posted on 2026-04-13 11:46:00 | Show all floors
Reply

Use Props Report

You need to log in before you can reply Login | Register

Forum Credit Rules

Close

Editors SelectedPrevious /2 Next

Archiver|Mobile|Darkroom|Privacy|DSC

GMT+7, 2026-04-28 19:43 , Processed in 0.017514 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

Quick Reply Back to Top Return to List