01: package org.contineo.core.i18n;
02:
03: import java.util.Locale;
04: import java.util.ResourceBundle;
05:
06: /**
07: * A central bean for handling all localisation information like data format.<p>
08: * All settings are retrieved from resource bundle <code>org.contineo.core.i18n.localeInformation</code>
09: *
10: *
11: * @author Sebastian Stein
12: */
13: public class LocaleInformation {
14: private static final String BUNDLE_NAME = "org.contineo.core.i18n.localeInformation";
15:
16: /**
17: * Retrieves a localised information for the specified locale.
18: *
19: * @param key The name of the information
20: * @param locale The wanted locale
21: * @return The found information
22: */
23: public static String getInfo(String key, Locale locale) {
24: ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME,
25: locale);
26: return bundle.getString(key);
27: }
28:
29: /**
30: * Retrieves a localised information for the specified language.
31: *
32: * @param key The name of the information
33: * @param language The wanted language
34: * @return The found information
35: */
36: public static String getInfo(String key, String language) {
37: Locale locale = new Locale(language);
38: return getInfo(key, locale);
39: }
40:
41: /**
42: * Returns the standard date format for the specified language
43: */
44: public static String getDateFormat(String language) {
45: return getInfo("dateFormat", language);
46: }
47:
48: /**
49: * Returns the short date format for the specified language
50: */
51: public static String getDateFormatShort(String language) {
52: return getInfo("dateFormatShort", language);
53: }
54: }
|