AEM Forms provide out of the box support for English (en), Spanish (es), French (fr), Italian (it), German (de), Japanese (ja), Portuguese-Brazilian (pt-BR), Chinese (zh-CN), Chinese-Taiwan (zh-TW), and Korean (ko-KR) locales. You can add support for more locales also, like Hindi(hi_IN).
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. It is managed as a set of XLIFF files for each locale and you can access it at [author-instance]/libs/cq/i18n/gui/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 at [author-instance]/libs/fd/xfaforms/clientlibs/I18N
. These locations contain separate folders for each locale. Because global dictionaries are 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.
Perform the following to steps add support for a new locale:
AEM Forms currently support localization of Adaptive Forms content in English (en), Spanish (es), French (fr), Italian (it), German (de), Japanese (ja), Portuguese-Brazilian (pt-BR), Chinese (zh-CN), Chinese-Taiwan (zh-TW), and Korean (ko-KR) locales.
To add support for a new locale at Adaptive Forms runtime:
git clone https://git.cloudmanager.adobe.com/<my-org>/<my-program>/
.Locate the Guide Localization Service.cfg.json
file and add the locale you want to add to the list of supported locales.
Create a file with the name as Guide Localization Service.cfg.json
file, if already not present.
etc/clientlibs
folder.locale-name
under etc/clientlibs
to serve as a container for xfa and af clientlibs.Create a node named as [locale-name]_xfa
and type as cq:ClientLibraryFolder
under etc/clientlibs/locale_name
, with category xfaforms.I18N.<locale>
, and add the following files:
xfalib.locale.Strings
for the <locale>
as defined in /etc/clientlibs/fd/xfaforms/I18N/ja/I18N
.Create a node named as [locale-name]_af
and type as cq:ClientLibraryFolder
under etc/clientlibs/locale_name
, with category as guides.I18N.<locale>
and dependencies as xfaforms.3rdparty
, xfaforms.I18N.<locale>
and guide.common
.
Create a folder named as javascript
and add the following files:
guidelib.i18n
, having patterns of “calendarSymbols”, datePatterns
, timePatterns
, dateTimeSymbols
, numberPatterns
, numberSymbols
, currencySymbols
, typefaces
for the <locale>
as per the XFA specifications described in Locale Set Specification.guidelib.i18n.strings
and guidelib.i18n.LogMessages
for the <locale>
as defined in /etc/clientlibs/fd/af/I18N/fr/javascript/LogMessages.js
.Add js.txt containing the following:
i18n.js
LogMessages.js
Perform this step only if the <locale>
you are adding is not among en
, de
, es
, fr
, it
, pt-br
, zh-cn
, zh-tw
, ja
, ko-kr
.
Create a folder languages
under etc
, if not present already.
Add a multi-valued string property languages
to the node, if not present already.
Add the <locale-name>
default locale values de
, es
, fr
, it
, pt-br
, zh-cn
, zh-tw
, ja
, ko-kr
, if not present already.
Add the <locale>
to the values of the languages
property of /etc/languages
.
Add the newly created folders in the filter.xml
under etc/META-INF/[folder hierarchy] as:
<filter root="/etc/clientlibs/[locale-name]"/>
<filter root="/etc/languages"/>
Before committing the changes into the AEM Git repository, you need to access your Git repository information.
Commit the changes to the GIT repository after adding a new locale support. Deploy your code using the full stack pipeline. Learn how to set up a pipeline to add new locale support.
Once the pipeline is complete, the newly added locale appears in the AEM environment.
Perform the following steps to use and render an Adaptive Form using a newly added locale:
&afAcceptLang=<locale-name>
in the URL of an Adaptive Form.There are two methods to identify the locale of an Adaptive Form. When an Adaptive Form is rendered, it identifies the requested locale by:
Retrieving 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.
Retrieving the following parameters in the listed 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 forces to render the form in Canadian-French locale:
https://'[server]:[port]'/<contextPath>/<formFolder>/<formName>.html?wcmmode=disabled&afAcceptLang=ca-fr
The browser locale set for the user, which is specified in the request using the Accept-Language
header.
If a client library for the requested locale doesn’t 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
doesn’t exist, the adaptive form uses 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.
Once the locale is identified, the Adaptive Form 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 is 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.
Get sample client library to add support for new locale. You need to change the content of the folder in the required locale.
Adobe recommends creating translation project after creating an Adaptive Form.
When new fields are added in an existing Adaptive Form:
[server:port]/libs/cq/i18n/gui/translator.html
. Update the dictionary for the newly added fields and upload it.