51黑料不打烊

Supporting new locales for adaptive forms localization

Version
Article link
AEM as a Cloud Service
AEM 6.5
This article

About locale dictionaries

The localization of adaptive forms relies on two types of locale dictionaries:

Form-specific dictionary Contains strings used in adaptive forms. For example, labels, field names, error messages, help descriptions, and so on. It is managed as a set of XLIFF files for each locale and you can access it at https://<host>:<port>/libs/cq/i18n/translator.html.

Global dictionaries There are two global dictionaries, managed as JSON objects, in AEM client library. These dictionaries contain default error messages, month names, currency symbols, date and time patterns, and so on. You can find these dictionaries in CRXDe Lite at /libs/fd/xfaforms/clientlibs/I18N. These locations contains separate folders for each locale. Because global dictionaries are usually not updated frequently, keeping separate JavaScript files for each locale enables browsers to cache them and reduce network bandwidth usage when accessing different adaptive forms on same server.

How localization of adaptive form works

There are two methods to identify the locale of the adaptive form. When an adaptive form is rendered, it identifies the requested locale by :

  • looking at the [local] selector in the adaptive form URL. The format of the URL is http://host:port/content/forms/af/[afName].[locale].html?wcmmode=disabled. Using [local] selector allows caching an adaptive form.

  • looking at the following parameters in the specified order:

    • Request parameter afAcceptLang
      To override the browser locale of users, you can pass the afAcceptLang request parameter to force the locale. For example, the following URL forced to render the form in Japanese locale:
      https://'[server]:[port]'/<contextPath>/<formFolder>/<formName>.html?wcmmode=disabled&afAcceptLang=ja

    • The browser locale set for the user, which is specified in the request using the Accept-Language header.

    • Language setting of the user specified in AEM.

    • Browser locale is enabled, by default. To change browser locale setting,

      • Open the configuration manager. The URL is http://[server]:[port]/system/console/configMgr
      • Locate and open the Adaptive Form and Interactive Communication Web Channel configuration.
      • Change status of the Use Browser Locale option and Save the configuration.

Once the locale is identified, the adaptive forms picks the form-specific dictionary. If the form-specific dictionary for the requested locale is not found, it uses the dictionary for language in which adaptive form was authored.

If no locale information is present, adaptive form is delivered in the original language of the form. The original language is the language used while developing the adaptive form.

If a client library for the requested locale does not exist, it checks for a client library for the language code present in the locale. For example, if the requested locale is en_ZA (South African English) and the client library for en_ZA does not exist, the adaptive form will use the client library for en (English) language, if it exists. However, if none of them exist, the adaptive form uses the dictionary for en locale.