Skip to content

Commit

Permalink
Fix #11569: Core JS setGlobalLocaleValue
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Mar 9, 2024
1 parent c680199 commit e82cc11
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,35 @@
var locale = this.getLocaleSettings();
return (locale&&locale[key]) ? locale[key] : PrimeFaces.locales['en_US'][key];
},

/**
* Loop over all locales and set the label to the new value in all locales.
* @param {string} localeKey The locale key
* @param {string} localeValue The locale value
*/
setGlobalLocaleValue: function(localeKey, localeValue) {
// Recursive function to iterate over nested objects
function iterateLocale(locale, lkey, lvalue) {
for (var key in locale) {
if (typeof locale[key] === 'object') {
// If the value is an object, call the function recursively
iterateLocale(locale[key], lkey, lvalue);
} else {
// Otherwise, set the new value if found
if (key === lkey) {
locale[key] = lvalue;
}
}
}
}

// iterate over all locales and try and set the key in each locale
for (var lang in PrimeFaces.locales) {
if (typeof PrimeFaces.locales[lang] === 'object') {
iterateLocale(PrimeFaces.locales[lang], localeKey, localeValue)
}
}
},

/**
* For 4.0 jQuery deprecated $.trim in favor of PrimeFaces.trim however that does not handle
Expand Down

0 comments on commit e82cc11

Please sign in to comment.