@Singleton public class TranslationServiceImpl extends Object implements TranslationService
DefaultMessageBundlesLoader
.
Each given key is looked up in the given locale, then in less specific locales, then in the fallback locale.
That is, if [a, b, c] are passed as keys, with country-specific Locale such as de_CH, and "b" is defined in the de_CH
message bundle, it will be returned, even if "a" is defined in the less specific "de" Locale.
When a basename is explicitly specified, it however uses MessagesManager
to look the keys up, falls back
to the default bundle of MessagesManager, then finally falls back on its own global message bundle.Constructor and Description |
---|
TranslationServiceImpl()
|
TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider)
|
TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider,
ComponentProvider componentProvider,
ResourceOrigin resourceOrigin,
EventBus systemEventBus) |
Modifier and Type | Method and Description |
---|---|
protected String |
handleUnknownKey(Locale locale,
String basename,
String[] keys) |
void |
reloadMessageBundles()
Allows to reload all the message bundles - useful in development.
|
protected DefaultMessageBundlesLoader |
setupMessageBundles() |
String |
translate(LocaleProvider localeProvider,
String[] keys) |
String |
translate(LocaleProvider localeProvider,
String basename,
String[] keys) |
@Inject public TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider, ComponentProvider componentProvider, ResourceOrigin resourceOrigin, @Named(value="system") EventBus systemEventBus)
@Deprecated public TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider)
@Deprecated public TranslationServiceImpl()
protected DefaultMessageBundlesLoader setupMessageBundles()
public String translate(LocaleProvider localeProvider, String[] keys)
translate
in interface TranslationService
public String translate(LocaleProvider localeProvider, String basename, String[] keys)
translate
in interface TranslationService
basename
- Usage of a basename is deprecated since 5.1. This method is here to allow backwards compatibility.public void reloadMessageBundles()
TranslationService
reloadMessageBundles
in interface TranslationService
Copyright © 2003–2016 Magnolia International Ltd.. All rights reserved.