close

Filter

loading table of contents...

Studio Developer Manual / Version 2107

Table Of Contents

5.6 Localization

Creating Resource Bundles

Text properties in CoreMedia Studio can be localized. English and German are supported out of the box; you can add your own localization bundles if required. To do so, proceed as follows:

  1. Add the new locale to the studio.locales property in your Studio application's application.properties file.

    This property contains a comma-separated list of locales. The first element in the list is en and specifies the locale of values in the default properties files (that is, the files without a locale suffix). Therefore, you must not change this first entry; it must always remain en (see below).

  2. Add properties files that follow the naming scheme for your added locale, as explained below.

Localized texts are stored in properties files according to the Java properties file syntax. The naming scheme of these files is:

<FileName>_<IsoLanguageCode>.properties

Caution

Caution

Jangaroo 4 expects *.properties files to be encoded with UTF-8, same as Flex does it (unlike java properties files that use ISO-8859-1). Take care to set the correct encoding in IDEA settings. To be on the safe side you can escape non-ASCII characters (for example, \u00F0 etc.).

A properties file with no language code contains properties in the default language English. Note that English is only a technical default. The default locale used for users opening CoreMedia Studio for the first time is determined by the best match between their browser language settings and all supported locales.

When properties are missing in a locale-specific properties file or the complete properties file is missing, the values of the properties are inherited from the default language (that is, they will appear in English rather than in the locale the user has set).

Properties files are placed beside ActionScript and MXML files in the proper package below the src/main/joo directory.

Accessing Resource Bundles

Accessing resource bundles is done via the ResourceManager. You must first specify metadata that defines the resource bundles for your application. The syntax for this metadata in MXML is as follows:

<fx:Metadata>
  [ResourceBundle('com.acme.My')]
  [ResourceBundle('com.acme.SomeOtherBundle')]
</fx:Metadata>

In an ActionScript class, you apply the metadata annotation above the class name, as the following example shows:

[ResourceBundle('com.acme.My')]
[ResourceBundle('com.acme.SomeOtherBundle')]
public class MyComponent extends Component {
    ...
}

Now you can use the declared resource bundles in ActionScript and MXML by calling the methods of the ResourceManager, such as getString().

<Panel ...
    title="{resourceManager.getString('com.acme.My', 'someProperty')}"
    ...>
  <fx:Metadata>
    [ResourceBundle('com.acme.My')]
    [ResourceBundle('com.acme.SomeOtherBundle')]
  </fx:Metadata>

  ...

  <TextField fieldLabel="{resourceManager.getString('com.acme.My', 'fieldLabelProperty')}"
             emptyText="{resourceManager.getString('com.acme.SomeOtherBundle', 'emptyTextProperty')}"
             ... />
</Panel>

The ResourceManager can be accessed via the property resourceManager (lower case) that is added to the ext.Component class by the Jangaroo Compiler. This property references the global singleton of type mx.resources.IResourceManager. If you are not subclassing an ext.Component you can access this singleton directly by calling mx.resources.ResourceManager.getInstance().

Overriding existing properties

If you want to change predefined labels, tooltips or similar, you can override properties from existing properties files. To this end, you should first define a new properties file and then call the static method ResourceBundle#overrideProperties(destination, source) This method will never remove a property key, it will only update existing values.

To overwrite properties in your own Studio Plugin you can use the com.coremedia.cms.editor.configuration.CopyResourceBundleProperties Plugin, which internally calls ResourceBundle#overrideProperties(destination,source).

<editor:CopyResourceBundleProperties
    destination="{mx.resources.ResourceManager.getInstance().getResourceBundle(null, 'com.acme.My')}"
    source="{mx.resources.ResourceManager.getInstance().getResourceBundle(null, 'com.acme.MyPlugin')}"/>

Generally, each Studio plugin module will contain at least one set of properties files for localizing its own components or for adapting existing properties files.

For details on UI localization through properties files see Section 7.2, “Localizing Labels”.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.