forked from I2P_Developers/i2p.i2p
- A flag of for the Arabic language, including the four Pan-Arab colors. Note: This is the 1917 Arab revolt / Hashemite dynasty flag. Source: http://commons.wikimedia.org/wiki/File:Arabic-Language-Flag.svg License: I, the copyright holder of this work, release this work into the public domain. This applies worldwide. In some countries this may not be legally possible; if so: I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law. Converted to 16x11 png by zzz / gimp - revert ch flag old change
72 lines
3.1 KiB
Java
72 lines
3.1 KiB
Java
package net.i2p.router.web;
|
|
|
|
import java.io.File;
|
|
import java.util.Iterator;
|
|
import java.util.TreeSet;
|
|
import java.util.Set;
|
|
|
|
public class ConfigUIHelper extends HelperBase {
|
|
|
|
public String getSettings() {
|
|
StringBuilder buf = new StringBuilder(512);
|
|
String current = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
|
Set<String> themes = themeSet();
|
|
for (String theme : themes) {
|
|
buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
|
|
if (theme.equals(current))
|
|
buf.append("checked=\"true\" ");
|
|
buf.append("value=\"").append(theme).append("\">").append(_(theme)).append("<br>\n");
|
|
}
|
|
return buf.toString();
|
|
}
|
|
|
|
static final String PROP_THEME_PFX = "routerconsole.theme.";
|
|
|
|
/** @return standard and user-installed themes, sorted (untranslated) */
|
|
private Set<String> themeSet() {
|
|
Set<String> rv = new TreeSet();
|
|
// add a failsafe even if we can't find any themes
|
|
rv.add(CSSHelper.DEFAULT_THEME);
|
|
File dir = new File(_context.getBaseDir(), "docs/themes/console");
|
|
File[] files = dir.listFiles();
|
|
if (files == null)
|
|
return rv;
|
|
for (int i = 0; i < files.length; i++) {
|
|
String name = files[i].getName();
|
|
if (files[i].isDirectory() && ! name.equals("images"))
|
|
rv.add(name);
|
|
}
|
|
// user themes
|
|
Set props = _context.getPropertyNames();
|
|
for (Iterator iter = props.iterator(); iter.hasNext(); ) {
|
|
String prop = (String) iter.next();
|
|
if (prop.startsWith(PROP_THEME_PFX) && prop.length() > PROP_THEME_PFX.length())
|
|
rv.add(prop.substring(PROP_THEME_PFX.length()));
|
|
}
|
|
return rv;
|
|
}
|
|
|
|
private static final String langs[] = {"ar", "de", "en", "es", "fr", "nl", "pt", "ru", "sv", "zh"};
|
|
private static final String flags[] = {"lang_ar", "de", "us", "es", "fr", "nl", "pt", "ru", "se", "cn"};
|
|
private static final String xlangs[] = {_x("Arabic"),
|
|
_x("German"), _x("English"), _x("Spanish"),_x("French"),
|
|
_x("Dutch"), _x("Portuguese"), _x("Russian"),
|
|
_x("Swedish"), _x("Chinese")};
|
|
|
|
/** todo sort by translated string */
|
|
public String getLangSettings() {
|
|
StringBuilder buf = new StringBuilder(512);
|
|
String current = Messages.getLanguage(_context);
|
|
for (int i = 0; i < langs.length; i++) {
|
|
// we use "lang" so it is set automagically in CSSHelper
|
|
buf.append("<input type=\"radio\" class=\"optbox\" name=\"lang\" ");
|
|
if (langs[i].equals(current))
|
|
buf.append("checked=\"true\" ");
|
|
buf.append("value=\"").append(langs[i]).append("\">")
|
|
.append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(flags[i]).append("\"> ")
|
|
.append(_(xlangs[i])).append("<br>\n");
|
|
}
|
|
return buf.toString();
|
|
}
|
|
}
|