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 not exist as content. The use of global language variables helps to solve this problem and allows multiple websites you manage to take advantage of the same variables for re-use across your sites.

Edit Global Language Variables

Navigate to Types & Tags -> Languages on the dotCMS backend to view/edit/create language variables.

Entering a Global Language Variable

To retrieve a value from the language dictionary within your content, reference them as follows:


Global variables referenced this way will be cached to improve performance.

Placing a Language Select Box on a dotCMS page

You may place a language select control on your page to enable front end users to select the language they want to view the page in. Once a front-end user has set the language of choice, both the global variables and the content, whether static or dynamically driven, will display in the chosen language.

Please keep in mind that a version of the global variables and content must exist in the chosen language to be displayed. If there is no content in the selected display language, pages should be built to display a default language version, or dotCMS should be configured to automatically display pages and content in a default language if content in the selected language doesn't exist. dotCMS does not do any kind of automated translation of content.

The following example code can be used in a dotCMS header container to provide a language select box for front-end users:

<!-- START Header -->
<div class="siteTools ui-helper-reset ui-state-default ui-corner-bottom">
  <div style="float:left;padding:3px;"><a href="/edit">Edit Page</a></div>
<form action="/home/" method="get">
    <a id="opener" href="#">Login</a> 
    <a href="/dotCMS/logout">Not: $user.fullName?</a>

<!--  Language Select Box code begins here -->

  #set ($languageId = $request.getSession().getAttribute('com.dotmarketing.htmlpage.language'))
  #if (!$UtilMethods.isSet($languageId))
    #set ($language = $languagewebapi.getDefaultLanguage())
    #set ($languageId = $

  ##The languageId is set to: $languageId

  #set($pathToPage = ${VTLSERVLET_URI})

  This is the path: $pathToPage<br/>
  <script language="JavaScript">  
    function openDir( form ) { 
      var newIndex = form.fieldname.selectedIndex; 
      if ( newIndex == 0 ) { 
        alert( "Please select a language" ); 
      } else { 
        cururl = form.fieldname.options[ newIndex ].value; 
        window.location.assign( cururl ); 
  <form name="form" method="post" action="#" style="display:inline; margin:0; padding:0;"> 
    <select name="fieldname" size="1" onChange="openDir( this.form )" style="display:inline; margin:0; padding:0;">
      <option>Select a Language:</option> 
      <option value=${pathToPage}?com.dotmarketing.htmlpage.language=1>English</option>
      <option value=${pathToPage}?com.dotmarketing.htmlpage.language=2>Spanish</option>
      <option value=${pathToPage}?com.dotmarketing.htmlpage.language=3>French</option>

 <!--  Language Select Box code ends here -->   

    <li><a href="/home/">Contact Us</a></li>
    <li><a href="/home/">Site Map</a></li>

    <li><input type="text" value="Search" name="dotQ" class="text ui-widget-content ui-corner-all" onfocus="this.value='';" /></li>
  <div class="clear"></div>
<div class="clear"></div>

<div class="yui-gf ui-corner-top">
  <div class="yui-u first">
    <a href="/"><div class="logoWrapper"></div></a>
    <h1 class="hidden">CompanyX</h1>

  <!-- START Main Nav -->
  <div class="yui-u">
    <div id="nav">
  <!-- END Main Nav -->
<!-- END Header -->