Forms (Multilingual) - Documentation topics on: form handling,forms,i18n,internationalization,l10n,language properties,languages,localization,multilingual,.

Forms (Multilingual)

Forms placed on any page will persist on that page regardless of what language is set in the session. Multilingual forms are expected to make use of default language properties and display the language set in the session.

Language Variables

Default language variables have been set within language properties files in several languages in the following directory:

dotCMS/WEB-INF/messages

In these language properties files, common terms such as “Submit“, “Forgot Password“, “Name“, “month“, and many more have already been translated in multiple languages. However these default laguage variables can be over-ridden or new variables added on the dotCMS backend as global language variables.

To make sure all fields in your multi-lingual form are internationalized, first add them all as language variables, including all of their multilingual versions, and then add the EXACT case sensitive name of that variable on the Form Structure as a field.

Example

Here's an example of how to internationalize form field labels for English and Spanish so that “First Name” and “Last Name” are internationalized:

First Name and Last Name set in English (note that the language property can't have spaces or special characters):

First Name and Last Name set in English

First Name and Last Name set as Spanish Language Variables using same Language key:

First Name and Last Name set in Spanish

After setting the Language Keys, use those keys on the Form Structure as shown below:

Using Language Keys on the Form Structure

When the Form is placed on a page and that page is viewed with the language setting set to English (language_id=1), or Spanish (language_id=2), the form will automatically translate the form labels using the Language Key values.

Example Form in English

English version of the form

Example form in Spanish

Spanish version of the form