Internationalization
2 minute read
CMP ships with English only. Translating it consists of generating message files from the strings marked in the product, translating those files, compiling them, and then telling CMP which language to serve. This is carried out on the appliance, and the files are stored in the proserv directory where they will not be overwritten during an upgrade.
Generate the message files
Run these commands on the appliance. Replace fr with your target language code from the ISO 639-1 list.
sudo su -
cd /opt/cloudbolt
mkdir locale
./manage.py makemessages -l fr --keyword=_lazy
Include --keyword=_lazy, as CMP marks most of its interface text with _lazy. Without that keyword, those strings are omitted, producing a catalog with missing translations.
Text rendered by JavaScript lives in another catalog. Generate it to translate those strings:
./manage.py makemessages -d djangojs -l fr -i node_modules -i docs
Copy the locale directory into proserv:
cp -R locale/ /var/opt/cloudbolt/proserv/
Translate the files
Edit django.po and djangojs.po in the language directory you created in proserv. Each entry pairs the English string with an empty translation:
msgid "Edit this blueprint item"
msgstr ""
Fill in msgstr for each msgid. An empty entry falls back to English.
Before compiling, check the Plural-Forms line in the file header. If it still reads nplurals=INTEGER; plural=EXPRESSION;, the placeholder that the generator writes, replace it with a real rule such as nplurals=2; plural=(n != 1);. Leaving the placeholder in causes an error once you switch languages.
Compile and switch language
-
Compile the files:
/opt/cloudbolt/manage.py compilemessages -
Add the language code to
/var/opt/cloudbolt/proserv/customer_settings.py. Use the lowercase form, such asLANGUAGE_CODE = "fr"orLANGUAGE_CODE = "pt-br". -
Restart Apache:
systemctl restart httpd.
If the interface is still in English, check for a catalog generated without --keyword=_lazy, files compiled outside proserv, or a language code that does not match the directory name. The directory uses an underscore, as in pt_BR, while the setting uses lowercase and a hyphen, as in pt-br.
What the catalogs do not cover
Message files translate the text built into the product. They do not touch objects such as parameters, actions, roles, blueprints, and groups. Those carry their own labels and descriptions, so translate them by editing each object in the UI.
Related
- Branded portals: Changing the product name, logos, and colors that users see.
- Using HTML in descriptions: Formatting the description text on your objects.