|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object velosurf.web.l10n.HTTPLocalizerTool velosurf.web.l10n.SimpleDBLocalizer
public class SimpleDBLocalizer
A basic database based Localizer implementation.
The following toolbox.xml
parameters are available:
localized-table
: the name of the table containing localized strings (default: "localized
").id-field
: the name of the field containing the string id (default: "id
").locale-field
: the name of the field containing the ISO locale code (default: "locale
").string-field
: the name of the field containing the lcoalized string (default: "string
").You can find on the web the list of ISO Language Codes and the list of ISO Country Codes.
Field Summary | |
---|---|
private java.util.Map |
config
tool configuration. |
private java.util.Map<java.lang.Object,java.lang.String> |
currentStrings
map (id -> localized) for the current locale. |
private static java.lang.String |
ID_FIELD_DEFAULT
default id fied name. |
private static java.lang.String |
ID_FIELD_KEY
id field name parameter key. |
private static java.lang.String |
idField
id field name. |
private static boolean |
initialized
initialization status. |
private static java.lang.String |
LOCALE_FIELD_DEFAULT
default locale field name. |
private static java.lang.String |
LOCALE_FIELD_KEY
locale field name parameter key. |
private static java.lang.String |
localeField
locale field name. |
private static java.util.Map<java.util.Locale,java.util.Map<java.lang.Object,java.lang.String>> |
localeStrings
map locale -> (id -> localized). |
private static java.lang.String |
LOCALIZED_TABLE_DEFAULT
default localized table name. |
private static java.lang.String |
LOCALIZED_TABLE_KEY
localized table name parameter key. |
private static java.lang.String |
localizedTable
localized table name. |
private static java.lang.String |
STRING_FIELD_DEFAULT
default localized string field name. |
private static java.lang.String |
STRING_FIELD_KEY
localized string field name parameter key. |
private static java.lang.String |
stringField
localized string field name. |
Fields inherited from class velosurf.web.l10n.HTTPLocalizerTool |
---|
locale |
Constructor Summary | |
---|---|
SimpleDBLocalizer()
Constructor. |
Method Summary | |
---|---|
void |
configure(java.util.Map config)
Configure this tool. |
java.lang.String |
get(java.lang.Object id)
Localized message getter. |
boolean |
hasLocale(java.util.Locale locale)
Check for the presence of a locale. |
void |
init(java.lang.Object initData)
Initialize this tool. |
private static void |
readLocales(javax.servlet.ServletContext ctx)
read localized messages into memory. |
void |
setLocale(java.util.Locale locale)
Locale setter. |
Methods inherited from class velosurf.web.l10n.HTTPLocalizerTool |
---|
checkLocaleChange, get, getBestLocale, getLocale |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String LOCALIZED_TABLE_KEY
private static final java.lang.String ID_FIELD_KEY
private static final java.lang.String LOCALE_FIELD_KEY
private static final java.lang.String STRING_FIELD_KEY
private static final java.lang.String LOCALIZED_TABLE_DEFAULT
private static final java.lang.String ID_FIELD_DEFAULT
private static final java.lang.String LOCALE_FIELD_DEFAULT
private static final java.lang.String STRING_FIELD_DEFAULT
private static java.lang.String localizedTable
private static java.lang.String idField
private static java.lang.String localeField
private static java.lang.String stringField
private static boolean initialized
private static java.util.Map<java.util.Locale,java.util.Map<java.lang.Object,java.lang.String>> localeStrings
private java.util.Map<java.lang.Object,java.lang.String> currentStrings
private java.util.Map config
Constructor Detail |
---|
public SimpleDBLocalizer()
Method Detail |
---|
public void configure(java.util.Map config)
config
- tool configurationpublic void init(java.lang.Object initData)
init
in class HTTPLocalizerTool
initData
- a view contextprivate static void readLocales(javax.servlet.ServletContext ctx)
ctx
- servlet contextpublic boolean hasLocale(java.util.Locale locale)
hasLocale
in class HTTPLocalizerTool
locale
- locale
public void setLocale(java.util.Locale locale)
setLocale
in interface Localizer
setLocale
in class HTTPLocalizerTool
locale
- localepublic java.lang.String get(java.lang.Object id)
get
in interface Localizer
get
in class HTTPLocalizerTool
id
- message id
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |