Global Language Variables - Documentation topics on: global language variables,i18n,internationalization,l10n,languages,localization,multilingual content,.

Global Language Variables

dotCMS allows easy and flexible management of multilingual content versions and multiple websites, but a completely multi-lingual site will need to handle multi-lingual navigation menus, buttons, etc, that may need to be referenced using variables. The use of Language Variable Content Type helps to solve this problem and allows the multilingual websites you manage to take advantage of the same language variables, and their different language versions, for use across your all of the sites you are managing with dotCMS.

Adding a New Language

New languages can be added under Types & Tags > Languages on the backend of dotCMS using two letter language and country codes.

Adding a New Language Variables as Content

Navigate to Language Variable Content Type under Content on the dotCMS backend to view/edit/create new language variables. The image below shows a few terms added that have both English and Spanish language versions.

Pulling Language Variables using the Text Tool

To retrieve a value dynamically on any page, using the following syntax, which will return the proper value for the corresponding language_id set in the current browser session:

$text.get("keyname")
  • OR -

In the same browser session, you can pull multiple language versions by passing the language id of the desired language version as a second parameter (English=1, Spanish=2):

$text.get("keyname", "1") - English
$text.get("keyname", "2") - Spanish

Example: Multiple languages in the same widget

The following code uses the Text tool to pull multiple language versions of the language variables at the same time.

<h3>English Language Variables</h3>
First Name: $text.get("firstName","1")<br>
Last Name: $text.get("lastName","1")<br>
City: $text.get("city","1")<br>
State: $text.get("state","1")<br>

<hr>
<h3>Spanish Language Variables</h3>
First Name: $text.get("firstName","2")<br>
Last Name: $text.get("lastName","2")<br>
City: $text.get("city","2")<br>
State: $text.get("state","2")<br>  

The code above produces the following output: