Accessing properties in JavaScript

There are three requirements for accessing a JavaScript property.

Figure 1. Accessing a property
// 1.
     dojo.requireLocalization("curam.application", "SomeJSFile");
     
     // 2.
     dojo.require("curam.util.ResourceBundle");
     var bundle = new curam.util.ResourceBundle("SomeJSFile");
     
     // 3.
     var localizedMessage = bundle.getProperty("myPropertyKey");
     var localizedMessageWithSubstitutions 
       = bundle.getProperty("my.sub.key", ["a", "b"]);

curam.application is the default package into which all localizable resources are placed by the Curam infrastructure. SomeJSFile is derived from the name of the related JavaScript properties file.

  1. Load the resources using dojo.requireLocalization().

    Refer to comment 1 in Accessing properties in JavaScript for an example of this.

  2. Create an instance of the curam.util.ResourceBundle object.

    This is required in order to be able to access the localized resources. Refer to comment 2 in Accessing properties in JavaScript for an example of this.

  3. Access a property

    The getProperty() method can be used to access a property on the instantiated ResourceBundle. Refer to comment 3 in Accessing properties in JavaScript for an example of how to get a property and a substituted (2 substitutions) property respectively.