BPM, Workflow, and Case

 View Only

IBM BAW- Exploring a New Dimension of Resource Bundles: Customizing Data Beyond Locale.

By Sachin Jain posted Sat August 10, 2024 06:05 AM

  

Introduction

Resource bundles are typically used to update labels or messages based on the user's locale, ensuring that content is appropriately tailored to different languages and regions. However, we've discovered an additional, powerful capability of resource bundles: the ability to maintain different values even within the same locale, allowing messages to be customized and displayed differently based on specific business needs.

 

As businesses grow and enter global markets, the ability to deploy the same code seamlessly across various countries or regions becomes crucial. To support this, we’re excited to introduce a solution that allows resource bundles to be customizable without requiring code changes or locale adjustments!

The Challenge: When deploying the same code across different countries or markets, challenges often arise due to the need for different labels on screen fields. These variations are necessary to meet local requirements or to avoid certain terms due to cultural or religious sensitivities, such as in the case of Islamic Banking.

 

The Solution: Our solution allows you to maintain a single code base while displaying customized labels on the screen as needed. This is achieved by storing resource bundle override data in a database or location that can be easily modified. The data is then retrieved and used to override the resource bundle via a specific function, ensuring that messages can be adapted without altering the core code.

Limitations:

  • The function must be executed within the context of the client-side human service.
  • Resource bundle overrides are only applied within the client-side human service context, not server-side.

 

Benefits:

  • Simplifies the deployment of the same code across different countries or markets.
  • Maintains a single code base while allowing different labels to be displayed.
  • Ensures compliance with cultural or religious requirements by avoiding specific words.

Technical Details: The key technical components of this solution include:

  • Resource Bundle Data: Override data is stored in a database or a location that can be easily updated or modified.
    sample override data:
{"hiringAssetRB":{"positionType":{"en":"Category"},"startingDate":{"en":"Joining Date"}}}

  • Managed File-JS Function: A managed file (uiconfig_util.js) of server type is added to the toolkit, this file contain function which facilitating resource bundle overrides for a CSHS with tw.resource namespace updates.
//Function to be used within CHSH for UI config pattern
function(){
  //Function overrides the resource bungle which is to be used
  //Before coming to the fist coach
  this.overrideResourceBundles=function(overrides /* response of the integration service */){
    if(!!overrides && !!tw){
      var configData=JSON.parse(overrides);
      //itegrate over bundles
      for(var bundleName in configData){
        if(!!tw.resource[bundleName]){
          //iterate over keys
          for(var key in configData[bundleName]){
              //check the type
              if(typeof configData[bundleName][key]==='string'){
                tw.resource[bundleName][key]=configData[bundleName][key];
              }else if(!!configData[bundleName][key][tw.system.user.locale]){
                tw.resource[bundleName][key]=configData[bundleName][key][tw.system.user.locale];
              }else if(!!configData[bundleName][key]["en"]){
                tw.resource[bundleName][key]=configData[bundleName][key]["en"];
              }//end of inner if else
            }//end of key for loop
          }else{
            console.warn('Bundle '+bundleName+' is not defined for the client side service');
          }
        }//end of bundle name for loop
      }//end of null check if
    }//end of override function
}//End of function for loop

  • Function execution: This function is executed within the context of the client-side human service to override resource bundle data.

if(!!tw.local.functions){
 var UIFunc=eval('new ('+tw.local.functions +')()');//run the functions string
 if(!!UIFunc.overrideResourceBundles && !!tw.local.resourceBundleOverride){
 	UIFunc.overrideResourceBundles(tw.local.resourceBundleOverride);
 }//End of if
}//End of outer if

  • Implementation Details: 
  1. Client side human service
    1. Fetch override resource bundle data based on current storage position (database or server file)
    2. Fetch function details from file and execute in the context of the coach.

 2. Coach view implementation: Create and attach resource bundle to the places where override is required.

Demo:
1. Execution of service without any override:-
Default label is available in the screen.
2. Execution of service after overriding resource bundle data.
Resource bundle override data:
{"hiringAssetRB":{"positionType":{"en":"Category"},"startingDate":{"en":"Joining Date"}}}

labels are changed for "Position type" and "Starting Date" without changing locale.

Authors:

This solution is developed and written by:

1. Mukesh Verma

2. Sachin Kumar Jain

#GlobalDeployment #FlexibleResourceBundles #SingleCodeBase #ClientSideHumanService #RuntimeUserMaintenance


#BusinessAutomationWorkflow(BAW)
0 comments
22 views

Permalink