Contextual Translation Scoping

Release 1.4 - ...

A new concept for translation scoping is introduced in 1.4: Contextual Translation Scoping.

After the introduction of sys.eval() with explicit scopes in 1.2 and 1.3, and with the introduction of Smartlet Presets in 1.4, we wanted to make things less complex. While sys.eval() with given scopes worked fine, things get a little nasty when splitting code blocks into separate translations. Consider the following piece of code:

Smartsite SXML CopyCode image Copy Code
{sys.eval(override_formatrow($data), smartlet.page(), smartlet.number())}

When moving that bit of code from a Smartlet's SXML to a separate translation, one had to rewrite the code:

Smartsite SXML CopyCode image Copy Code
{sys.eval(override_formatrow($data), translation.arg(page), smartlet.caller())}

Apart from the pain of refactoring, the readability doesn't really improve this way.

The main reason the explicit scoping feature was introduced was to allow for overriding local overridable translations in a Smartlet folder. This means that the two scoping parameters would mostly point to:

  1. The page the smartlet renders on
  2. The smartlet itself

Considering the fact that there already were two ways to specify the scope for translations to use:

  1. translation.localscope.xxx()
  2. translation.globalscope.xxx()

... we decided to introduce a third one that implicitly 'knows' what scopes to rely on: translation.scope.xxx()

Both pieces of code shown above can then be rewritten as:

Smartsite SXML CopyCode image Copy Code
{translation.scope.override_formatrow($data)}

Calling translations this way ensures that scope resolving takes three scopes into account.

  1. Page scope
    Normal scope. Always set, and normally provided by the rendering page. 
  2. Evaluation scope
    Special scope to be injected by using the TranslationContext macro or by specifying the evaluationscope named argument in translation calls.
  3. Fallback scope
    Scope to use as 'if all else fails' scope. Set automatically by Smartlets, to their own folder.