+
+ /**
+ * Return the {@link Locale} representing the given language.
+ *
+ * @param language
+ * the language to initialise, in the form "en-GB" or "fr" for
+ * instance
+ *
+ * @return the corresponding {@link Locale} or the default {@link Locale} if
+ * it is not known
+ */
+ static private Locale getLocaleFor(String language) {
+ Locale locale;
+
+ if (language == null) {
+ locale = Locale.getDefault();
+ } else {
+ language = language.replaceAll("_", "-");
+ String lang = language;
+ String country = null;
+ if (language.contains("-")) {
+ lang = language.split("-")[0];
+ country = language.split("-")[1];
+ }
+
+ if (country != null)
+ locale = new Locale(lang, country);
+ else
+ locale = new Locale(lang);
+ }
+
+ return locale;
+ }
+
+ /**
+ * Return formated, display-able information from the {@link Meta} field
+ * given. Each line will always starts with a "#" character.
+ *
+ * @param meta
+ * the {@link Meta} field
+ *
+ * @return the information to display or NULL if none
+ */
+ static private String getMetaInfo(Meta meta) {
+ String what = meta.what();
+ String where = meta.where();
+ String format = meta.format();
+ String info = meta.info();
+
+ int opt = what.length() + where.length() + format.length();
+ if (opt + info.length() == 0)
+ return null;
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("# ");
+
+ if (opt > 0) {
+ builder.append("(");
+ if (what.length() > 0) {
+ builder.append("WHAT: " + what);
+ if (where.length() + format.length() > 0)
+ builder.append(", ");
+ }
+
+ if (where.length() > 0) {
+ builder.append("WHERE: " + where);
+ if (format.length() > 0)
+ builder.append(", ");
+ }
+
+ if (format.length() > 0) {
+ builder.append("FORMAT: " + format);
+ }
+
+ builder.append(")\n# ");
+ }
+
+ builder.append(info);
+
+ return builder.toString();
+ }
+
+ /**
+ * The enum representing textual information to be translated to the user as
+ * a key.
+ *
+ * Note that each key that should be translated MUST be annotated with a
+ * {@link Meta} annotation.
+ *
+ * @author niki
+ *
+ */
+ public enum StringId {
+ DUMMY, // <-- TODO : remove
+ NULL, // Special usage, no annotations so it is not visible in
+ // .properties files
+ @Meta(what = "a key to press", where = "action keys", format = "MUST BE 3 chars long", info = "Tab key")
+ KEY_TAB, // keys
+ @Meta(what = "a key to press", where = "action keys", format = "MUST BE 3 chars long", info = "Enter key")
+ KEY_ENTER, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_BACK, // MainWindow
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_HELP, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_VIEW_CARD, // FileList
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_VIEW_CONTACT, // ContactList
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_EDIT_CONTACT, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_SAVE_CARD, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_DELETE_CONTACT, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_SEARCH, //
+ @Meta(what = "", where = "", format = "", info = "we could use: ' ', ┃, │...")
+ DEAULT_FIELD_SEPARATOR, // MainContentList
+ @Meta(what = "", where = "", format = "", info = "")
+ DEAULT_FIELD_SEPARATOR_NOUTF, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_INVERT, // ContactDetails
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_FULLSCREEN, //
+ @Meta(what = "", where = "", format = "", info = "")
+ KEY_ACTION_SWITCH_FORMAT, // multi-usage
+ };