* Console:

- Don't save config when checking for updates on configupdate.jsp
      - Rework ConfigRestartBean and tag
      - More tag fixups
      - Add lang=xx for testing
      - Add file for additional tagged strings
This commit is contained in:
zzz
2009-10-26 21:48:46 +00:00
parent 850a8da0a9
commit a2d90eebea
27 changed files with 254 additions and 119 deletions

View File

@ -25,8 +25,12 @@ public class Messages {
private static final String _localeLang = Locale.getDefault().getLanguage();
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(2);
private static final Set<String> _missing = new ConcurrentHashSet(2);
/** use to look for untagged strings */
private static final String TEST_LANG = "xx";
private static final String TEST_STRING = "XXXX";
/** current locale **/
/* unused
public static String getString(String key) {
if (_localeLang.equals("en"))
return key;
@ -39,12 +43,15 @@ public class Messages {
return key;
}
}
*/
/** lang in routerconsole.lang property, else current locale */
public static String getString(String key, I2PAppContext ctx) {
String lang = getLanguage(ctx);
if (lang.equals("en"))
return key;
else if (lang.equals(TEST_LANG))
return TEST_STRING;
ResourceBundle bundle = findBundle(lang);
if (bundle == null)
return key;
@ -68,17 +75,20 @@ public class Messages {
* Use autoboxing to call with ints, longs, floats, etc.
*/
public static String getString(String s, Object o, I2PAppContext ctx) {
String lang = getLanguage(ctx);
if (lang.equals(TEST_LANG))
return TEST_STRING + '(' + o + ')' + TEST_STRING;
String x = getString(s, ctx);
Object[] oArray = new Object[1];
oArray[0] = o;
try {
MessageFormat fmt = new MessageFormat(x, new Locale(getLanguage(ctx)));
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 +
"\" param: \"" + o +
"\" lang: " + getLanguage(ctx));
"\" lang: " + lang);
return "FIXME: " + x + ' ' + o;
}
}