5.3.2.4.4. Registering localized resources with ResourceBundle service

In this example, you have a resource file, that is ViewSource_en.properties. The _en suffix means English. You can write many resources for other languages.

  1. Edit the ViewSource_en.properties file as below:

    MoreExtensionContainer.action.ViewSource=View Source

    This indicates that the label of your action will be View Source.

    Name of the MoreExtensionContainer.action.ViewSource property must be changed if you use another type. It is dependent on the gtmpl file you use in your Java class. See this code in wiki.war!/templates/wiki/webui/control/action/AbstractActionComponent.gtmpl:

    String labelName = _ctx.appRes(uicomponent.getParent().getName() + ".action." + actionName);
  2. Configure the ResourceBundle service in the configuration.xml file as below:

    
    <external-component-plugins>
        <target-component>org.exoplatform.services.resources.ResourceBundleService</target-component>
        <component-plugin>
            <name>UI Extension</name>
            <set-method>addResourceBundle</set-method>
            <type>org.exoplatform.services.resources.impl.BaseResourceBundlePlugin</type>
            <init-params>
                <values-param>
                    <name>init.resources</name>
                    <value>locale.com.acme.ViewSource</value>
                </values-param>
                <values-param>
                    <name>portal.resource.names</name>
                    <value>locale.com.acme.ViewSource</value>
                </values-param>
            </init-params>
        </component-plugin>
    </external-component-plugins>

    Pay attention to the resource name: locale.com.acme.ViewSource. It is a translation of the locale/com/acme/ViewSource_en.properties file path (relative to the Jar archive), with the _en suffix and the .properties extension is eliminated.

    See here for the ResourceBundle configuration.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus