12. Language

12.1. Introduction

Support for multilanguage portals, with a customizable dictionary. Languages can be freely defined and associated to locales for e.g. language specific date formatting.

12.2. Language Handling

This chapter will help you to understand how to handle Gentics Portal.Node's language features. See Section 8.5, “language-section” to learn how multilanguage support is configured. In views the current language can be read or set using portal.language.id.

Example 4.56. Setting the current language

Here's a simple example which depicts how to set the portal's language to German, assuming that the id of "German" is configured to be "de". Also see the Gentics Portal.Node SDK's SamplePortletapplication/LanguageSelector portlet for a working real-life example.

<view>
  ...
    <action class="GeneralViewAction">
      <parameters>
        <parameter id="set">portal.language.id="de"</parameter>
      </parameters>
    </action>
  ...
</view>

In templates, you can either use $portal.i18n("key") or the “I18nImp” (Section 1.11). For setting parameters in the translation, you can use the setParameter() method:

## welcome is translated into "Welcome $name!"
#set($message = $portal.i18n("welcome"))
$message.setParameter("name", $portal.user.lastname)
## this will output something like "Welcome Mustermann!"
$message

Keep in mind that you will need to maintain a dictonary for every language configured, as described in Section 8.5.3, “Dictionaries”