Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java @ 2290:6f4a1f513e89
Calculation error report: i18n the km of the error report.
flys-artifacts/trunk@3954 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 09:33:06 +0000 |
parents | 2898b1ff6013 |
children | 79e7bba0f593 |
comparison
equal
deleted
inserted
replaced
2289:fe3ea0f16098 | 2290:6f4a1f513e89 |
---|---|
35 /** | 35 /** |
36 * Returns the locales supported by this server. | 36 * Returns the locales supported by this server. |
37 * | 37 * |
38 * @return the supported locales. | 38 * @return the supported locales. |
39 */ | 39 */ |
40 public Locale[] getLocales() { | 40 public synchronized Locale [] getLocales() { |
41 if (locales == null) { | 41 if (locales == null) { |
42 readLocales(); | 42 readLocales(); |
43 } | 43 } |
44 | 44 |
45 return locales; | 45 return locales; |
56 locales[0] = Locale.GERMANY; | 56 locales[0] = Locale.GERMANY; |
57 locales[1] = Locale.ENGLISH; | 57 locales[1] = Locale.ENGLISH; |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 public static Locale getLocale(CallMeta meta) { | 61 private static synchronized void ensureInstance() { |
62 if (INSTANCE == null) { | 62 if (INSTANCE == null) { |
63 INSTANCE = new Resources(); | 63 INSTANCE = new Resources(); |
64 } | 64 } |
65 } | |
66 | |
67 | |
68 public static Locale getLocale(CallMeta meta) { | |
69 ensureInstance(); | |
65 | 70 |
66 Locale[] locales = INSTANCE.getLocales(); | 71 Locale[] locales = INSTANCE.getLocales(); |
67 return meta.getPreferredLocale(locales); | 72 return meta.getPreferredLocale(locales); |
68 } | 73 } |
69 | 74 |
78 * @param def A default value that is returned, if <i>key</i> was not found. | 83 * @param def A default value that is returned, if <i>key</i> was not found. |
79 * | 84 * |
80 * @return the translated message. | 85 * @return the translated message. |
81 */ | 86 */ |
82 public static String getMsg(CallMeta meta, String key, String def) { | 87 public static String getMsg(CallMeta meta, String key, String def) { |
83 if (INSTANCE == null) { | 88 |
84 INSTANCE = new Resources(); | 89 ensureInstance(); |
85 } | |
86 | 90 |
87 Locale[] locales = INSTANCE.getLocales(); | 91 Locale[] locales = INSTANCE.getLocales(); |
88 Locale locale = meta.getPreferredLocale(locales); | 92 Locale locale = meta.getPreferredLocale(locales); |
89 | 93 |
90 return getMsg(locale, key, def); | 94 return getMsg(locale, key, def); |