A great utility for localization is Attesoro, which can help you build your resource bundles.
Eclipse Resource Bundle Editor Plugin: http://sourceforge.net/projects/eclipse-rbe/ is another FANTASTIC editor for eclipse.
IBM's Resource Bundle Manager which is awesome too.
Below you can see some screenshots of the eclipse resource bundle editor plugin. I really recommend this tool also
INFO Make sure your files are all utf-8 encoding. It's also good i18n practice to liberally use cfprocessingdirective
Now that you have completed the initialization of the i18n settings in the configuration file, you are ready to code for them. There are several methods that are available to all handlers, interceptors, layouts and views that deal with i18n via runtime mixins. You can use these methods directly or go to the services directly if you inject them.
This module registers the following models in WireBox:
i18n@cbi18n
: Helper with all kinds of methods for localization
resourceService@cbi18n
: Service to interact with language resource bundles
The module registers the following methods for handlers/layouts/views/interceptors:
You can leverage the getResource() or $r()
method to retrieve resources from specific bundles by using the bundle
argument or the @bundle
convention.
We do like our @bundle
convention as it looks prettier and you type a lot less.
Here are some examples of usage
INFO Please note that the i18N services are singleton objects and lives throughout your entire application span.
You can place the i18n@cbi18n
service in the prc
scope and then use this utility for i18n specific methods anywhere in your layouts and views, below is a simple example:
INFO There are tons of great utility methods in the i18n service that will allow you to work with localization and internationalization. Please view them via the API Docs for the latest methods and arguments.
If you elect not to use property files for your resource bundles, or need to expand your i18n implementation to include content pulled from other sources, the module allows for the specification of a customResourceService
in the configuration.
To begin, create a custom resource service which extends the core i18n resource service:
To override the resource bundle used, you would declare a new loadResourceBundle
method. To override the implementation of the getResource( i18nResourceLabel )
you would declare a new getResource
method. An example, using your database to retrieve an i18n resource bundle:
Lets say we want to account for a more complex metadata structure in our resource bundles. For example, allow a draft
value to allow for administrators to see which items in our bundle are pending review but display the default value to the public. We might also want to add any new resource requests containing a default value as drafts in the system (which we won't cover here). For special circumstances, such as these, we would need to change the implementation of the getResource
method to account for this draft functionality:
The ability to extend and implement custom resource services provides you with a great deal of flexibility in your internationalization efforts. Use cases might include database-driven i18n resources, distributed caching implementations, and variable bundle formats used in third-party tools and plugins.