Translations and System Translations

Release 1.0 - ...

Translations are items of contenttype Translation. Translations are re-usable pieces of information. in an editorial environment they are used to ensure proper naming of commonly used phrases whithin an organization, like productname, company address, department name and much more. Once the item of contenttype Translation is created, editors can call these translation from their text with the default viper-syntax:

  CopyCode image Copy Code
{name of the translation()}

Every time a page is rendered, the translation-syntax is replaced by the content of the translation.

For site developers translations are even more important. They could use them to create easy to use building blocks for their sites. To distinguish 'technical' translations from content translations, the contenttype System Translation exists. Because a different contenttype is used, this translation can easily be hidden, based on security, for editors within, for example, the webEditor.

Global and Local

Translations can be made scoped. A Translation (both normal and system) can be scoped as Global or as Local. A global Translation is availlable through the complete site. A local Translation is scoped within the folder and sub-folders where the translations is added.

A local Translation can override a global Translation and give a different implementation to the global one. This is only possible when the global Translation has been marked as overridable. A local Translation can be added on it's own as well, but, be carefull with that. If a local Translation is requested within it's scope, it will render, but requested outside it's scope it generates an error.

When a local Translation overrides a global one, and only adds some extra information, it is easy to inherit from the base translation by using the translation.base() viper.

  CopyCode image Copy Code
{translation.base()}
<p>An extra line of information!</p>

Parametrized Translations

A translation will become more powerfull when it is parametrized. Based on the parameter passed into the translation, it's result will differ. Within the translation, the parameters can be read using the translation.arg() viper. The parameters are passed as a parameter array. This means that the parameters are read sequentially:

Smartsite SXML CopyCode image Copy Code
This is a translation with two arguments. The values are:
argument 1: {translation.arg(1, default="onmitted")}
argument 2: {translation.arg(2, default="onmitted")}

This example translation can be called like:

Smartsite SXML CopyCode image Copy Code
{exampletranslation('first', 'second')}

where the result is:

  CopyCode image Copy Code
This is a translation with two arguments. The values are:
argument 1: first
argument 2: second

Because the arguments are passed as a parameter array, a second parameter cannot be passed without a first parameter. If the example translation is called in this way:

Smartsite SXML CopyCode image Copy Code
{exampletranslation('second')}

The result will be:

  CopyCode image Copy Code
This is a translation with two arguments. The values are:
argument 1: second
argument 2: onmitted

Parametrized Translations and Intellisense

Within the Smartsite SXML Editor, intellisense helps a lot in coding your SXML Document. When starting a Viper syntax, Translations appear in the list as well because they conform to this syntax. To add intellisense to your translations as well, a few steps have to be taken:

A parametrized translation's name should look like this:

  CopyCode image Copy Code
exampletranslation(AnyName, AnotherName)

Intellisense will read this syntax and notices the two arguments. To provide help for the arguments, the named parameter rem is added to the first occurence of the argument within the translation. From now on, the translation arguments can be read by thier alias defined in the title:

Smartsite SXML CopyCode image Copy Code
This is a translation with two arguments. The values are:
argument 1: {translation.arg(AnyName, rem="some clear description" default="onmitted")}
argument 2: {translation.arg(AnotherName, rem="some another clear description" default="onmitted")}

Finally, the Description field of the translation is used for a helpful tooltip when a translation is selected from the list using intellisense.

Named translation arguments

Translation arguments can be passed in order of call syntax, like shown above, or by name, using the Viper named parameter syntax:

Smartsite SXML CopyCode image Copy Code
{exampletranslation('foo', 'bar', options='Test')}

Within the Translation replacement field, the value of the 'options' argument as shown here can be retrieved in the same way as arguments making part of the translation name:

Smartsite SXML CopyCode image Copy Code
{translation.arg(options)}