The Resource I18n Concern Library (Rincl) facilitates internationalization by providing access to localization resources via Csar.
Rincl uses the Csar ConcernProvider
mechanism, so that an application can have access to a globally configured default Rincl implementation simply by including that implementation's dependency. For example merely including the dependency io.rincl:rincl-resourcebundle-provider:x.x.x
will automatically provide resources from resource bundle property file lookup. Classes desiring resource access may then then implement Rincled
for simplified retrieval of Resources
.
More complex configuration may be using Rincl.setDefaultResourceI18nConcern(ResourceI18nConcern)
with the concern of choice, as in the following example:
Rincl.setDefaultResourceI18nConcern(new MyResourceI18nConcern());
The Rincl
class also provides methods for retrieving and setting the locale, with improvements over the native Java approach.
An application can easily integrate Rincl resource bundle support with just a few steps:
- Include the dependency
io.rincl:rincl-resourcebundle-provider:x.x.x
. This automatically includes the dependenciesio.rincl:rincl-resourcebundle:x.x.x
andio.rincl:rincl:x.x.x
, and registers support for resource bundles. - (optional) Set the preferred locale using
Rincl.setLocale(Locale locale)
. - Have
MyClass
implement the mixin interfaceRincled
. - Store resources in
MyClass.properties
orMyClass_xx.properties
, etc. according to the desired locale. - Inside
MyClass
callgetResources().getXXX(String resourceKey)
to retrieve the type of resource you desire.
Note: If you do not want to implement Rincled
, you can access resources for any class using Rincl.getResourceI18nConcern(MyClass.class).getResources().getXXX(String resourceKey)
.
Other Rincl implementations in addition to resource bundles will be available in the future.
Rincl is available in the Maven Central Repository in group io.rincl.
Issues tracked by JIRA.
- 0.7.1:
- RINCL-14: Parent resources fallback for strings drops format arguments.
- RINCL-13: Add ability to look up resources for actual class instances.
- RINCL-10: Add support to request messages from a specific locale.
- RINCL-9: Support additional resource types.
- RINCL-4: Standard way for providing parent/fallback resources.
- 0.7.0:
- 0.6.0: First release.