Creating a Text Provider class

A text provider is used to provide localized text that can be used within web content item forms. For example, a text provider can be used to localize the field labels or help text within an authoring template so that each user sees the labels or help text in their own language.

To use a text provider, you must create a text provider class and then register the text provider by deploying it on the server.
  1. Create a java class that implements the interface com.ibm.workplace.wcm.api.plugin.textprovider.TextProvider . This class must implement the following methods:
    public String getProviderName() {}
    This method returns the unique name of the text provider.
    public String getString(String key, Locale displayLocale) {}
    This method returns some translated text, given a key identifying the message and a locale.
    public Collection<String> getProviderKeys() {}
    This method returns a list of keys used when accessing the text provider. These keys are displayed in the authoring UI when a user is configuring the text provider.
    public boolean isShownInAuthoringUI() {}
    This method allows you to prevent your text provider from appearing in the authoring UI.

    See the Javadoc documentation for further information.

  2. Methods inherited from com.ibm.portal.Localized must also be implemented.
    public String getTitle(Locale displayLocale) {}
    This method returns the title for the text provider that will be used to allow selection of the text provider.
    public ListModel<Locale> getLocales()
    This method returns a list of locales that are supported by this text provider.
    public String getDescription(Locale p_arg0)
    This method returns a description of the text provider.

    See the Javadoc documentation for further information.

  3. A plugin.xml file is needed whether the deployment is done using a WAR or EAR, or using a loose jar. If deploying via an application in a WAR or EAR, include the plugin.xml file in the application's "WEB-INF" folder. When using a jar, include the plugin.xml in the root of the jar.
    <?xml version="1.0" encoding="UTF-8"?>
    <plugin id="com.acme"
           name="Sample Text Provider"
           version="1.0.0"
           provider-name="IBM">
           
     <extension
        point="com.ibm.workplace.wcm.api.TextProvider"
        id="SampleTextProvider">
        <provider class="com.acme.SampleTextprovider"/>
     </extension>
    
    </plugin>
Naming conventions:
If you create a new plugin application with the same names and IDs as an existing plugin, the new plugin may override the first. When creating plugin applications ensure that the following are unique across your system:
  • The plugin ID, plugin name and extension ID of the plugin.xml file.
  • The fully qualified class name plus path of all classes within the application.
  • The file path of any files within the application.