This chapter describes how to enable translation of Community-Gadgets functionality into multiple languages.
This chapter contains the following sections:
The Community-Gadgets user interface can be translated, by default, into the following languages: English, French, German, Italian, Japanese, Korean, Portuguese, Spanish, Simplified Chinese, and Traditional Chinese. Moreover, you can also customize existing labels and translations to new languages on demand.
The language pack is located in the file system of the Community-Gadgets web application at cg.war/WEB-INF/classes/i18n_resources
.
The i18n_resources
directory contains two subfolders, server
and widgets
that include resources for the Community-Gadgets interface and for client-side widgets respectively.
The server
directory contains a list of Java property resource bundles that are separated on the basis of the Community application sub-system. It contains localizations for the following sub-systems: core
, cos-resources
, gadgets, gadgets-exception, service
, shared
, and users
.
The widgets
directory contains a list of folders in which each folder corresponds to a particular widget. For example, the wsdk.comments
folder corresponds to the Comments widget and the wsdk.reviews
folder to the Reviews widget.
The cos.commons
directory contains resources that are shared across all the widgets.The logic of picking up a required language is different in the Community interface and in the widgets deployed on a web site. The following sections discuss both types of logic in order of priority.
If a language is customized in the Web Experience Management (WEM) profile for the logged-in business user, apply it. If not, then proceed to the next step.
If the locale of the browser is supported, apply this setting. If not, proceed to the next step.
Apply the default English
locale.
Language detection logic described in this section applies to all Community-Gadgets end side widgets.
The following first and second steps are based on the premise that the web site may already have some language selection mechanism to display site content in different languages. For example, most sites have a language icon on the top or bottom of a site page for this purpose. If this mechanism uses cookies or JavaScript variables for language selection, then the Community widgets can also use them after client's consent.Site developers customize the language selection mechanism by enabling the creation of the cos_language
cookie or the JavaScript variable with a language value. Once this is done, the Community widgets can use the client's language selection mechanism to display site content in different languages.
Use the language parameter given in a cos_language
cookie that site developers specify manually.
If no cookie is set, proceed to the next step.
Use the language parameter of a global JavaScript variable, cos_language
that site developers or integrators can specify manually.
If no variable is set, proceed to the next step.
Use the default language setting chosen by the administrator via the Community interface by selecting Settings then Language (Figure 82-2).
This setting applies to all types of widgets deployed on the site.
Figure 82-2 Language Setting in Community-Gadgets
To add a new language, complete the following steps:
List the new language in the Community-Gadgets configuration (see Section 82.3, "Registering the New Language in Community-Gadgets"), so that it displays in the default language selector in the Community interface.
Upload translations for all the resources located in cg.war/WEB-INF/classes/i18n_resources
/<subfolders containing translation files>
. That is, translate all *_en.properties
files located in this directory and copy back the translated files (for example, for Russian language the file is *_ru.properties
).
To register a new language in the Community-Gadgets configuration:
Navigate to the cg.war/WEB-INF/lib
directory.
Open the cos-shared-11.1.1.8.0.jar
file, then extract the cos_core_metadata.xml
file.
Search for the schema::cos::commons:permissions:language
string. The declaration is as follows:
<bean id="language" class="com.fatwire.cos.metadata.core.model.MetadataDescriptorImpl"> <property name="uid" value="schema::cos::commons:permissions:language"/> <property name="name" value="label.language"/> <property name="defaultValue" value="en_US"/> <property name="dataOptionsValue" value="[ { name: 'label.language.english', value:'en_US'}, { name: 'label.language.brazilian_portuguese', value:'pt_BR'}, { name: 'label.language.chinese_simplified', value:'zh_CN'}, { name: 'label.language.chinese_traditional', value:'zh_TW'}, { name: 'label.language.french', value:'fr'}, { name: 'label.language.german', value:'de'}, { name: 'label.language.italian', value:'it'}, { name: 'label.language.japanese', value:'ja'}, { name: 'label.language.korean', value:'ko'}, { name: 'label.language.spanish', value:'es'}, <ADD COMMA AND INSERT NEW LANGUAGE HERE> ]"/> … </bean>
To the dataOptionsValue
property, add a new JSON object for the new language. For example, for Russian, the entry can be the following:
{ name: 'label.language.russian', value:'ru'}
If the entry for Russian is added, the property value will be:
<property name="dataOptionsValue" value="[ { name: 'label.language.english', value:'en_US'}, { name: 'label.language.brazilian_portuguese', value:'pt_BR'}, { name: 'label.language.chinese_simplified', value:'zh_CN'}, { name: 'label.language.chinese_traditional', value:'zh_TW'}, { name: 'label.language.french', value:'fr'}, { name: 'label.language.german', value:'de'}, { name: 'label.language.italian', value:'it'}, { name: 'label.language.japanese', value:'ja'}, { name: 'label.language.korean', value:'ko'}, { name: 'label.language.spanish', value:'es'} { name: 'label.language.russian', value:'ru_RU'} ]"/>
Save the cos_core_metadata.xml
file and include this revised file in the cos-shared-11.1.1.8.0.jar
file.
Navigate to the i18n_resources/server/cos-resources_<LANG>.properties
resource bundle, then add the label.langauge.russian
key with value translation for each supported language.
Each of the cos-resources
files (cos-resources.properties
, cos-resources_de.properties
, cos-resources_es.properties
, cos-resources_fr.properties
, cos-resources_it.properties
, and so on) contains a set of language labels. The following is an example for cos-resources_en.properties
:
label.language.english = English label.language.brazilian_portuguese = Brazilian Portuguese label.language.chinese_simplified = Simplified Chinese label.language.chinese_traditional = Traditional Chinese label.language.french = French label.language.german = German label.language.italian = Italian label.language.japanese = Japanese label.language.korean = Korean label.language.spanish = Spanish
Add a new line containing the parameter name (for example, label.langauge.russian
) and the parameter value (for example, Russian for cos-resources_en.properties
):
label.langauge.russian=Russian
The cos-resources_en.properties
value for label.langauge.russian
is different (Russische
in cos-resources_de.properties
or Russe
in cos-resources_fr.properties
).
Therefore,
label.langauge.<lang_id>=<value_translation>
For all resource bundles that can be found recursively in the i18n_resources
directory, upload translation files in the same folder with the corresponding language suffix. For example, in the directory named i18n_resources/server/users.properties
you can find a Russian translation for the English pack. So, upload the translation file for Russian: users_ru_RU.properties
in the i18n_resources/server/
directory.
Restart the application server for the Community management application.
To verify that the new language is displayed, log in to Community as an administrator, then choose Language from the Settings menu.