COREmanager Documentation

Adding a new language to the control panel

 

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/_msg_.xml file with the following content:

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

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>
Comments

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

killall core

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/_mod_local_msg.xml file.

After the translation is complete, all language messages will be in the  _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;
  • _msg__msg.xml — file with the language description;
  • _mod_local_msg.xml — file with the language description and all translated messages.

You can merge the _msg__msg.xml and _mod_local_msg.xml files. To do this, copy all messages from _mod_local_msg.xml to _msg__msg.xml.

Or rename _mod_local_msg.xml to _msg__msg.xml, but then new edits with Ctrl + Enter will be written to the new file _mod_local_msg.xml.

Comments

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 _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
    Comments
  2. In the new file _msg_sv.xml change to . You will get a file for the Swedish language, which already has all possible control panel messages.
  3. Translate the messages in the file from English to Swedish.
  4. For the changes to take effect, restart the control panel:
    killall core