3ea95625ca177182d75a0ddce0be5fcd68cd1a63
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 KEY_ACTION_BACK
, KEY_ACTION_HELP
, KEY_ACTION_VIEW_CONTACT
, KEY_ACTION_EDIT_CONTACT
, KEY_ACTION_SWITCH_FORMAT
, TITLE
, NULL
;
28 public String
trans() {
29 return Trans
.getInstance().trans(this);
34 * Get the (unique) instance of this class.
36 * @return the (unique) instance
38 static public Trans
getInstance() {
41 instance
= new Trans();
47 public String
trans(StringId stringId
) {
48 if (map
.containsKey(stringId
)) {
49 return map
.get(stringId
);
52 return stringId
.toString();
56 map
= new HashMap
<StringId
, String
>();
58 // TODO: get from a file instead?
59 map
.put(StringId
.NULL
, "");
60 map
.put(StringId
.KEY_ACTION_BACK
, "Back");
61 map
.put(StringId
.TITLE
, "[ jVcard: version 0.9 ]");
62 map
.put(StringId
.KEY_ACTION_VIEW_CONTACT
, "view");
63 map
.put(StringId
.KEY_ACTION_EDIT_CONTACT
, "edit");
64 map
.put(StringId
.KEY_ACTION_SWITCH_FORMAT
, "Change view");