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.