Namespace: Translations

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 1.0
Module:
  • ojtranslation

QuickNav

Description

Services for Retrieving Translated Resources


Usage

Typescript Import Format
//This namespace exports multiple static methods or members. To import 
import * as Translations from "ojs/ojtranslation";

//Now you can access the methods as Translations.methodName and so on

For additional information visit:


Methods

(static) applyParameters(pattern, parameters) : {string}

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.
Returns:

The formatted message string, or an empty string if the pattern is either null or an empty string.

Type
string

(static) getComponentTranslations(componentName) : {Object}

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
Returns:

a map of translated resources

Type
Object

(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.
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.
Returns:

formatted translated string

(static) setBundle(bundle) : {void}

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
Returns:
Type
void