org.mentawai.i18n
Class LocaleManager

java.lang.Object
  extended by org.mentawai.i18n.LocaleManager

public class LocaleManager
extends Object

Author:
Sergio Oliveira

Field Summary
static Locale DEFAULT_LOCALE
           
static boolean I18N_DEBUG
           
static long I18N_RELOAD_TIME
           
static String LANG_PARAM
           
 
Constructor Summary
LocaleManager()
           
 
Method Summary
static void add(Locale loc)
           
static void add(String loc)
           
static Locale decideLocale(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
static String formatDate(Locale loc, Date date)
           
static String formatDateTime(Locale loc, Date date)
           
static String formatTime(Locale loc, Date date)
           
static String getDateMask(Locale loc)
           
static String getDefaultDateMask()
           
static Locale getDefaultLocale()
           
static String getDefaultTimeMask()
           
static String getDir()
          Return the current dir for i18n files.
static int getId(Locale loc)
           
static String getLangCookieName(javax.servlet.http.HttpServletRequest req)
           
static Locale getLocale(javax.servlet.http.HttpServletRequest req)
           
static Locale getLocale(javax.servlet.http.HttpServletRequest req, boolean onlySupported)
           
static Locale getLocale(int id)
           
static Locale getLocaleFromString(String text)
           
static int[] getLocaleIds()
           
static Locale[] getLocales()
           
static String getMaster()
           
static SimpleDateFormat getSimpleDateFormat(Locale loc)
           
static SimpleDateFormat getSimpleDateFormat(String mask)
           
static SimpleDateFormat getSimpleTimeFormat(Locale loc)
           
static SimpleDateFormat getSimpleTimeFormat(String mask)
           
static Locale getSupportedLocale(Locale loc)
           
static Locale getSupportedLocale(Locale loc, boolean returnDefaultIfNotFound)
           
static Locale getSupportedLocale(Locale loc, Locale def)
           
static Locale getSupportedLocale(Locale loc, Locale def, boolean returnDefaultIfNotFound)
           
static Locale getSupportedLocale(String loc)
           
static Locale getSupportedLocale(String loc, boolean returnDefaultIfNotFound)
           
static String getTimeMask(Locale loc)
           
static boolean isSupportedLocale(Locale loc)
           
static boolean isSupportedLocale(String text)
           
static boolean isUseMasterForEverything()
           
static boolean isUsePrefixForActions()
           
static Set<Locale> scanLocales(String dir)
           
static Set<Locale> scanLocales(String dir, String filename)
           
static void setDateMask(Locale loc, String dateMask)
           
static void setDefaultDateMask(String defaultDateMask)
           
static void setDefaultTimeMask(String defaultTimeMask)
           
static void setDir(String directory)
          Set the directory from where to look for i18n files.
static void setMaster(String s)
           
static void setTimeMask(Locale loc, String timeMask)
           
static void setUseMasterForEverything(boolean useMaster)
          Deprecated. use useMasterI18N(boolean useMaster) instead
static void startLocaleScan()
           
static void stopLocaleScan()
           
static void useMasterI18N(boolean useMaster)
           
static void usePrefixForActions(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANG_PARAM

public static String LANG_PARAM

DEFAULT_LOCALE

public static Locale DEFAULT_LOCALE

I18N_RELOAD_TIME

public static long I18N_RELOAD_TIME

I18N_DEBUG

public static boolean I18N_DEBUG
Constructor Detail

LocaleManager

public LocaleManager()
Method Detail

usePrefixForActions

public static void usePrefixForActions(boolean b)

isUsePrefixForActions

public static boolean isUsePrefixForActions()

stopLocaleScan

public static void stopLocaleScan()

startLocaleScan

public static void startLocaleScan()

scanLocales

public static Set<Locale> scanLocales(String dir)
                               throws Throwable
Throws:
Throwable

scanLocales

public static Set<Locale> scanLocales(String dir,
                                      String filename)
                               throws Throwable
Throws:
Throwable

setUseMasterForEverything

public static void setUseMasterForEverything(boolean useMaster)
Deprecated. use useMasterI18N(boolean useMaster) instead

Since:
1.1.2

useMasterI18N

public static void useMasterI18N(boolean useMaster)
Since:
1.12

setDir

public static void setDir(String directory)
Set the directory from where to look for i18n files. Default directory is "i18n" on the root dir. ("/i18n") To change for WEB-INF/classes/i18n you can call: LocaleManager.setDir("WEB-INF/classes/i18n"); Notice that this method will also change the location of the master file, if and only if you never called the setMaster method!

Parameters:
directory - The new directory for the i18n files.
Since:
1.9

getDir

public static String getDir()
Return the current dir for i18n files.

Returns:
The current dir
Since:
1.9

isUseMasterForEverything

public static boolean isUseMasterForEverything()
Since:
1.1.2

add

public static void add(Locale loc)

setMaster

public static void setMaster(String s)

getMaster

public static String getMaster()

add

public static void add(String loc)

getDefaultLocale

public static Locale getDefaultLocale()

getLocales

public static Locale[] getLocales()

getLocaleIds

public static int[] getLocaleIds()

getLocaleFromString

public static Locale getLocaleFromString(String text)

isSupportedLocale

public static boolean isSupportedLocale(Locale loc)

isSupportedLocale

public static boolean isSupportedLocale(String text)

getLocale

public static Locale getLocale(int id)

getId

public static int getId(Locale loc)

getSupportedLocale

public static Locale getSupportedLocale(String loc,
                                        boolean returnDefaultIfNotFound)

getSupportedLocale

public static Locale getSupportedLocale(Locale loc,
                                        boolean returnDefaultIfNotFound)

getSupportedLocale

public static Locale getSupportedLocale(Locale loc)

getSupportedLocale

public static Locale getSupportedLocale(String loc)

getSupportedLocale

public static Locale getSupportedLocale(Locale loc,
                                        Locale def)

getSupportedLocale

public static Locale getSupportedLocale(Locale loc,
                                        Locale def,
                                        boolean returnDefaultIfNotFound)

getLocale

public static Locale getLocale(javax.servlet.http.HttpServletRequest req)

getLangCookieName

public static String getLangCookieName(javax.servlet.http.HttpServletRequest req)

decideLocale

public static Locale decideLocale(javax.servlet.http.HttpServletRequest req,
                                  javax.servlet.http.HttpServletResponse res)

getLocale

public static Locale getLocale(javax.servlet.http.HttpServletRequest req,
                               boolean onlySupported)

setDefaultDateMask

public static void setDefaultDateMask(String defaultDateMask)

getDefaultDateMask

public static String getDefaultDateMask()

setDateMask

public static void setDateMask(Locale loc,
                               String dateMask)

getDateMask

public static String getDateMask(Locale loc)

setDefaultTimeMask

public static void setDefaultTimeMask(String defaultTimeMask)

getDefaultTimeMask

public static String getDefaultTimeMask()

setTimeMask

public static void setTimeMask(Locale loc,
                               String timeMask)

getTimeMask

public static String getTimeMask(Locale loc)

formatDate

public static String formatDate(Locale loc,
                                Date date)

formatTime

public static String formatTime(Locale loc,
                                Date date)

formatDateTime

public static String formatDateTime(Locale loc,
                                    Date date)

getSimpleDateFormat

public static SimpleDateFormat getSimpleDateFormat(String mask)

getSimpleDateFormat

public static SimpleDateFormat getSimpleDateFormat(Locale loc)

getSimpleTimeFormat

public static SimpleDateFormat getSimpleTimeFormat(String mask)

getSimpleTimeFormat

public static SimpleDateFormat getSimpleTimeFormat(Locale loc)


Copyright © 2013. All Rights Reserved.