The Web UI has a mechanism in place to allow "user-facing" text to be localized to different languages.
At its heart, the mechanism uses Java Resource Bundles backed by properties files (see Java Tutorial) to provide each text snippet with a "key" that is used for lookup of the text in the language of the configured Locale.
A primary goal of the implementation is to keep translation work down to a minimum. This means that words and phrases used in multiple places in the UI should be "re-used" from a single source in the resource bundles, where possible. Using this approach reduces duplication of language translations, and prevents subtly different translations for the same phrase in different places.
Resource Bundle Collection
The resource bundles are maintained in the onos web_gui module, under the ~/src/main/resources tree, in the org/onosproject/ui/lion directory.
A "top level" directory -- core -- contains three directories:
- common – for bundles of words and phrases that will appear in many places in the UI
- fw - for bundles relating to text appearing in "UI framework" code
- view - for bundles relating to specific "UI views" code
It is expected that a second top level directory – apps -- will be created in the future, for bundles relating to the ONOS Apps that are included in the distribution.
Note in the image above that the "Resource Bundle 'X'" elements are synthetic containers created by IntelliJ (IDE) to group together bundles of the same text in the different languages.
Looking at the (expanded) 'Action' bundle, it can be seen that there is a default bundle (Action.properties) which has text in English, along with translations into Spanish (es), Italian (it), Korean (ko), Traditional Chinese (zh_CN) and Taiwanese (zh_TW).
In the IDE, selecting the actual file will allow the developer to edit the text of the file, as you would expect:
However, selecting the "bundle" provides an edit mode where each localization key can be selected to display all translations for that specific key:
A flat structure for a specific UI element