cea5df4c1ba0eb5f53bb7eb574611d61cb5a4172
1 package be
.nikiroo
.jvcard
.i18n
;
3 import java
.util
.HashMap
;
7 * This class manages the translation of {@link Trans#StringId}s into
8 * user-understandable text.
14 static private Object lock
= new Object();
15 static private Trans instance
= null;
17 private Map
<StringId
, String
> map
= null;
20 * An enum representing information to be translated to the user.
25 public enum StringId
{
26 DUMMY
, // <-- TODO : remove
27 KEY_ACTION_BACK
, KEY_ACTION_HELP
, KEY_ACTION_VIEW_CONTACT
, KEY_ACTION_VIEW_CARD
, KEY_ACTION_EDIT_CONTACT
, KEY_ACTION_SWITCH_FORMAT
, NULL
;
29 public String
trans() {
30 return Trans
.getInstance().trans(this);
35 * Get the (unique) instance of this class.
37 * @return the (unique) instance
39 static public Trans
getInstance() {
42 instance
= new Trans();
48 public String
trans(StringId stringId
) {
49 if (map
.containsKey(stringId
)) {
50 return map
.get(stringId
);
53 return stringId
.toString();
57 map
= new HashMap
<StringId
, String
>();
59 // TODO: get from a file instead?
60 map
.put(StringId
.NULL
, "");
61 map
.put(StringId
.DUMMY
, "[dummy]");
62 map
.put(StringId
.KEY_ACTION_BACK
, "Back");
63 map
.put(StringId
.KEY_ACTION_VIEW_CONTACT
, "view");
64 map
.put(StringId
.KEY_ACTION_EDIT_CONTACT
, "edit");
65 map
.put(StringId
.KEY_ACTION_SWITCH_FORMAT
, "Change view");