This article describes how to add a new language to the control panel. Swedish is taken as an example.

How to add a language to the panel


To make a new language appear in the language selection field, create the /usr/local/mgr5/etc/xml/<mgrname>_msg_<sv>.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
<lang name="sv">
</lang>
</mgrdata>
CODE
Comments

<mgrname> — abbreviated name of the control panel. The file <mgrname>_msg_sv.xml should be named according to the name of the panel, that is, the BILLmanager file will be named billmgr_msg_<language>.xml, and the VMmanager file will be named vmmgr_msg_<language>.xml, etc.

Abbreviated names of control panels:

  • ispmgr — ISPmanager;
  • billmgr — BILLmanager;
  • vmmgr — VMmanager KVM or Cloud;
  • vemgr — VMmanager OVZ;
  • dcimgr — DCImanager;
  • ipmgr — IPmanager;
  • dnsmgr — DNSmanager.

<sv> — language code. Use an arbitrary value.

To display the language name in the control panel, create the  /usr/local/mgr5/etc/xml/core_mod_sv.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
<lang name="en">
       <messages name="label_langs">
       <msg name="sv">Svenska</msg>
       </messages>
</lang>
</mgrdata>
CODE
Comments

Svenska — language name.

sv — language code. Use the value you specified in the <mgrname>_msg_<sv>.xml file.

After both files have been added, restart the command control panel:

killall core
CODE

In the panel, you will be able to select the Swedish language on the authorization page or on the page for changing the user's language.

How to translate the panel interface


Once the new language is added, you can translate the control panel interface into that language. There are two methods to translate:

Method 1

  1. In the control panel, switch to the new language. This can be done on the authorization page or in the user settings. Since you have not yet added new messages for this language, the entire interface will be in the default language.
  2. Select any text for translation in the panel and press Ctrl + Enter. A window will open in which you need to enter the translation.
  3. After you enter a new message and save the changes, the interface will immediately change to the new message.

All changes you make with Ctrl + Enter will be saved in the/usr/local/mgr5/etc/xml/<mgrname>_mod_local_msg.xml file.

After the translation is complete, all language messages will be in the  <mgrname>_mod_local_msg.xml file.

In total, you will have three language files:

  • core_mod_sv.xml — contains the language name. The file is needed so that the language selection list displays the name of the language, not its short designation;
  • <mgrname>_msg_<sv>_msg.xml — file with the language description;
  • <mgrname>_mod_local_msg.xml — file with the language description and all translated messages.

You can merge the <mgrname>_msg_<sv>_msg.xml and <mgrname>_mod_local_msg.xml files. To do this, copy all messages from <mgrname>_mod_local_msg.xml to <mgrname>_msg_<sv>_msg.xml.

Or rename <mgrname>_mod_local_msg.xml to <mgrname>_msg_<sv>_msg.xml, but then new edits with Ctrl + Enter will be written to the new file <mgrname>_mod_local_msg.xml.

Comments

<mgrname> — abbreviated name of the control panel.

<sv> — language code. Use an arbitrary value.

Method 2

The first method allows you to translate directly from the panel interface, but it is not always convenient, and not all messages can be translated this way. In this case, you can use the second method.

  1. Take the English message file <mgrname>_msg_en.xml as a base and copy it:

    cp /usr/local/mgr5/etc/xml/<mgrname>_msg_en.xml /usr/local/mgr5/etc/xml/<mgrname>_msg_<sv>.xml
    CODE
    Comments

    <mgrname> — abbreviated name of the control panel. Possible values:

      • ispmgr — ISPmanager;
      • billmgr — BILLmanager;
      • vmmgr — VMmanager KVM or Cloud;
      • vemgr — VMmanager OVZ;
      • dcimgr — DCImanager;
      • ipmgr — IPmanager;
      • dnsmgr — DNSmanager.

    <sv> — language code. Use an arbitrary value.

    • In the new file <ispmgr>_msg_sv.xml change <lang name="en"> to <lang name="sv">. You will get a file for the Swedish language, which already has all possible control panel messages.
    • Translate the messages in the file from English to Swedish.
    • For the changes to take effect, restart the control panel:

      killall core
      CODE