Localization functions
----------------------


.. index:: Macro function;fn.localize

* *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.           

.. index:: Macro function;fn.list_installed_languages

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

.. index:: Macro function;fn.list_installed_languages_admin

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

.. index:: Macro function;fn.list_installed_languages_selfservice

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

.. index:: Macro function;fn.list_installed_languages_by_role

* *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 


.. index:: Macro function;fn.localize_choices

* *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'}]  
  
  

.. tabularcolumns:: |p{10cm}|p{5cm}|

+----------------------------------------------------+-----------------------------+
| Example                                            | Output                      |
+====================================================+=============================+
| ::                                                 |                             |
|                                                    | A localized value is        |
|    {{ fn.localize data.LocalizedModelStore.        | returned.                   |
|      localized_value |                             |                             |
|      where_clause }}                               |                             |
+----------------------------------------------------+-----------------------------+
| ::                                                 | ::                          |
|                                                    |                             |
|    {# 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'}]  |
|                                                    |                             |
+----------------------------------------------------+-----------------------------+
|                                                    | output before localization: |
|                                                    |                             |
| ::                                                 | ::                          |
|                                                    |                             |
|    {{ fn.localize_choices                          |     [{'title': _('create'), |
|  data.HcsNbnSupportedModelsDAT.operations |        |       'value': 'create'},   |
|  modelType:data/User }}                            |      {'title': _('delete'), |
|                                                    |       'value': 'delete'},   |
|                                                    |      {'title': _('update'), |
|                                                    |       'value': 'update'}]   |
+----------------------------------------------------+-----------------------------+

.. |VOSS Automate| replace:: VOSS Automate
.. |Unified CM| replace:: Unified CM
