About localization#
Overview#
Casa supports multilingual support through resource bundles. Administrators supply bundles as plaintext files ending with the .properties
file extension.
By default, Casa contains three bundles, each in a separate file. These bundles contain the internationalization labels in the English language, as displayed in a default Casa installation. For example, to add support for French, you would have to create the following files:
File | Description |
---|---|
user_fr.properties |
Contains labels mostly found in user-facing pages |
admin_fr.properties |
Contains labels mostly found in administrator-facing pages |
general_fr.properties |
Contains labels found widely across the app and plugins |
Adding internationalization labels#
To supply labels in a particular language (or even if you want to override the English translation provided), do the following:
- Log in to the Chroot
- Extract the Casa default labels:
/opt/jre/bin/jar -xf /opt/gluu/jetty/casa/webapps/casa.war WEB-INF/classes/labels
- Run
cp WEB-INF/classes/labels/*.properties .
and delete WEB-INF dir:rm -R WEB-INF/
- Add the appropriate suffix to the properties files found in the current directory, ie.
_de
for German,_es
for Spanish,_ja
for Japanese, etc. - Edit the contents of files accordingly. Use UTF-8 encoding for opening and saving
cd
to/opt/gluu/jetty/casa/static
- Create directory
i18n
if it does not exist:mkdir i18n
- Transfer the properties files to the
i18n
folder - Ensure
jetty
user has permission for reading the files - Restart casa
Log in to the application and review your work. Make necessary edits and repeat the process.
How are labels picked?#
In Casa, the rule for displaying contents is leveraged from the underlying framework. In short, the locale to use per session is picked based on the end-user browser settings.
As an example, if the browser was configured to use U.S. English, the locale will be en_US
. This means that files ending in _en_US.properties
will be considered first. Then, the country suffix is removed and thus _en.properties
is looked up. Finally the non-suffixed ones are considered, that is, the default label files bundled with Casa.
Additionally, end users can pick the language of their preference by selecting a language item from the dropdown list appearing at the bottom of any Casa page. The list is only shown if there are two or more languages available to display.
Localization in plugins#
Plugins also support localization through the "zk-label" bundle. Check here for more information. This is useful for plugins developed by your organization. If you have installed plugins developed by Gluu, they will only contain a single default English file.
To add your own translation for plugin texts, proceed as follows:
cd
to the folder where you stored the jar file of the plugin of interest. This file was delivered to you by Gluu staff directly.- Extract the plugin's default labels (requires Java bin on your path):
jar -xf JAR_FILE labels/zk-label.properties
cd
tolabels
folder- Add the appropriate suffix to the properties file, ie.
_de
for German,_es
for Spanish,_ja
for Japanese, etc. - Edit the contents accordingly. Use UTF-8 encoding for opening and saving
- Connect to your Gluu Casa Server/VM and log into chroot
cd
to/opt/gluu/jetty/casa/static
- Create directory
i18n
if it does not exist:mkdir i18n
- Transfer the properties file to the
i18n
folder - Ensure
jetty
user has permission for reading - Restart casa
Note
Since most Gluu Inc. plugins have a zk-label.properties
, you can accumulate all plugin texts into a single file, or you can use a different filename for each plugin.
Properties file syntax#
Administrators acquainted with the format used for properties files in Java will find Casa resource bundle files familiar. The format used in Casa differs slightly, but it is more powerful. To learn more about this topic, visit this page.
Tips#
-
Not all entries present in default label files have to be translated in your own localized versions. If you are comfortable with the current text for a particular entry, you can simply remove it to use the one in the default files.
-
There is no need to supply specific translations for countries. While supported, most of time it suffices to create files suffixed with the language code, for instance
_es
, and not with country code (e.g_es_CO
,_es_AR
,_es_EC
,_es_ES
, etc.) -
Actual filenames for properties files are not relevant. Upon start, Casa will parse all properties files present in
i18n
folder.