<fx:Metadata>
[ResourceBundle('my.package.BundleName')]
..
</fx:Metadata>
Localizing Labels - CMCC 10
Maybe you are already familiar with localizing labels of document types and property names in Studio. But there are many other labels besides these two that can be localized as well. Find out more about this feature during your Studio customization process.
This guide applies to CMCC 10
This how-to guide has yet to be updated for the most recent product release. Some of the elements in this guide might not work as described, if you are on the latest version.
Thank you for your patience!
What you'll learn
- Adding new resource bundles
- Overriding standard Studio labels
Prerequisites
- A Blueprint workspace
Time matters
Should I read this?
Localizing Labels
In general, you can localize all labels in CoreMedia Studio. Typical cases are document type names and document property names but also labels or button texts, error messages or window titles. The localized texts are stored in properties files. To use these property values, classes are generated by the MXML compiler following the singleton pattern. Property classes can be adapted as described in the Studio Developer Manual typically overriding the existing value with values from a new customizing property class.
Predefined property classes of CoreMedia Studio
The following classes are predefined property classes defining labels and messages used throughout CoreMedia Studio.
-
Actions_properties
-
DeviceTypes_properties
-
Editor_properties
-
EditorErrors_properties
-
Publisher_properties
-
Validators_properties
See the ActionScript documentation for a list of defined properties.
Predefined properties files of Blueprint Studio
The blueprint-forms Studio plugin contains several properties files with localization entries in the studio/blueprint-forms/src/main/joo/com/coremedia/blueprint/studio
directory. These files are used for to localize several features of Studio, for example tab titles, document type names or validator messages.
You can simply change the value of any of the properties as needed. While you can also add new properties to these files when building extensions of CoreMedia Studio, it is preferable to put new localization keys into new properties files.
Adding a new resource bundle
If you want to add a new properties file which contains your own localization keys, proceed as follows:
-
Create a directory corresponding to the desired package of your resource bundle, for example
<ModuleName>/src/main/joo/<PackagePath>
. -
Create new properties files following the naming scheme:
<PropertyFileName>.properties
and<PropertyFileName>_de.properties
. -
Add one or more keys and values in the format
<KeyName>=<PropertyValue>
-
Optionally, add the same key to each locale-specific properties file, using an appropriate translation. By default, there is only one translation (German), but you can add your own.
-
In an MXML file describing your custom component, import the resource bundle in the metadata section:
-
Address the resource bundle and key in the text attribute of the component where you want to use the label:
ResourceManager.getInstance().getString('my.package.BundleName',<KEY_NAME>)
. You will get code completion in a properly configured IDE for the keys of your resource bundle. -
Instead of using the
ResourceManager.getInstance()
singleton, you can reference theresourceManager
object that is available for every component instance.
Example: Adding a Search Button
To introduce a new localized button to the Favorites toolbar you could add the following component to the file BlueprintFormsStudioPlugin.mxml
for the component FavoritesToolbar
.
<editor:FavoritesToolbar>
<editor:plugins>
<ui:AddItemsPlugin>
<ui:items>
<Button itemId="exampleButton">
<baseAction>
<editor:ShowCollectionViewAction published="false"
editedByMe="true"
contentType="CMArticle"
text="{ResourceManager.getInstance().getString(
'com....BlueprintStudio_properties',
'doc_example_txt')}"/>
</baseAction>
</Button>
</ui:items>
<ui:after>
<Button itemId="{FavoritesToolbar.NEW_MENU_BUTTON_ITEM_ID}"/>
</ui:after>
</ui:AddItemsPlugin>
</editor:plugins>
</editor:FavoritesToolbar>
The attribute text
of the editor:ShowCollectionView
element defines the text to be displayed in the Studio web application.
In order to have the label you want, you need to add it to the properties file. The BlueprintStudio.properties
file starts like this after adding a string for the label:
doc_example_txt=My Example Button
SpacerTitle_navigation=Navigation
SpacerTitle_versions=Versions
SpacerTitle_layout=Layout
...
Override Standard Studio Labels
It is also possible to override the standard Studio labels, like so:
-
Create a properties file with all labels you want to override, for example,
CustomLabels.properties
andCustomLabels_de.properties
. -
Search for the key of the property that should be changed. All the keys are documented in the ActionScript API, such as
Action_withdraw_tooltip
in the resource bundle classActions_properties
. -
In your
CustomLabels
bundle, set the new value for the key. -
In the
configuration
section of your Studio plugin, override theActions_properties
bundle with the following code:
//override the standard studio labels with custom properties
<editor:CopyResourceBundleProperties destination="{ResourceManager.getInstance().getResourceBundle(null, 'com.coremedia.cms.editor.sdk.actions.Actions')}"
source="{ResourceManager.getInstance().getResourceBundle(null, 'com.coremedia.blueprint.studio.CustomLabels')}"/>
This can be done with every property of Studio. An example can also be found in file the BlueprintFormsStudioPlugin.mxml
.