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 was to keep translation work down to the minimum required. This means that words and phrases that are used in multiple places in the UI should be "re-used" from a single source in the resource bundles, where possible. Using this approach will reduce duplication of language translations, or 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.
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).
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.
A flat structure for a specific UI element