Localization Functions

  • fn.localize: Return a value that is localized, in other words it will be translated if a translation exists. It is used with a macro call that returns a value from a data store.

  • fn.list_installed_languages: List the installed languages on the system. This includes languages in the Admin Portal and selfservice GUI.

  • fn.list_installed_languages_admin: List the installed languages in the Admin Portal.

  • fn.list_installed_languages_selfservice: List the installed languages in the selfservice GUI.

  • fn.list_installed_languages_by_role: List the installed languages based on the User Role Interface value.

    The User Role Interface value is a parameter of this function:

    • admin - installed languages in the Admin Portal

    • self-service - selfservice GUI

    • none - union of admin and selfservice languages

  • fn.localize_choices: Given a parameter containing a list of strings, return title-value pairs of the strings, with the titles marked for localization. The function is used to localize drop-down lists. For example, given a list:

    [ 'choice1', 'choice2' ]
    

    then the function will return

    [ {'title': _('choice1'), 'value': 'choice1'},
      {'title': _('choice2'), 'value': 'choice2'}]
    

    which is then localized upon rendering. For English, this will simply be:

    [ {'title': 'choice1', 'value': 'choice1'},
      {'title': 'choice2', 'value': 'choice2'}]
    

Example

Output

{{ fn.localize data.LocalizedModelStore.
  localized_value |
  where_clause }}

A localized value is returned.

{# fn.list_installed_languages #}
[{'value': 'en-us',
  'title': 'English'},
 {'value': 'de-de',
   'title':'German'}]
{# fn.list_installed_languages_admin #}
[{'value':'en-us',
  'title': 'English'}]
{# fn.list_installed_languages_selfservice #}
[{'value': 'en-us',
  'title': 'English'},
 {'value': 'de-de',
  'title': 'German'}]
{# fn.list_installed_languages_by_role none #}
[{'value': 'en-us',
  'title': 'English'},
 {'value': 'de-de',
   'title': 'German'}]
  {{ fn.localize_choices
data.HcsNbnSupportedModelsDAT.operations |
modelType:data/User }}

output before localization:

[{'title': _('create'),
  'value': 'create'},
 {'title': _('delete'),
  'value': 'delete'},
 {'title': _('update'),
  'value': 'update'}]