org.olat.core.util.i18n
Class I18nModule

java.lang.Object
  extended by org.olat.core.logging.LogDelegator
      extended by org.olat.core.configuration.AbstractOLATModule
          extended by org.olat.core.util.i18n.I18nModule
All Implemented Interfaces:
OLATModule, GenericEventListener

public class I18nModule
extends AbstractOLATModule

Description:

The I18nModule initializes the localization infrastructure. It offers configuration options to define the default language, the available and enabled languages etc.

Initial Date: 28.08.2008

Author:
Florian Gnaegi, frentix GmbH, http://www.frentix.com

Field Summary
static java.lang.String GUI_PREFS_COMPARE_LANG_ENABLED
           
static java.lang.String GUI_PREFS_INLINE_TRANSLATION_ENABLED
           
static java.lang.String GUI_PREFS_PREFERRED_COMPARE_LANG
           
static java.lang.String GUI_PREFS_PREFERRED_REFERENCE_LANG
           
static java.io.File LANG_CUSTOMIZING_DIRECTORY
           
static java.io.File LANG_OVERLAY_DIRECTORY
           
static java.io.File LANG_PACKS_DIRECTORY
           
static java.lang.String LOCAL_STRINGS_FILE_POSTFIX
           
static java.lang.String LOCAL_STRINGS_FILE_PREFIX
           
static java.lang.String SCHEDULER_NAME
           
 
Constructor Summary
I18nModule()
          Used by framework startup mechanism, don't call this yourself
 
Method Summary
 void destroy()
          Destroy the module resources.
 void event(Event event)
           
static java.util.Map<java.lang.String,java.util.Locale> getAllLocales()
           
static java.lang.String getApplicationFallbackBundle()
           
static java.util.Set<java.lang.String> getAvailableLanguageKeys()
           
static java.lang.String getBrasatoFallbackBundle()
           
static java.util.List<java.lang.String> getBundleNamesContainingI18nFiles()
           
static java.util.Locale getDefaultLocale()
           
static java.util.Set<java.lang.String> getEnabledLanguageKeys()
           
static java.util.Locale getFallbackLocale()
           
static java.util.Set<java.lang.String> getOverlayLanguageKeys()
           
static java.util.Map<java.util.Locale,java.util.Locale> getOverlayLocales()
           
static java.lang.String getOverlayName()
          Returns the overlay name or NULL if not configured.
static java.io.File getPropertyFilesBaseDir(java.util.Locale locale, java.lang.String bundleName)
          Get the base source directory for the given language where the language files for this bundle are stored
static java.util.Set<java.lang.String> getTranslatableLanguageKeys()
           
static java.util.List<java.lang.String> getTransToolReferenceLanguages()
           
static boolean isOverlayEnabled()
          Checks if the overlay mechanism is enabled.
static boolean isTransToolEnabled()
           
static void reInitialize()
          Reinitialize the entire i18n system
static void setDefaultLocale(java.util.Locale newDefaultLocale)
          Method to set new default locale
static void setEnabledLanguageKeys(java.util.Set<java.lang.String> newEnabledLangKeys)
          Set the languages that are enabled on the system.
 
Methods inherited from class org.olat.core.configuration.AbstractOLATModule
init
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_STRINGS_FILE_PREFIX

public static final java.lang.String LOCAL_STRINGS_FILE_PREFIX
See Also:
Constant Field Values

LOCAL_STRINGS_FILE_POSTFIX

public static final java.lang.String LOCAL_STRINGS_FILE_POSTFIX
See Also:
Constant Field Values

LANG_CUSTOMIZING_DIRECTORY

public static final java.io.File LANG_CUSTOMIZING_DIRECTORY

LANG_PACKS_DIRECTORY

public static final java.io.File LANG_PACKS_DIRECTORY

LANG_OVERLAY_DIRECTORY

public static final java.io.File LANG_OVERLAY_DIRECTORY

SCHEDULER_NAME

public static final java.lang.String SCHEDULER_NAME
See Also:
Constant Field Values

GUI_PREFS_PREFERRED_COMPARE_LANG

public static final java.lang.String GUI_PREFS_PREFERRED_COMPARE_LANG
See Also:
Constant Field Values

GUI_PREFS_PREFERRED_REFERENCE_LANG

public static final java.lang.String GUI_PREFS_PREFERRED_REFERENCE_LANG
See Also:
Constant Field Values

GUI_PREFS_COMPARE_LANG_ENABLED

public static final java.lang.String GUI_PREFS_COMPARE_LANG_ENABLED
See Also:
Constant Field Values

GUI_PREFS_INLINE_TRANSLATION_ENABLED

public static final java.lang.String GUI_PREFS_INLINE_TRANSLATION_ENABLED
See Also:
Constant Field Values
Constructor Detail

I18nModule

public I18nModule()
Used by framework startup mechanism, don't call this yourself

Method Detail

destroy

public void destroy()
Description copied from class: AbstractOLATModule
Destroy the module resources. Called by the framework at shutdown time

Specified by:
destroy in interface OLATModule
Overrides:
destroy in class AbstractOLATModule
See Also:
OLATModule.destroy()

getDefaultLocale

public static java.util.Locale getDefaultLocale()
Returns:
The default locale configured for this web app

setDefaultLocale

public static void setDefaultLocale(java.util.Locale newDefaultLocale)
Method to set new default locale

Parameters:
newDefaultLocale -

getFallbackLocale

public static java.util.Locale getFallbackLocale()
Returns:
The locale that is used when a string is not found in any other locale

getAvailableLanguageKeys

public static java.util.Set<java.lang.String> getAvailableLanguageKeys()
Returns:
as keys: a Set of Strings with the supported languages (e.g. de, de_CH, en, ...). those are the languages that are installed. See the enabled languages to get the list of languages that are enabled to be used

getTranslatableLanguageKeys

public static java.util.Set<java.lang.String> getTranslatableLanguageKeys()
Returns:
A set of language keys that can be translated by the translation tool. Theses are the languages that are available in the source form. Languages embedded in jars can't be edited.

getAllLocales

public static java.util.Map<java.lang.String,java.util.Locale> getAllLocales()
Returns:
the map (with dummy value) of all languages including overlayLocales (as a String)

getOverlayLocales

public static java.util.Map<java.util.Locale,java.util.Locale> getOverlayLocales()
Returns:
The lookup map of the overlay locales. Key: the locale; value: the corresponding overlay

getEnabledLanguageKeys

public static java.util.Set<java.lang.String> getEnabledLanguageKeys()
Returns:
as keys: a List of Strings with the supported languages (e.g. de, de_CH, en, ...). those are the languages which can be chosen by the user

getOverlayLanguageKeys

public static java.util.Set<java.lang.String> getOverlayLanguageKeys()
Returns:
as keys: a List of Strings with the supported languages overlay keys

setEnabledLanguageKeys

public static void setEnabledLanguageKeys(java.util.Set<java.lang.String> newEnabledLangKeys)
Set the languages that are enabled on the system. The change affects the system immediately and is persisted in the olatdata/system/configuration

Parameters:
newEnabledLangKeys -

getTransToolReferenceLanguages

public static java.util.List<java.lang.String> getTransToolReferenceLanguages()
Returns:
A list of language keys that are reference and fallback languages

getBundleNamesContainingI18nFiles

public static java.util.List<java.lang.String> getBundleNamesContainingI18nFiles()
Returns:
All bundles that contain a _i18n directory with translation files

getBrasatoFallbackBundle

public static java.lang.String getBrasatoFallbackBundle()
Returns:
The bundle name that contains the commonly used translations from the brasato framework

getApplicationFallbackBundle

public static java.lang.String getApplicationFallbackBundle()
Returns:
The bundle name that contains the commonly used translations from the application

isOverlayEnabled

public static boolean isOverlayEnabled()
Checks if the overlay mechanism is enabled. The overlay is similar to the locale variant, but adds another layer on top of it.

Returns:
true: enabled; false: disabled

getOverlayName

public static java.lang.String getOverlayName()
Returns the overlay name or NULL if not configured. For an overlay file with the name 'LocalStrings_de__VENDOR.properties' it will return 'VENDOR'

Returns:
name of the overlay

isTransToolEnabled

public static boolean isTransToolEnabled()
Returns:
true: enable the translation tool; false: disable the translation tool

getPropertyFilesBaseDir

public static java.io.File getPropertyFilesBaseDir(java.util.Locale locale,
                                                   java.lang.String bundleName)
Get the base source directory for the given language where the language files for this bundle are stored

Parameters:
locale -
bundleName -
Returns:
The file or null if the language is not read-write configured

reInitialize

public static void reInitialize()
Reinitialize the entire i18n system


event

public void event(Event event)
Specified by:
event in interface GenericEventListener
Overrides:
event in class AbstractOLATModule
See Also:
AbstractOLATModule.event(org.olat.core.gui.control.Event)