org.olat.core.util.i18n
Class I18nManager

java.lang.Object
  extended by org.olat.core.logging.LogDelegator
      extended by org.olat.core.manager.BasicManager
          extended by org.olat.core.util.i18n.I18nManager

public class I18nManager
extends BasicManager

Description:
I18nManager is responsible for internationalization issues, to store and load properties files in the available languages. see olat_config.xml for the languages offered. Log in as olat Administrator -> go to "test" tab, choose Language translation tool to have a web based translation tool available

Initial Date: 10.11.2004

Author:
Felix Jost

Field Summary
static int DEFAULT_BUNDLE_PRIORITY
           
static int DEFAULT_KEY_PRIORITY
           
static java.lang.String FILE_NOT_FOUND_ERROR_PREFIX
           
static java.lang.String I18N_DIRNAME
           
static java.lang.String IDENT_END_POSTFIX
           
static java.lang.String IDENT_PREFIX
           
static java.lang.String IDENT_START_POSTFIX
           
static java.io.FilenameFilter jarFileFilter
           
static java.lang.String METADATA_ANNOTATION_POSTFIX
           
static java.lang.String METADATA_BUNDLE_PRIORITY_KEY
           
static java.lang.String METADATA_KEY_PRIORITY_POSTFIX
           
static java.lang.String USESS_KEY_I18N_MARK_LOCALIZED_STRINGS
           
 
Method Summary
static void attachI18nInfoToThread(javax.servlet.http.HttpServletRequest hreq)
          Attache some data to thread local variables needed by the i18nManager.
 java.lang.String buildI18nFilename(java.util.Locale locale)
          Helper method to build i18n filenames from a given locale.
 java.lang.String buildI18nItemIdentifyer(java.lang.String bundleName, java.lang.String key)
          Helper method to build a unique identifyer for an i18n item from the given bundle name and key
 void copyLanguagesFromJar(java.io.File jarFile, java.util.Set<java.lang.String> toCopyI18nKeys)
          Copy the given set of languages from the given jar to the configured i18n source directories.
 int countBundles(java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Count the number of available bundles
 int countI18nItems(java.util.Locale locale, java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Count the i18n items in a bundle
 java.lang.String[] createLanguageFlagsCssClasses(java.lang.String[] languageKeys, java.lang.String additionalCssClass)
          Create a string array that contains the css markup for country flags
 java.io.File createLanguageJarFile(java.util.Set<java.lang.String> languageKeys, java.lang.String fileName)
          Create a jar file that contains the translations for the given languages.
 boolean createNewLanguage(java.lang.String localeKey, java.lang.String languageInEnglish, java.lang.String languageTranslated, java.lang.String authors)
           
 java.lang.String createOrigianlLocaleKeyForOverlay(java.util.Locale overlay)
          Calculate the language key from the given overlay locale without the locale (the original language before adding the overlay postfix)
 void deleteLanguage(java.lang.String deleteLangKey, boolean reallyDeleteIt)
          Method to delete an entire language.
 void deleteProperties(java.util.Locale locale, java.lang.String bundleName)
          Delete the given property file from disk
 java.util.List<I18nItem> findExistingAndMissingI18nItems(java.util.Locale referenceLocale, java.util.Locale targetLocale, java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Find all i18n items that exist in the source locale and the target locale
 java.util.List<I18nItem> findExistingI18nItems(java.util.Locale targetLocale, java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Find all i18n items that exist in the target locale
 java.util.List<I18nItem> findI18nItemsByKeySearch(java.lang.String searchString, java.util.Locale searchLocale, java.util.Locale targetLocale, java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Find all i18n items that contain the given search string in their key.
 java.util.List<I18nItem> findI18nItemsByValueSearch(java.lang.String searchString, java.util.Locale searchLocale, java.util.Locale targetLocale, java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Find all i18n items that contain a given search string in their value.
 java.util.List<I18nItem> findMissingI18nItems(java.util.Locale referenceLocale, java.util.Locale targetLocale, java.lang.String limitToBundleName, boolean includeBundlesChildren)
          Find all i18n items that exist in the source locale but not in the target locale
 java.lang.String getAnnotation(I18nItem i18nItem)
          Get the annotation for this i18n item.
 java.util.Locale getCurrentThreadLocale()
          Get the locale used in the current thread or the default locale if no locale is set.
 java.util.Map<java.lang.String,java.lang.String> getEnabledLanguagesTranslated()
          Get a map of the enabled language keys as keys with their translated name as values.
 I18nItem getI18nItem(java.lang.String bundleName, java.lang.String key, java.util.Locale locale)
          Factory method to create a single i18n item
static I18nManager getInstance()
           
 java.lang.String getJSTranslatorData(java.util.Locale locale, java.lang.String bundleName)
          Get the javascript translator data for this locale.
 java.lang.String getLanguageAuthor(java.lang.String languageKey)
          Get the authors of the language as they entered themselfes in the translation tool.
 java.lang.String getLanguageInEnglish(java.lang.String languageKey, boolean overlayEnabled)
          Translate the given language key to english (for administrative interface).
 java.lang.String getLanguageTranslated(java.lang.String languageKey, boolean overlayEnabled)
          Translate the given language key to the language itself.
 java.lang.Long getLastModifiedDate(java.util.Locale locale, java.lang.String bundleName)
          Get the last modified date of this bundle and locale
 java.lang.String getLocaleKey(java.util.Locale locale)
          Calculate the locale key that identifies the given locale.
 java.util.Locale getLocaleOrDefault(java.lang.String localeKey)
           
 java.util.Locale getLocaleOrNull(java.lang.String localeKey)
           
 java.lang.String getLocalizedString(I18nItem i18nItem, java.lang.Object[] args)
          Get the translated value for a given i18n item.
 java.lang.String getLocalizedString(java.lang.String bundleName, java.lang.String key, java.lang.Object[] args, java.util.Locale locale, boolean overlayEnabled, boolean fallBackToDefaultLocale)
          Get a localized string.
 java.lang.String getLocalizedString(java.lang.String bundleName, java.lang.String key, java.lang.Object[] args, java.util.Locale locale, boolean overlayEnabled, boolean fallBackToDefaultLocale, boolean fallBackToFallbackLocale, boolean resolveRecursively, int recursionLevel)
           
 java.io.File getPropertiesFile(java.util.Locale locale, java.lang.String bundleName, java.io.File sourceDir)
          Get the property file for a given locale and bundle.
 java.util.Properties getPropertiesWithoutResolvingRecursively(java.util.Locale locale, java.lang.String bundleName)
           
 java.util.Properties getResolvedProperties(java.util.Locale locale, java.lang.String bundleName)
           
 boolean isCachingEnabled()
           
 boolean isCurrentThreadMarkLocalizedStringsEnabled()
          Check if this thread should be rendered using markup arround the localized strings
static void remove18nInfoFromThread()
          Remove any thread local data that was set using the attachI18nInfoToThread() method
 java.util.Set<java.lang.String> sarchForAvailableLanguagesInJarFile(java.io.File jarFile, boolean checkForExecutables)
          Searches within a jar file for available languages.
 void saveOrUpdateI18nItem(I18nItem i18nItem, java.lang.String value)
          Save the given value for the given i18nItem
 void saveOrUpdateProperties(java.util.Properties properties, java.util.Locale locale, java.lang.String bundleName)
          Create a new property file or update an existing property file form the given propeties object
 void setAnnotation(I18nItem i18nItem, java.lang.String annotation)
           
 void setBundlePriority(java.lang.String bundleName, int priority)
          Set the bundle priority for a specific bundle.
 void setCachingEnabled(boolean useCache)
          Method to enable / disable caching of loaded and resolved bundles
 void setKeyPriority(java.lang.String bundleName, java.lang.String key, int priority)
          Set the key priority within the bundle.
 void setMarkLocalizedStringsEnabled(UserSession usess, boolean isMarkLocalizedStringsEnabled)
          Set the
 void sortBundles(java.util.List<java.lang.String> bundleNames, boolean afterBundlePriorities)
          Sort the bundle names alphabetically or by using the bundle priorities.
 void sortI18nItems(java.util.List<I18nItem> i18nItems, boolean afterBundlePriorities, boolean afterKeyPriorities)
          Sort a list of i18n items.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_NOT_FOUND_ERROR_PREFIX

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

USESS_KEY_I18N_MARK_LOCALIZED_STRINGS

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

IDENT_END_POSTFIX

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

IDENT_START_POSTFIX

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

IDENT_PREFIX

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

METADATA_ANNOTATION_POSTFIX

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

METADATA_BUNDLE_PRIORITY_KEY

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

METADATA_KEY_PRIORITY_POSTFIX

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

I18N_DIRNAME

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

DEFAULT_BUNDLE_PRIORITY

public static final int DEFAULT_BUNDLE_PRIORITY
See Also:
Constant Field Values

DEFAULT_KEY_PRIORITY

public static final int DEFAULT_KEY_PRIORITY
See Also:
Constant Field Values

jarFileFilter

public static java.io.FilenameFilter jarFileFilter
Method Detail

getInstance

public static I18nManager getInstance()
Returns:
the manager

getLocalizedString

public java.lang.String getLocalizedString(I18nItem i18nItem,
                                           java.lang.Object[] args)
Get the translated value for a given i18n item. The returned translation is the pure translated value: no fallback mechanism, no overlay mechanism, no recursive resolving

Parameters:
i18nItem -
args - the arguments used in this item or NULL if no such arguments needed
Returns:
The translated string.

getLocalizedString

public java.lang.String getLocalizedString(java.lang.String bundleName,
                                           java.lang.String key,
                                           java.lang.Object[] args,
                                           java.util.Locale locale,
                                           boolean overlayEnabled,
                                           boolean fallBackToDefaultLocale)
Get a localized string. The translation order is as follows:
  1. a) Look in overlay of given locale if overlay is configured
  2. b) Look in given locale
  3. c) Fallback to overlay of locale without variant if given locale has a variant
  4. d) Fallback to locale without variant if given locale has a variant
  5. e) Fallback to overlay of locale without country if given locale has a country
  6. f) Fallback to locale without country if given locale has a country
  7. g) Fallback to overlay of default locale
  8. h) Fallback to default locale
  9. i) Fallback to overlay of reference and fallback locale
  10. j) Fallback to reference and fallback locale
  11. k) Print error message

Parameters:
bundlePath - The bundle path
key - The key too lookup
args - The arguments used while formatting or NULL if no arguments
locale - The locale to use
overlayEnabled - true: lookup first in overlay; false: don't lookup in overlay
fallBackToDefaultLocale - true: fallback to default enabled; false: no fallback
Returns:
The formatted message in the given language or NULL if no fallback possible and not found

getLocalizedString

public java.lang.String getLocalizedString(java.lang.String bundleName,
                                           java.lang.String key,
                                           java.lang.Object[] args,
                                           java.util.Locale locale,
                                           boolean overlayEnabled,
                                           boolean fallBackToDefaultLocale,
                                           boolean fallBackToFallbackLocale,
                                           boolean resolveRecursively,
                                           int recursionLevel)

getAnnotation

public java.lang.String getAnnotation(I18nItem i18nItem)
Get the annotation for this i18n item. There exists only one annotation per key, it is shared between all languages

Parameters:
i18nItem -
Returns:
the annotation or NULL if no annotation exists

setAnnotation

public void setAnnotation(I18nItem i18nItem,
                          java.lang.String annotation)

findExistingI18nItems

public java.util.List<I18nItem> findExistingI18nItems(java.util.Locale targetLocale,
                                                      java.lang.String limitToBundleName,
                                                      boolean includeBundlesChildren)
Find all i18n items that exist in the target locale

Parameters:
targetLocale - The locale that must be translated
limitToBundleName -
includeBundlesChildren - true: also find the keys in the bundles children; false: find only the keys in the exact bundle name. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:
List of i18n items

findMissingI18nItems

public java.util.List<I18nItem> findMissingI18nItems(java.util.Locale referenceLocale,
                                                     java.util.Locale targetLocale,
                                                     java.lang.String limitToBundleName,
                                                     boolean includeBundlesChildren)
Find all i18n items that exist in the source locale but not in the target locale

Parameters:
referenceLocale - The locale that serves as the prototype
targetLocale - The locale that must be translated
limitToBundleName -
includeBundlesChildren - true: also find the keys in the bundles children; false: find only the keys in the exact bundle name. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:
List of i18n items

findExistingAndMissingI18nItems

public java.util.List<I18nItem> findExistingAndMissingI18nItems(java.util.Locale referenceLocale,
                                                                java.util.Locale targetLocale,
                                                                java.lang.String limitToBundleName,
                                                                boolean includeBundlesChildren)
Find all i18n items that exist in the source locale and the target locale

Parameters:
referenceLocale - The locale that serves as the prototype
targetLocale - The locale that must be translated
limitToBundleName -
includeBundlesChildren - true: also find the keys in the bundles children; false: find only the keys in the exact bundle name. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:
List of i18n items

findI18nItemsByValueSearch

public java.util.List<I18nItem> findI18nItemsByValueSearch(java.lang.String searchString,
                                                           java.util.Locale searchLocale,
                                                           java.util.Locale targetLocale,
                                                           java.lang.String limitToBundleName,
                                                           boolean includeBundlesChildren)
Find all i18n items that contain a given search string in their value. The search string can contain '*' as a wild-card

Parameters:
searchString - The search string, case-insensitive. * are treated as wild-cards
searchLocale - The locale where to search
targetLocale - The locale that should be used as result target
limitToBundleName - The name of a bundle in which the keys should be searched or NULL to search in all bundles
includeBundlesChildren - true: also find the keys in the bundles children; false: find only the keys in the exact bundle name. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:
List of i18n items

findI18nItemsByKeySearch

public java.util.List<I18nItem> findI18nItemsByKeySearch(java.lang.String searchString,
                                                         java.util.Locale searchLocale,
                                                         java.util.Locale targetLocale,
                                                         java.lang.String limitToBundleName,
                                                         boolean includeBundlesChildren)
Find all i18n items that contain the given search string in their key.

Parameters:
searchString - The search string, case-insensitive
searchLocale - The language to search in for
targetLocale - The locale that should be used as result target
limitToBundleName - The name of a bundle in which the keys should be searched or NULL to search in all bundles
includeBundlesChildren - true: also find the keys in the bundles children; false: find only the keys in the exact bundle name. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:
List of i18n items

getI18nItem

public I18nItem getI18nItem(java.lang.String bundleName,
                            java.lang.String key,
                            java.util.Locale locale)
Factory method to create a single i18n item

Parameters:
bundleName -
key -
locale -
Returns:

sortI18nItems

public void sortI18nItems(java.util.List<I18nItem> i18nItems,
                          boolean afterBundlePriorities,
                          boolean afterKeyPriorities)
Sort a list of i18n items. The list sorted alphabetically:
  1. if afterBundlePriorities=true, the bundles are sorted by bundle priority
  2. if afterBundlePriorities=true and afterKeyPriorities=true, the bundles are sorted by bundle and then by key priority
  3. within the priorities, the bundles and keys are sorted alphabetically

Parameters:
i18nItems -
afterBundlePriorities -
afterKeyPriorities -

sortBundles

public void sortBundles(java.util.List<java.lang.String> bundleNames,
                        boolean afterBundlePriorities)
Sort the bundle names alphabetically or by using the bundle priorities. Take care when sorting a list you previously got from the Module - this list is shared with all other users. Instead, use the sorted version

Parameters:
bundleNames -
afterBundlePriorities -

saveOrUpdateI18nItem

public void saveOrUpdateI18nItem(I18nItem i18nItem,
                                 java.lang.String value)
Save the given value for the given i18nItem

Parameters:
i18nItem -
value -

countI18nItems

public int countI18nItems(java.util.Locale locale,
                          java.lang.String limitToBundleName,
                          boolean includeBundlesChildren)
Count the i18n items in a bundle

Parameters:
locale -
limitToBundleName - The name of a bundle for which the keys should be counted or NULL to count keys in every available bundle
includeBundlesChildren - true: also count the keys of the bundles children; false: count only the keys of the exact bundle name. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:

countBundles

public int countBundles(java.lang.String limitToBundleName,
                        boolean includeBundlesChildren)
Count the number of available bundles

Parameters:
limitToBundleName - The name of a bundle or NULL to count every available bundle
includeBundlesChildren - true: also count the bundles children; false: count only the exact bundle name which will always be 1. When limitToBundeName is set to NULL the includeBundlesChildren will always be set to true
Returns:

getPropertiesWithoutResolvingRecursively

public java.util.Properties getPropertiesWithoutResolvingRecursively(java.util.Locale locale,
                                                                     java.lang.String bundleName)
Parameters:
locale -
bundleName -
Returns:
the properties for the given locale and bundlename. When no file is found, an emtpy properties object will be returned

getResolvedProperties

public java.util.Properties getResolvedProperties(java.util.Locale locale,
                                                  java.lang.String bundleName)

saveOrUpdateProperties

public void saveOrUpdateProperties(java.util.Properties properties,
                                   java.util.Locale locale,
                                   java.lang.String bundleName)
Create a new property file or update an existing property file form the given propeties object

Parameters:
properties - The properties to persis
locale - The locale of the properties
bundleName - The properties bundle

deleteProperties

public void deleteProperties(java.util.Locale locale,
                             java.lang.String bundleName)
Delete the given property file from disk

Parameters:
locale -
bundleName -

getJSTranslatorData

public java.lang.String getJSTranslatorData(java.util.Locale locale,
                                            java.lang.String bundleName)
Get the javascript translator data for this locale. The generated code is cached in a VM scope. The entry is removed from the cache whenever something on the property file changed
This method should only be called by the JSTranslatorMapper. If you need localized data in your javascript code use the following code snipplet: ; <script type='text/javascript'> var translator = b_jsTranslatorFactory.getTranslator('de', 'org.olat.core'); alert(translator.translate('warn.beta.feature')); </script>

Parameters:
locale -
bundleName -
Returns:

getLastModifiedDate

public java.lang.Long getLastModifiedDate(java.util.Locale locale,
                                          java.lang.String bundleName)
Get the last modified date of this bundle and locale

Parameters:
locale -
bundleName -
Returns:

getLocaleOrDefault

public java.util.Locale getLocaleOrDefault(java.lang.String localeKey)
Parameters:
localeKey - the locale in String form. For the moment we only accept locales with either a language ("de"), a language and a country ("de_CH"), or a language and a country and a variant ("de_CH_bern").

Overlay locales are not not accepted

If localeKey is null, the default locale is used.

Returns:
the locale given the localeKey as returned by the Locale.toString() method, or the default locale if the language was not found

getLocaleOrNull

public java.util.Locale getLocaleOrNull(java.lang.String localeKey)
Parameters:
localeKey - the locale in String form. For the moment we only accept locales with either a language ("de"), a language and a country ("de_CH"), or a language and a country and a variant ("de_CH_bern").

In addition, all overlay locales are also accepted

If localeKey is null, null is returned

Returns:
the locale given the localeKey as returned by the Locale.toString() method, or if no language was found

getLanguageTranslated

public java.lang.String getLanguageTranslated(java.lang.String languageKey,
                                              boolean overlayEnabled)
Translate the given language key to the language itself. This is used in language selection boxes where each language is labeled in their language. This method uses the getLanguageInEnglish() method as a fallback in case the translation could not be found.

Parameters:
languageKey -
Returns:
e.g. "Deutsch" for input de

getEnabledLanguagesTranslated

public java.util.Map<java.lang.String,java.lang.String> getEnabledLanguagesTranslated()
Get a map of the enabled language keys as keys with their translated name as values. The language list uses the overlay feature to modify the language name when the overlay is configured.

Returns:

getLanguageInEnglish

public java.lang.String getLanguageInEnglish(java.lang.String languageKey,
                                             boolean overlayEnabled)
Translate the given language key to english (for administrative interface). This method fallbacks to the language key and never returns an error message

Parameters:
languageKey -
Returns:
e.g. "German" for input de

getLanguageAuthor

public java.lang.String getLanguageAuthor(java.lang.String languageKey)
Get the authors of the language as they entered themselfes in the translation tool. This reads the key org.olat.core:this.language.translator.names

Parameters:
languageKey -
Returns:
e.g. "Marion Weber, University of Zuerich"

createLanguageFlagsCssClasses

public java.lang.String[] createLanguageFlagsCssClasses(java.lang.String[] languageKeys,
                                                        java.lang.String additionalCssClass)
Create a string array that contains the css markup for country flags

Parameters:
languageKeys - The source array of language keys
additionalCssClass - additional CSS classes that should be added or NULL. E.g. you could use 'b_with_small_icon_left'
Returns:

attachI18nInfoToThread

public static void attachI18nInfoToThread(javax.servlet.http.HttpServletRequest hreq)
Attache some data to thread local variables needed by the i18nManager. Make sure you call remove18nInfoFromThread() when the thread is finished!

Parameters:
hreq - The http servlet request

remove18nInfoFromThread

public static void remove18nInfoFromThread()
Remove any thread local data that was set using the attachI18nInfoToThread() method


getCurrentThreadLocale

public java.util.Locale getCurrentThreadLocale()
Get the locale used in the current thread or the default locale if no locale is set. Usually this is the users logged in Locale

Returns:
the locale of this thread

setMarkLocalizedStringsEnabled

public void setMarkLocalizedStringsEnabled(UserSession usess,
                                           boolean isMarkLocalizedStringsEnabled)
Set the

Parameters:
usess -
isMarkLocalizedStringsEnabled -

isCurrentThreadMarkLocalizedStringsEnabled

public boolean isCurrentThreadMarkLocalizedStringsEnabled()
Check if this thread should be rendered using markup arround the localized strings

Returns:

setBundlePriority

public void setBundlePriority(java.lang.String bundleName,
                              int priority)
Set the bundle priority for a specific bundle. Does not update the priorities of the children bundles, but note that when reading priorities of children that do not have a priority set, the system will degregate to the next parent that does have a priority set. Thus, it is not necessary to set children bundles priorities unless you want to set a higher priority.

Use priorities as follows:

If no priority is defined, the standard priority of 500 is used

Parameters:
bundleName -
priority -

setKeyPriority

public void setKeyPriority(java.lang.String bundleName,
                           java.lang.String key,
                           int priority)
Set the key priority within the bundle. The smaller the number, the higher is the priority. Higher priority items will appear on top of the list of to be translated keys

Priorities should be between 000 (hight prio, begin of list) and 999 (low prio, end of list)

If no priority is used, the standard priority of 500 is used

Parameters:
bundleName -
key -
priority -

setCachingEnabled

public void setCachingEnabled(boolean useCache)
Method to enable / disable caching of loaded and resolved bundles

Parameters:
useCache -

isCachingEnabled

public boolean isCachingEnabled()
Returns:
true: manager uses cache; false: manager always reads from filesystem

buildI18nFilename

public java.lang.String buildI18nFilename(java.util.Locale locale)
Helper method to build i18n filenames from a given locale. E.g. when locale=de_CH, the resulting i18n file name will be LocalStrings_de_CH.properties

This method will check if the locale is an overlay locale and remove unnecessary white space

Parameters:
locale -
Returns:

getLocaleKey

public java.lang.String getLocaleKey(java.util.Locale locale)
Calculate the locale key that identifies the given locale. Adds support for the overlay mechanism.

Parameters:
locale -
Returns:

createOrigianlLocaleKeyForOverlay

public java.lang.String createOrigianlLocaleKeyForOverlay(java.util.Locale overlay)
Calculate the language key from the given overlay locale without the locale (the original language before adding the overlay postfix)

Parameters:
overlay -
Returns:
The original language key or NULL if not found

buildI18nItemIdentifyer

public java.lang.String buildI18nItemIdentifyer(java.lang.String bundleName,
                                                java.lang.String key)
Helper method to build a unique identifyer for an i18n item from the given bundle name and key

Parameters:
bundleName -
key -
Returns:

sarchForAvailableLanguagesInJarFile

public java.util.Set<java.lang.String> sarchForAvailableLanguagesInJarFile(java.io.File jarFile,
                                                                           boolean checkForExecutables)
Searches within a jar file for available languages.

Parameters:
jarFile -
checkForExecutables - true: check if jar contains java or class files and return an empty set if such executable files are found; false don't check or care
Returns:
Set of language keys, can be empty but never null

copyLanguagesFromJar

public void copyLanguagesFromJar(java.io.File jarFile,
                                 java.util.Set<java.lang.String> toCopyI18nKeys)
Copy the given set of languages from the given jar to the configured i18n source directories. This method can only be called in a translation server environment.

Parameters:
jarFile -
toCopyI18nKeys -

getPropertiesFile

public java.io.File getPropertiesFile(java.util.Locale locale,
                                      java.lang.String bundleName,
                                      java.io.File sourceDir)
Get the property file for a given locale and bundle. If the locale is null, the metadata for this bundle are returned instead.

Parameters:
locale - the locale or NULL to get the bundle metadata file
bundleName -
sourceDir - the source directory where to search for the properties file
Returns:
a file object. The file might not exist, but the mehod never return NULL!

createNewLanguage

public boolean createNewLanguage(java.lang.String localeKey,
                                 java.lang.String languageInEnglish,
                                 java.lang.String languageTranslated,
                                 java.lang.String authors)

deleteLanguage

public void deleteLanguage(java.lang.String deleteLangKey,
                           boolean reallyDeleteIt)
Method to delete an entire language.

Parameters:
deleteLangKey -
true: - really delete the language; false: dry run with console logging

createLanguageJarFile

public java.io.File createLanguageJarFile(java.util.Set<java.lang.String> languageKeys,
                                          java.lang.String fileName)
Create a jar file that contains the translations for the given languages.

Note that this file is created in a temporary place in olatdata/tmp. It is in the responsibility of the caller of this method to remove the file when not needed anymore.

Parameters:
languageKeys -
fileName - the name of the file.
Returns:
The file handle to the created file or NULL if no such file could be created (e.g. there already exists a file with this file name)