Namespace: Translation

Translation

This service can be instantiated within the Maestro angular app or within node for unit testing. Note that the node module will not have access to $rootScope, Form or Resource. Methods relying on these dependencies cannot be unit tested.

Methods


Translation.fetch(lang [, retainUserLanguage] [, translationDataUrl])

Loads the translation for the specified language code. If the translation loads, the interface will refresh with the localized terminology. If the translation doesn't load, an error will appear in the JavaScript Console.
Parameters:
Name Type Argument Description
lang string The language to fetch the dictionary for.
retainUserLanguage string <optional>
Skip updating the selected language in the browser storage
translationDataUrl string <optional>
URL to download the translation CSV from
Returns:
Type
Promise
Example

Load a translation with a language code of "en_AU".

Translation.fetch("en_AU");

Translation.setValues(newValues)

Updates the current language with the definitions provided in the newValues object. The current form will be updated with the language definitions, but the language will not be saved.
Parameters:
Name Type Description
newValues object Key/value pairs to update the translation dictionary. Key is the path of the item property to be updated, value is the new string to apply
Examples

Update the label of the field with ID "firstName".

Translation.setValues( { "firstName.label": "Enter your First Name" } );

Update the display value of the second option in the "myDropdown" dropdown widget.

Translation.setValues( { "myDropdown.properties.options[1].label": "New Dropdown Option" } );