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.
{"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
- Client side human service
- Fetch override resource bundle data based on current storage position (database or server file)
- Fetch function details from file and execute in the context of the coach.
Demo:
1. Execution of service without any override:-
Default label is available in the screen.
#GlobalDeployment #FlexibleResourceBundles #SingleCodeBase #ClientSideHumanService #RuntimeUserMaintenance
#BusinessAutomationWorkflow(BAW)