Class: Translations

Oracle® JavaScript Extension Toolkit (JET)
3.2.0

E87541-01

QuickNav

oj. Translations

Version:
  • 3.2.0
Services for Retrieving Translated Resources

Constructor

new Translations()

Source:

Methods

<static> applyParameters(pattern, parameters)

Applies parameters to a format pattern
Parameters:
Name Type Description
pattern string pattern that may contain tokens like {0}, {1}, {name}. These tokens will be used to define string keys for retrieving values from the parameters object. Token strings should not contain comma (,) or space characters, since they are reserved for future format type enhancements. The reserved characters within a pattern are: $ { } [ ] These characters will not appear in the formatted output unless they are escaped with a dollar character ('$').
parameters Object | Array parameters to be inserted into the string. Both arrays and Javascript objects with string keys are accepted.
Source:
Returns:
formatted message or null if the pattern argument was null

<static> getComponentTranslations(componentName)

Provides a key-to-value map of the translated resources for a given component name
Parameters:
Name Type Description
componentName string name of the component
Source:
Returns:
a map of translated resources

<static> getResource(key) → {Object|string|null}

Retrives a translated resource for a given key
Parameters:
Name Type Description
key string resource key The dot character (.) within the key string is interpreted as a separator for the name of a sub-section within the bundle. For example, 'components.chart', would be read as the 'chart' section within 'components'. Thus the key name for an individual section should never contain a dot.
Source:
Returns:
resource associated with the key or null if none was found
Type
Object | string | null

<static> getTranslatedString(key, var_args)

Retrieves a translated string after inserting optional parameters. The method uses a key to retrieve a format pattern from the resource bundle. Tokens like {0}, {1}, {name} within the pattern will be used to define placement for the optional parameters. Token strings should not contain comma (,) or space characters, since they are reserved for future format type enhancements. The reserved characters within a pattern are: $ { } [ ] These characters will not appear in the formatted output unless they are escaped with a dollar character ('$').
Parameters:
Name Type Description
key string translations resource key. The dot character (.) within the key string is interpreted as a separator for the name of a sub-section within the bundle. For example, 'components.chart', would be read as the 'chart' section within 'components'. Thus the key name for an individual section should never contain a dot.
var_args string | Object | Array optional parameters to be inserted into the translated pattern. If more than one var_args arguments are passed, they will be treated as an array for replacing positional tokens like {0}, {1}, etc. If a single argument is passed, it will be treated as a Javascript Object whose keys will be matched to tokens within the pattern. Note that an Array is just a special kind of such an Object. For backward compatibility, a var_args argument whose type is neither Object or Array will be used to replace {0} in the pattern.
Source:
Returns:
formatted translated string

<static> setBundle(bundle)

Sets the translation bundle used by JET If an AMD loader (such as Require.js) is not present, this method should be called by the application to provide translated strings for JET. This method may also be used by an application that wants to completely replace the resource bundle that is automatically fetched by an AMD loader.
Parameters:
Name Type Description
bundle Object resource bundle that should be used by the framework
Source: