forked from I2P_Developers/i2p.i2p
i2psnark: Translate theme names, translated sort
This commit is contained in:
@ -141,7 +141,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
public static final String RC_PROP_UNIVERSAL_THEMING = "routerconsole.universal.theme";
|
||||
public static final String PROP_THEME = "i2psnark.theme";
|
||||
public static final String DEFAULT_THEME = "ubergine";
|
||||
private static final String[] THEMES = new String[] { "dark", "light", "ubergine", "vanilla" };
|
||||
private static final String[] THEMES = new String[] { _x("dark"), _x("light"), _x("ubergine"), _x("vanilla") };
|
||||
/** From CSSHelper */
|
||||
private static final String PROP_DISABLE_OLD = "routerconsole.disableOldThemes";
|
||||
private static final boolean DEFAULT_DISABLE_OLD = true;
|
||||
@ -848,7 +848,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
|
||||
/**
|
||||
* Get current theme.
|
||||
* @return String -- the current theme
|
||||
* @return String -- the current theme, untranslated
|
||||
*/
|
||||
public String getTheme() {
|
||||
String theme;
|
||||
@ -913,7 +913,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
|
||||
/**
|
||||
* Get all themes
|
||||
* @return String[] -- Array of all the themes found, non-null, unsorted
|
||||
* @return Array of all the themes found, non-null, unsorted, untranslated. Not a copy, do not modify.
|
||||
*/
|
||||
public static String[] getThemes() {
|
||||
return THEMES;
|
||||
@ -2802,6 +2802,14 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
return _util.getString(s, o, o2);
|
||||
}
|
||||
|
||||
/**
|
||||
* mark for translation, does not translate
|
||||
* @since 0.9.53
|
||||
*/
|
||||
private static String _x(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsorted map of name to Tracker object
|
||||
* Modifiable, not a copy
|
||||
|
@ -10,6 +10,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.Collator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -2516,12 +2517,18 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
out.write("<select name='theme'>");
|
||||
String theme = _manager.getTheme();
|
||||
String[] themes = _manager.getThemes();
|
||||
Arrays.sort(themes);
|
||||
// translated sort
|
||||
Map<String, String> tmap = new TreeMap<String, String>(Collator.getInstance());
|
||||
for (int i = 0; i < themes.length; i++) {
|
||||
if(themes[i].equals(theme))
|
||||
out.write("\n<OPTION value=\"" + themes[i] + "\" SELECTED>" + themes[i]);
|
||||
tmap.put(_t(themes[i]), themes[i]);
|
||||
}
|
||||
for (Map.Entry<String, String> e : tmap.entrySet()) {
|
||||
String tr = e.getKey();
|
||||
String opt = e.getValue();
|
||||
if(opt.equals(theme))
|
||||
out.write("\n<option value=\"" + opt + "\" SELECTED>" + tr + "</option>");
|
||||
else
|
||||
out.write("\n<OPTION value=\"" + themes[i] + "\">" + themes[i]);
|
||||
out.write("\n<option value=\"" + opt + "\">" + tr + "</option>");
|
||||
}
|
||||
out.write("</select>\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user