public string function getResource(
// The resource (key) to retrieve from the main loaded bundle.
//A default value to send back if the resource (key) not found
//Pass in which locale to take the resource from. By default it uses the user's current set locale
any locale="#VARIABLES.i18n.getfwLocale()#",
//An array, struct or simple string of value replacements to use on the resource string
//prevent errors via empty label strings from being passed
if( !len( trim(resource) ) ) return resource;
//protect from a bad locale value being passed
if( !len( trim( arguments.locale ) ) ) arguments.locale = VARIABLES.i18n.getfwLocale();
var thisLocale = arguments.locale;
var rBundles = Controller.getSetting("RBundles");
var currentUser = Wirebox.getInstance( "SessionService" ).getCurrentUser();
if( !structKeyExists( rBundles, arguments.locale ) ){
loadBundle( rbLocale=arguments.locale, rbAlias=arguments.bundle );
var resourceBundle = rBundles[ arguments.locale ];
if( structKeyExists( resourceBundle, arguments.resource ){
var resource = resourceBundle[ arguments.resource ];
if( resource.published ){
return formatResourceObject( resourceObj=resource, args=arguments );
} else if( !resource.published && currentUser.isAdministrator() ) {
return formatDraftResource( resourceObj=resource, args=arguments );
} else if( !isNull( arguments.default ) ) {
if( !isNull( arguments.values ) ){
return formatRBString( arguments.default, arguments.values );
return arguments.default;
return renderUnknownTranslation( arguments.resource );