Package io.goobi.viewer.messages
Class ViewerResourceBundle
java.lang.Object
java.util.ResourceBundle
io.goobi.viewer.messages.ViewerResourceBundle
ViewerResourceBundle class.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static LocaleConstantdefaultLocaleprotected static Map<Locale, ResourceBundle> ConstantlocalBundlesConstantreloadNeededMapFields inherited from class java.util.ResourceBundle
parent -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for ViewerResourceBundle.ViewerResourceBundle(Path localConfigPath) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcleanUpTranslation(String value) Removes the "zzz" marker from the given string.static voidCreates a local messages_xx.properties file for every locale in the Faces context, if not already present.Getter for the fieldallLocales.getAllLocales(jakarta.servlet.ServletContext servletContext) static LocaleGetter for the fielddefaultLocale.static LocalegetDefaultLocale(jakarta.servlet.ServletContext servletContext) static LocalegetDefaultLocaleFromFacesConfig(jakarta.servlet.ServletContext servletContext) static LocalegetDefaultLocaleFromFile(Path facesConfigPath) static LocaleReturns a locale for the configured fallback language.getKeys()getLocalesFromFacesConfig(jakarta.servlet.ServletContext servletContext) Get locales configured in faces-config, ordered by appearance in filegetLocalesFromFile(Path facesConfigPath) static FilegetLocalTranslationFile(String language) getMessagesValues(Locale locale, String keyPrefix) getMessagesValues.static StringgetTranslation(String key, Locale locale) getTranslation.static StringgetTranslation(String key, Locale locale, boolean useFallback) getTranslation.static StringgetTranslation(String key, Locale locale, boolean useFallback, boolean cleanup) static StringgetTranslation(String key, Locale locale, boolean useFallback, boolean reversePriority, boolean cleanup) getTranslation.static StringgetTranslation(String key, Locale inLocale, boolean useFallback, boolean returnKeyIfNoneFound, boolean reversePriority, boolean cleanup) getTranslation.protected static StringgetTranslation(String key, ResourceBundle fallbackBundle, ResourceBundle preferredBundle, boolean cleanup) Translation method with ResourceBundle parameters.static de.intranda.metadata.multilanguage.IMetadataValuegetTranslations(String key) Returns a Multilanguage metadata value containing all found translations for thekey, or the key itself if not translations were foundstatic de.intranda.metadata.multilanguage.IMetadataValuegetTranslations(String key, boolean allowKeyAsTranslation) static de.intranda.metadata.multilanguage.IMetadataValuegetTranslations(String key, List<Locale> locales, boolean allowKeyAsTranslation) static StringgetTranslationWithParameters(String key, Locale locale, boolean removeRemainingPlaceholders, String... params) getTranslationWithParameters.protected ObjecthandleGetObject(String key) This is the method that is called for HTML translations.static voidinit(jakarta.servlet.ServletContext servletContext) static booleanupdateLocalMessageKey(String key, String value, String language) Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
-
Field Details
-
localBundles
ConstantlocalBundles -
reloadNeededMap
ConstantreloadNeededMap -
defaultLocale
ConstantdefaultLocale
-
-
Constructor Details
-
ViewerResourceBundle
public ViewerResourceBundle()Constructor for ViewerResourceBundle.
-
ViewerResourceBundle
-
-
Method Details
-
getDefaultLocale
Getter for the field
defaultLocale.- Returns:
- a
Localeobject.
-
getFallbackLocale
Returns a locale for the configured fallback language. Does not use FacesContext.- Returns:
- Locale for the language code returned by the configuration getter
-
handleGetObject
This is the method that is called for HTML translations.- Specified by:
handleGetObjectin classResourceBundle
-
getTranslation
getTranslation.
-
getTranslationWithParameters
public static String getTranslationWithParameters(String key, Locale locale, boolean removeRemainingPlaceholders, String... params) getTranslationWithParameters.
-
translate
-
getTranslation
getTranslation.
-
getTranslation
public static String getTranslation(String key, Locale locale, boolean useFallback, boolean cleanup) - Parameters:
key-locale-useFallback-cleanup-- Returns:
- Translated message key
-
getTranslation
public static String getTranslation(String key, Locale locale, boolean useFallback, boolean reversePriority, boolean cleanup) getTranslation.
- Parameters:
key- Message key to translatelocale- Desired localeuseFallback- If true, get default locale translation if there is none for the given localereversePriority- If true, the global bundle will be checked first, then the localcleanup- If true, elements such as 'zzz' will be removed from the translation- Returns:
- Translated message key
-
getTranslation
public static String getTranslation(String key, Locale inLocale, boolean useFallback, boolean returnKeyIfNoneFound, boolean reversePriority, boolean cleanup) getTranslation.
- Parameters:
key- Message key to translateinLocale- Desired localeuseFallback- If true, get default locale translation if there is none for the given localereturnKeyIfNoneFound- If true, the key will be returned as translation value; null otherwisereversePriority- If true, the global bundle will be checked first, then the localcleanup- If true, elements such as 'zzz' will be removed from the translation- Returns:
- Translated message key
-
getTranslation
protected static String getTranslation(String key, ResourceBundle fallbackBundle, ResourceBundle preferredBundle, boolean cleanup) Translation method with ResourceBundle parameters. It can be overridden from inheriting classes which may pass their own bundles.- Parameters:
key- Message keyfallbackBundle- Fallback bundle if no value is found in preferredBundlepreferredBundle- Check for a translation in this bundle firstcleanup- If true, elements such as 'zzz' will be removed from the translation- Returns:
- Translated message key
-
cleanUpTranslation
Removes the "zzz" marker from the given string.- Parameters:
value- aStringobject.- Returns:
- Cleaned-up value
-
getMessagesValues
getMessagesValues.
-
getKeys
- Specified by:
getKeysin classResourceBundle
-
getTranslations
Returns a Multilanguage metadata value containing all found translations for thekey, or the key itself if not translations were found- Parameters:
key- the message key- Returns:
- A Multilanguage metadata value containing all found translations for the
key, or the key itself if not translations were found
-
getTranslations
public static de.intranda.metadata.multilanguage.IMetadataValue getTranslations(String key, boolean allowKeyAsTranslation) -
getTranslations
-
getAllLocales
Getter for the field
allLocales.- Returns:
- a
Listobject.
-
getAllLocales
- Parameters:
servletContext-- Returns:
- List of all configured
Locales
-
getDefaultLocale
- Parameters:
servletContext-- Returns:
- Default
Locale
-
getFacesLocales
-
getLocalesFromFacesConfig
Get locales configured in faces-config, ordered by appearance in file- Parameters:
servletContext-- Returns:
- a list of Locale objects, or null if the list could not be retrieved
-
getDefaultLocaleFromFacesConfig
- Parameters:
servletContext-- Returns:
- Default
Locale
-
createLocalMessageFiles
public static void createLocalMessageFiles()Creates a local messages_xx.properties file for every locale in the Faces context, if not already present. -
getLocalesFromFile
public static List<Locale> getLocalesFromFile(Path facesConfigPath) throws IOException, org.jdom2.JDOMException - Parameters:
facesConfigPath-- Returns:
Locales configured in given file path- Throws:
IOExceptionorg.jdom2.JDOMException
-
getDefaultLocaleFromFile
public static Locale getDefaultLocaleFromFile(Path facesConfigPath) throws IOException, org.jdom2.JDOMException - Parameters:
facesConfigPath-- Returns:
- Default
Localeconfigured in given file path - Throws:
IOExceptionorg.jdom2.JDOMException
-
init
public static void init(jakarta.servlet.ServletContext servletContext) - Parameters:
servletContext-
-
getAllKeys
- Returns:
- All message keys in the bundle
-
getAllLocalKeys
- Returns:
- Set of message keys from local messages_*.properties
-
updateLocalMessageKey
- Parameters:
key- Message keyvalue- Message valuelanguage- ISO 639-1 language code- Returns:
- true if file updated successfully; false otherwise
-
getLocalTranslationFile
-