Many labels besides document types and property names can also be localized. Typical cases are labels or button texts, error messages or window titles. The localized texts are stored in property files. To use these property values, classes are generated by the EXML compiler following the singleton pattern. Property classes can be adapted as described in Section 5.7, “Localization”, 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
Editor_properties
EditorErrors_properties
Publisher_properties
Validators_properties
See the ActionScript documentation for a list of defined properties.
Predefined property files of Blueprint Studio
The CoreMedia Studio Blueprint plugin contains two property files
with localization entries in the
studio/blueprint-components/src/main/joo/com/coremedia/cms/studio/blueprint
directory: BlueprintStudio.properties
and
BlueprintStudio_de.properties
. These files are used for custom search buttons in
the favorites toolbar and for other labels that are not content type specific.
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 property files.
Adding a new resource bundle
If you want to add a new property file to contain your own localization key, 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 schema:
<PropertyFileName>.properties
and<PropertyFileName>_de.properties
.Add one or more keys and values, like so:
<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 EXML file describing your custom component, import the resource bundle, using its fully qualified class name:
<exml:import class="<FullyQualifiedName>_properties"/>
Address the resource bundle and key in the text attribute of the component where you want to use the label:
{<FileName>_properties.INSTANCE.<KeyName>}
. You will get code completion in a properly configured IDE once the properties bundle was compiled.Alternatively, reference the
INSTANCE
object from an ActionScript class.
Example: Adding a search button
In order to introduce a new localized button to the favorites toolbar you could add the
following component to the file BlueprintFavoritesToolbarButtons.exml
:
<button itemId="exampleButton"> <baseAction> <editor:showCollectionViewAction text="{BlueprintStudio_properties.INSTANCE.doc_example_txt}" published="false" editedByMe="true" contentType="CMArticle"/> </baseAction> </button>
Example 7.9. Adding a search button
The attribute text
of the editor:ShowCollectionView
Element defines
the text to be displayed in the Studio web application. On the top of the file
BlueprintFavoritesToolbarButtons.exml
you will see the following line:
<exml:import class="com.coremedia.cms.studio. \ blueprint.BlueprintStudio_properties"/>
This line imports the BlueprintStudio.properties
file into the scope. Of course,
you could also import your own file.
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 ...
Example 7.10. Example property file
Override Standard Studio Labels
It is also possible to override the standard Studio labels, like so:
Create a property 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
init()
method of theEditorPlugin
, override theActions_properties
bundle with the following code:
//override the standard studio labels with custom properties ResourceBundle.overrideProperties(Actions_properties, CustomLabels_properties);
Example 7.11. Overriding properties
This can be done with every property of Studio. An example can also
be found in the BlueprintStudioPlugin
.