G11N & I18N

BTT Web 2.0 On-Demand Internet banking Workplace supports G11N & I18N.

Internet banking developers can develop a script file, for example, LangList.js, to list the languages to be internationalized, and map it to a resource file, such as Lang-en_US.js. In the resource file, developers list the pairs of key-values of the content to be internationalized.

When an end-user logs on, he or she will see a page in the same language as the OS default language.

The end-user can also change the language by specifying a favorite language as shown in the sample. In this case the page is reloaded and shown in the language the user has selected.

Here is an example of the script file LangList.js.

/**
 * the base uri of language resource file
 */
BTTLocale.baseUri = "BTTWeb20/locale/language/";
BTTLocale.prefix = "Lang-";
BTTLocale.extension = ".js";

/**
 * the mapping from language string to resource file 
 */
BTTLocale.Lang = {
	"zh-cn": "zh_CN",
	"en-gb": "en_GB",
	"en-us": "en_US",
	"en-ca": "en_CA"
}
Where:
  1. BTTLocale.baseUri is the URI of the resource file.
  2. BTTLocale.prefix is the prefix of the name of the resource file.
  3. BTTLocale.extension is the extension of the resource file.
  4. BTTLocale.Lang lists the key-value pairs of the languages. The key should be the exact OS language identifier.

    Make sure you use the quotation marks for the key because JavaScript™ can't parse String with " - " in it correctly.

Here is an example of the resource file Lang-en_US.js.

BTTLocale.resource = {
	
  //service repository
	my_service: "My service",
	basic_widget: "Basic Widgets",
	html_service: "Html Service",
  web1_transaction: "Web1.0 Transaction",
	...
		
	//tooltips
	tip_tab_close:"click to close tab",
	tip_tab_logo: "click to edit tab logo",
	tip_max:"max",
	tip_restore: "restore",
	...
  
  //other information
  add_tab: "add new tab",
	add_column: "add new column"
  ...
  
  //Attention: Don't add "," after the last key-value pairs
}
Note:
  1. To internationalize the service tree, the key should be the identical attribute of “name” in Service.xml.

    As described in the parameters specification for each tag in Service.xml, the name attribute is the service name which is displayed in the service list tree.

  2. To internationalize the tips, the key should be the identical ones listed in the sample.

    See the following table lists for details.

    Table 1. Lists of the key-value pairs of tool tips internationalization
    Key Description
    tip_tab_close Tips for the close icon of a tab
    tip_tab_logo Tips for a tab logo
    tip_max Tips for the max icon of a widget
    tip_restore Tips for the restore icon of a widget
    tip_edit Tips for the edit icon of a widget
    tip_refresh Tips for the refresh icon of a widget
    tip_collapse Tips for the collapse icon of a widget
    tip_close Tips for the close icon of a widget
  3. For other information to be internationalized,
    1. Define the key as you like. Invoke the method BTTLocale.getText(key) in the resource.jsp to get the internationalized information as follows:
      function showTools(){ 	  
      		$("add_tab").innerHTML = BTTLocale.getText("add_tab"); 	  
      		$("add_column").innerHTML = BTTLocale.getText("add_column");
      		...
      }
    2. If parameters are needed, you can call the method BTTLocale.getText(key, arg1, arg2...)

      The first parameter is the key of text that needs to be internalized. Other parameters are what need to be internationalized.

      Here is an example. If you want to show a visit track which consists of two arguments, username, time and the fixed text, do the following:
      1. Call the method BTTLocale.getText(key, arg1, arg2...) by the following code:
        function user(name){
          this.name = name;
        	  this.visit = function(){
        		  var t = new Date();
        		  var track = BTTLocale.getText("visit_track",this.name,t);
        		  alert(track);
        	  }
        }
        var user1 = new user("Jack");
        user1.visit ();
      2. Define the internationalization text in resource file Lang-en_US.js::
        visit_track: "User {1} visited you at {2}",
      3. When your favorite language is English, you can see:
        example of internationalize information with arguments
  4. Make sure you save this resource file in UTF-8.