Tajin I18N support.
Features
- Automatic bundle reloading
- Caching
- JSON bundle support
- Javascript bundle support
- ResourceBundle support
- Google Guice integration
Usage
Add a field annotated with @Bundle
in your class with type I18NBundlerProvider
, with the wanted bundle. Then access the bundle for a locale and translate.
static class MyClass {
@Bundle('classpath:bundle.js')
I18NBundlerProvider i18n
void aMethod() {
i18n.getBundle(Locale.CANADA_FRENCH).getValue('mykey', ['10', 'seconds'])
}
}
Settings
-
tajin.i18n.miss
: Specify behavior on key not found.- Default:
THROW_EXCEPTION
- Possible values:
THROW_EXCEPTION
,RETURN_NULL
,RETURN_KEY
- Default:
-
tajin.i18n.cache.maximumSize
: Specify the maximum cache size of localized bundles. Bundles are a set of merges properties for a given locale. In an application handling mainly 2 or 3 locales, you can reduce this value.- Default:
100
- Set it to
-1
for no maximum size (i.e. when locale values are controled) - Set it to
0
for no cache at all
- Default:
-
tajin.i18n.cache.expirationSeconds
: Specify the maximum of time a bundle will remain in cache before being reloaded.- Default:
3600
- Set it to
-1
for no eviction - Set it to
0
for no cache at all
- Default:
Tajin templating support.
Features
- Groovy syntax support
- Context data
- Localized bundles
- Caching
- Any location
Usage
Add a field annotated with @Template
in your class with type TemplateMerger
, with the wanted template location. Then merge with a locale and some context data.
static class MyClass {
@Template('classpath:template.txt')
TemplateMerger merger
void aMethod() {
merger.merge(Locale.CANADA_FRENCH, [context: session])
}
}
Settings
-
tajin.templating.charset
: Specify the charset for the templates.- Default:
UTF-8
- Default:
-
tajin.templating.baseDir
: Base directory to find templates into.- Default:
default working directory of JVM process
- Default:
-
tajin.templating.cache.maximumSize
: Specify the maximum cache size of localized templates.- Default:
-1
- Set it to
-1
for no maximum size (i.e. when locale values are controled) - Set it to
0
for no cache at all
- Default:
-
tajin.templating.cache.expirationSeconds
: Specify the maximum of time a bundle will remain in cache before being reloaded.- Default:
-1
- Set it to
-1
for no eviction - Set it to
0
for no cache at all
- Default:
Adds asynchronous Event support in your project. This module contains a Dispatcher
based on Google Guava EventBus
.
Settings
-
tajin.async.dispatcher.enabled
: Specify if you want to activate or not async feature- Default:
true
- Default:
-
tajin.async.dispatcher.minPoolSize
: Specify the minimum pool size for async events- Default:
0
- Default:
-
tajin.async.dispatcher.maxPoolSize
: Specify the maximum pool size for async events. If the pool size is reached, events will be dispatched on the same thread firing them.- Default:
10 * <cpu count>
- Default:
-
tajin.async.scheduler.enabled
: Specify if you want to activate or not scheduling feature- Default:
true
- Default:
-
tajin.async.scheduler.poolSize
: Specify the pool size for scheduled tasks- Default:
2 * <cpu count>
- Default:
This is a bundle containing all Tajin modules at once.