@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()
Deprecated.
since 5.4.4. Use
#TranslationServiceImpl(javax.inject.Provider, javax.inject.Provider instead. |
TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider)
Deprecated.
since 5.4.5. Use
#TranslationServiceImpl(javax.inject.Provider, javax.inject.Provider instead. |
TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider,
ComponentProvider componentProvider,
ResourceOrigin resourceOrigin,
EventBus systemEventBus)
Deprecated.
since 5.5.2. Use
#TranslationServiceImpl(javax.inject.Provider, javax.inject.Provider instead. |
TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider,
javax.inject.Provider<DefaultMessageBundlesLoader> defaultMessageBundlesLoaderProvider) |
Modifier and Type | Method and Description |
---|---|
protected String |
handleUnknownKey(Locale locale,
String basename,
String[] keys) |
void |
reloadMessageBundles()
Deprecated.
since 5.5.2. Reload message bundles in
DefaultMessageBundlesLoader directly. |
protected DefaultMessageBundlesLoader |
setupMessageBundles()
Deprecated.
since 5.5.2. Use
defaultMessageBundlesLoaderProvider directly or setup message bundles in DefaultMessageBundlesLoader . |
String |
translate(LocaleProvider localeProvider,
String[] keys) |
String |
translate(LocaleProvider localeProvider,
String basename,
String[] keys) |
@Inject public TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider, javax.inject.Provider<DefaultMessageBundlesLoader> defaultMessageBundlesLoaderProvider)
@Deprecated public TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider, ComponentProvider componentProvider, ResourceOrigin resourceOrigin, @Named(value="system") EventBus systemEventBus)
#TranslationServiceImpl(javax.inject.Provider, javax.inject.Provider)
instead.@Deprecated public TranslationServiceImpl(javax.inject.Provider<I18nModule> i18nModuleProvider)
#TranslationServiceImpl(javax.inject.Provider, javax.inject.Provider)
instead.@Deprecated public TranslationServiceImpl()
#TranslationServiceImpl(javax.inject.Provider, javax.inject.Provider)
instead.@Deprecated protected DefaultMessageBundlesLoader setupMessageBundles()
defaultMessageBundlesLoaderProvider
directly or setup message bundles in DefaultMessageBundlesLoader
.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.@Deprecated public void reloadMessageBundles()
DefaultMessageBundlesLoader
directly.TranslationService
reloadMessageBundles
in interface TranslationService
Copyright © 2003–2017 Magnolia International Ltd.. All rights reserved.