Resource Bundles - Mura Docs v6

Resource Bundles

Resource Bundles add a common method of internationalization to Mura.

rbFactory = $.siteConfig('RBFactory');

By default a site's resource bundles are located at {siteid}/includes/resourceBundles/. They follow a strict naming convention that matched the languages language and region values.

Syntax

{language}_{region}.properties

Example:

en_us.properties

If Mura cannot find a direct language and region match it will look for just a language match.

Example:

{language}.properties

Example:

en.properties

Custom Keys

If you have custom keys that you would like to deploy as part of a theme you can deploy them in a resource bundle file within your site's theme directory ({siteid}/includes/themes/{theme}/resourceBundles). You only need to add keys that are unique to your theme. All other key values will come from the default resource bundles ({siteid}/includes/resourceBundles).

For example, if your theme required a key named myCustomString and your site was using the default English resource bundle you would create a file name en.properties in your {siteID}/includes/themes/{theme}/resourceBundles directory with the following content:

myCustomString=This is my custom resource bundle key.

You could then reload Mura and have access to that key.

<cfscript>
    rbFactory = $.siteConfig('RBFactory');
</cfscript>

<cfoutput>
    #rbFactory.getKey('myCustomString')#<br/>
    #rbFactory.getKey('comments.comments')#
</cfoutput>

As a shortcut, you can also directly pull keys from an instance of the Mura Scope.

<cfoutput>
    #$.rbKey('myCustomString')#<br/>
    #$.rbKey('comments.comments')#
</cfoutput>

Lookup Hierarchy

Mura has a strict look-up hierarchy that allows you to both organize your resource bundles and override base settings:

  1. /{SiteID}/includes/themes/{theme}/resourceBundles/{targetResourceBundle}
  2. /{SiteID}/includes/resourceBundles/{targetResourceBundle}
  3. /requirements/mura/resourceBundles/resources/{targetResourceBundle}