We have learned about content modeling in alfresco in previous few posts. Now after creating the content model there are some times comes a requirement of localizing that content model. What we had seen in previous post is simple content model where all the titles related to aspect, type and properties are in model XML file hard coded in English.
To support localization of a model, you can augment the model XML values with locale-specific values by registering a standard Java resource bundle for each language variant of a model. Localizing content-model values is often required to render user interfaces that are driven from the content model, such as a property sheet that displays a grid of property name and value.
The content models provided out of the box are all augmented with a default (for US English) Java resource bundle. The following is an extract from the resource bundle for the ECM domain model:
cm_contentmodel.description=Alfresco Content Domain Model cm_contentmodel.type.cm_object.title=Object cm_contentmodel.type.cm_object.description=Base Content Domain Object cm_contentmodel.property.cm_name.title=Name cm_contentmodel.property.cm_name.description=Name cm_contentmodel.type.cm_folder.title=Folder cm_contentmodel.type.cm_folder.description=Folder
Resource bundles are composed of many key/value pairs. For content models, the keys are structured as follows:
In our case
- model_prefix is the model namespace prefix.
- model_name is the model name.
- feature is one of type, aspect, property, association, constraint, or data type.
- feature_prefix is the namespace prefix of the feature definition name.
- feature_name is the feature definition name.
Resource bundle Registration
Content model resource bundles must be registered with their associated content model. It can be done by adding following entry in context file. The Dictionary Bootstrap component supports the additional labels property, which allows for a list of resource bundle files (located in the classpath) to be specified. You must restart the Alfresco content repository to register the resource bundle.
<bean id="customModel.extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap"> <property name="labels"> <list> <value>alfresco/extension/customModel.properties</value> </list> </property> </bean>
This is how we can localize any custom content model within alfresco.