add 2-param method, tag the java messages, fix the buttons, clean up add and create forms

This commit is contained in:
zzz
2009-12-10 18:08:50 +00:00
parent c39f047703
commit e5248b09ab
5 changed files with 331 additions and 94 deletions

View File

@ -76,6 +76,28 @@ public abstract class Translate {
}
}
/** for {0} and {1} */
public static String getString(String s, Object o, Object o2, I2PAppContext ctx, String bun) {
String lang = getLanguage(ctx);
if (lang.equals(TEST_LANG))
return TEST_STRING + '(' + o + ',' + o2 + ')' + TEST_STRING;
String x = getString(s, ctx, bun);
Object[] oArray = new Object[2];
oArray[0] = o;
oArray[1] = o2;
try {
MessageFormat fmt = new MessageFormat(x, new Locale(lang));
return fmt.format(oArray, new StringBuffer(), null).toString();
} catch (IllegalArgumentException iae) {
System.err.println("Bad format: orig: \"" + s +
"\" trans: \"" + x +
"\" param1: \"" + o +
"\" param2: \"" + o2 +
"\" lang: " + lang);
return "FIXME: " + x + ' ' + o + ',' + o2;
}
}
/** @return lang in routerconsole.lang property, else current locale */
public static String getLanguage(I2PAppContext ctx) {
String lang = ctx.getProperty(PROP_LANG);