1 package net.jaekl.frank;
3 import java.util.Locale;
4 import java.util.MissingResourceException;
5 import java.util.ResourceBundle;
6 import java.util.concurrent.ConcurrentHashMap;
8 import net.jaekl.qd.QDBundleFactory;
10 public class FrankBundle {
11 public static final String DATA_COLLECTED = "data.collected";
12 public static final String DESTINATION = "destination";
13 public static final String ERROR_PAGE = "error.page";
14 public static final String ETA = "eta";
15 public static final String FRANK = "frank";
16 public static final String GPS_OFF = "gps.off";
17 public static final String GPS_READ = "gps.read";
18 public static final String MINUTES = "m"; // suffix (abbreviated) for minutes
19 public static final String REMAIN = "remain";
20 public static final String ROUTE = "route";
21 public static final String SECONDS = "s";
22 public static final String UNEXPECTED_ERROR = "unexpected.error";
24 final static String BUNDLE_NAME = "frank";
26 static ConcurrentHashMap<Locale, FrankBundle> m_bundleMap = new ConcurrentHashMap<Locale, FrankBundle>();
28 ResourceBundle m_bundle;
30 public static FrankBundle getInst(Locale locale) {
31 FrankBundle result = m_bundleMap.get(locale);
33 synchronized(FrankBundle.class) {
34 result = m_bundleMap.get(locale);
36 result = new FrankBundle(locale);
38 m_bundleMap.put(locale, result);
44 private FrankBundle(Locale locale) {
45 m_bundle = QDBundleFactory.getInst().getBundle(BUNDLE_NAME, locale);
48 public String get(String key) {
50 if (null != m_bundle) {
51 return m_bundle.getString(key);
54 catch (MissingResourceException e) {
55 // Make it clear that something has gone wrong.
57 // Fall through to the fallback behaviour below
59 return "[" + key + "]";