Java Integration

Java SDK offers many methods and functions that can be used in the Controllers, Views and Models. The following sections will provide a detailed description for every function and its options.

Tml static utility functions

Tml static utility functions

All functions documented under this section have to be called under Tml class e.g. Tml.translate("Hello world").

translate

Translation function available in controllers

translate(String label, String description)

translate(String label, String description, Map<String, Object> tokens)

translate(String label, Map<String, Object> tokens)

translate(String label, Map<String, Object> tokens, Map<String, Object> options)  
Name Type Required Description
label String true The label to translate
description String false Description of the label that acts as a hint to the translator as well as contextualizes the key to be unique for the description
tokens Map<String, Object> false If label uses data or decoration tokens, the token values will be provided using this parameter
options Map<String, Object> false Additional attributes

Options

  • dry - set to no translate this label to current language, display it in original language

switchLanguage

Function to switch context to another language

switchLanguage(Language language)  
Name Type Required Description
language Language true The language to which you need to swith

getCurrentLanguage

Function to get current language in Session

getCurrentLanguage()  

initSource

Function to init new source in Application

initSource(String key)

initSource(String key, String locale)  
Name Type Required Description
key String true The source key to get
locale String false The locale to translate

getCurrentSource

The function to get current source of current Session

getCurrentSource()  

getApplication

The function to get Application of current Session

getApplication()  

beginBlockWithOptions

The function to start translation block with custom options

beginBlockWithOptions(Map<String, Object> options)  
Name Type Required Description
options Map<String, Object> true The map of options that must be set to block

getBlockOptions

The function to get options of block

getBlockOptions()  

endBlock

The function to end translation block

endBlock()  

getBlockOption

The function to get specific option from the block

getBlockOption(String key)  
Name Type Required Description
key String true The key of option that need to be get