Package org.alfresco.repo.i18n
Interface MessageService
-
- All Superinterfaces:
org.alfresco.service.cmr.i18n.MessageLookup,org.alfresco.repo.tenant.TenantDeployer
- All Known Implementing Classes:
MessageServiceImpl
@AlfrescoPublicApi public interface MessageService extends org.alfresco.repo.tenant.TenantDeployer, org.alfresco.service.cmr.i18n.MessageLookupUtility class providing methods to access the Locale of the current thread and to get Localised strings. These strings may be loaded from resource bundles deployed in the Repository.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetBaseBundleName(java.lang.String resourceName)java.util.LocalegetContentLocale()Get the content local for the current thread.
This will revert togetLocale()if no value has been defined.java.util.LocalegetLocale()Get the general local for the current thread, will revert to the default locale if none specified for this thread.java.util.LocalegetNearestLocale(java.util.Locale templateLocale, java.util.Set<java.util.Locale> options)Searches for the nearest locale from the available options.java.util.Set<java.lang.String>getRegisteredBundles()Get set of registered message resource bundlesjava.util.ResourceBundlegetRepoResourceBundle(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String path, java.util.Locale locale)Get message resource bundle from the repository note: also used by Web Client (ResourceBundleWrapper)java.util.LocaleparseLocale(java.lang.String localeStr)Factory method to create a Locale from a lang_country_variant string.voidregister(MessageDeployer messageDeployer)Register message deployer with message servicevoidregisterResourceBundle(java.lang.String bundleBasePath)Register a resource bundle.voidsetContentLocale(java.util.Locale locale)Set the content locale for the current thread.voidsetLocale(java.util.Locale locale)Set the locale for the current thread.voidunregisterResourceBundle(java.lang.String resBundlePath)Unregister a resource bundle
-
-
-
Method Detail
-
setLocale
void setLocale(java.util.Locale locale)
Set the locale for the current thread.- Parameters:
locale- the locale
-
getLocale
java.util.Locale getLocale()
Get the general local for the current thread, will revert to the default locale if none specified for this thread.- Returns:
- the general locale
-
setContentLocale
void setContentLocale(java.util.Locale locale)
Set the content locale for the current thread.- Parameters:
locale- the content locale
-
getContentLocale
java.util.Locale getContentLocale()
Get the content local for the current thread.
This will revert togetLocale()if no value has been defined.- Returns:
- Returns the content locale
-
getNearestLocale
java.util.Locale getNearestLocale(java.util.Locale templateLocale, java.util.Set<java.util.Locale> options)Searches for the nearest locale from the available options. To match any locale, pass in null.- Parameters:
templateLocale- the template to search for or null to match any localeoptions- the available locales to search from- Returns:
- Returns the best match from the available options, or the null if all matches fail
-
parseLocale
java.util.Locale parseLocale(java.lang.String localeStr)
Factory method to create a Locale from a lang_country_variant string.- Parameters:
localeStr- e.g. fr_FR- Returns:
- Returns the locale instance, or the
defaultif the string is invalid
-
registerResourceBundle
void registerResourceBundle(java.lang.String bundleBasePath)
Register a resource bundle.This should be the bundle base path eg, alfresco/messages/errors or, workspace://SpaceStore/app:company_home/app:dictionary/app:labels/cm:errors
Once registered the messages will be available via getMessage, assuming the bundle resource exists at the given path location.
- Parameters:
bundleBasePath- the bundle base path
-
unregisterResourceBundle
void unregisterResourceBundle(java.lang.String resBundlePath)
Unregister a resource bundleThis should be the bundle base path eg alfresco/messages/errors or workspace://SpaceStore/app:company_home/app:dictionary/app:labels/cm:errors
Once unregistered the messages will no longer be available via getMessage
- Parameters:
resBundlePath- the bundle base path
-
getRepoResourceBundle
java.util.ResourceBundle getRepoResourceBundle(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String path, java.util.Locale locale) throws java.io.IOExceptionGet message resource bundle from the repository note: also used by Web Client (ResourceBundleWrapper)- Parameters:
storeRef- store refpath- repository path (XPath)locale- locale- Returns:
- input stream
- Throws:
java.io.IOException
-
getRegisteredBundles
java.util.Set<java.lang.String> getRegisteredBundles()
Get set of registered message resource bundles- Returns:
- set of registered bundles
-
register
void register(MessageDeployer messageDeployer)
Register message deployer with message service- Parameters:
messageDeployer- MessageDeployer
-
getBaseBundleName
java.lang.String getBaseBundleName(java.lang.String resourceName)
-
-