Localisation key

From VYRE

Jump to: navigation, search

A localisation key is used in Unify to output text on a page in different locales. A full list of all localisation keys and their values can be found in the Configuration module under Localizations.

Contents

Localizations section

In the localizations section of Unify keys can be managed. Similar functionality can also be added to sites using the Localisations portlet.

Search

Adding text into the message search box, and then clicking the search button, will return all keys were at least one translation exists which contains that text.

Create

Clicking on the create button will present a form allowing a new key to be added, which when submitted will present the key editing screen.

Edit

When editing a key, all the current locales for that key will be displayed, and new locales can be added by clicking the Add locale button with the correct locale selected in the dropdown box. When the correct translations have be added the changes can be saved. Keys which are no longer required can be deleted.

Refresh standard keys

Clicking the Refresh standard keys will add the default keys and some translations of these keys to the system, or, if they already exist, will return them to their default values.

Usage

To output the content of a localisation key, for example in a Static code portlet or a page name, use the following format:

$bundle.translate('my.localization.key')

For more information see dynamic variables.

Some portlets, such as the user display portlet, accept a localisation key as a parameter when they are being configured. Here the name of the key can simply be entered, without any other code:

my.localization.key

XSL

To use localisation keys in XSL a different syntax needs to be used. To access the value the following parameter and variable need to be added, along with a namespace definition to the stylesheet tag (unless the exclude-result-prefix attribute is added the namespace will appear in the HTML code):

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:vyre="vyre" exclude-result-prefixes="vyre">
<xsl:param name="renderLocale"/>
<xsl:variable name="resources" select="vyre:publishing.LocalizationProcessor.getCachedBundleByLanguage($renderLocale)"/>

The value can then be accessed using:

<xsl:value-of select="vyre:getXSLString($resources,'my.localization.key')"/>

or when between quotes:

{vyre:getXSLString($resources,'my.localization.key')}

Page Templates

To use localisation keys in Page Templates simply include the 'fmt' tag library at the top of the template.

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

And then on the page you can call the message function to display the value of a desired key.

<fmt:message key="my.localisation.key"/>
Personal tools