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
, // MainWindow
28 KEY_ACTION_VIEW_CARD
, // FileList
29 KEY_ACTION_VIEW_CONTACT
, KEY_ACTION_EDIT_CONTACT
, KEY_ACTION_SAVE_CARD
, KEY_ACTION_DELETE_CONTACT
, KEY_ACTION_SWITCH_FORMAT
, // ContactList
30 NULL
; // Special usage
32 public String
trans() {
33 return Trans
.getInstance().trans(this);
38 * Get the (unique) instance of this class.
40 * @return the (unique) instance
42 static public Trans
getInstance() {
45 instance
= new Trans();
51 public String
trans(StringId stringId
) {
52 if (map
.containsKey(stringId
)) {
53 return map
.get(stringId
);
56 return stringId
.toString();
60 map
= new HashMap
<StringId
, String
>();
62 // TODO: get from a file instead?
63 map
.put(StringId
.NULL
, "");
64 map
.put(StringId
.DUMMY
, "[dummy]");
65 map
.put(StringId
.KEY_ACTION_BACK
, "Back");
66 map
.put(StringId
.KEY_ACTION_HELP
, "Help");
67 map
.put(StringId
.KEY_ACTION_VIEW_CONTACT
, "Open");
68 map
.put(StringId
.KEY_ACTION_VIEW_CARD
, "Open");
69 map
.put(StringId
.KEY_ACTION_EDIT_CONTACT
, "Edit");
70 map
.put(StringId
.KEY_ACTION_DELETE_CONTACT
, "Delete");
71 map
.put(StringId
.KEY_ACTION_SWITCH_FORMAT
, "Change view");