Commit 2a76c4ab authored by Franco Fichtner's avatar Franco Fichtner

wizard: add language selection; closes #648

parent 26814679
......@@ -228,6 +228,28 @@ function system_resolvconf_generate($dynupdate = false)
return 0;
}
function get_locale_list()
{
$locales = array();
/* first one is the default */
$locales['en_US'] = gettext('English');
$locales['zh_CN'] = gettext('Chinese (Simplified)');
$locales['nl_NL'] = gettext('Dutch');
$locales['fr_FR'] = gettext('French');
$locales['de_DE'] = gettext('German');
$locales['it_IT'] = gettext('Italian');
$locales['ja_JP'] = gettext('Japanese');
$locales['mn_MN'] = gettext('Mongolian');
$locales['pt_BR'] = gettext('Portuguese');
$locales['ru_RU'] = gettext('Russian');
$locales['es_ES'] = gettext('Spanish');
$locales['sv_SE'] = gettext('Swedish');
$locales['tr_TR'] = gettext('Turkish');
return $locales;
}
function get_country_codes()
{
$dn_cc = array();
......
......@@ -56,7 +56,9 @@
<Log VisibleName="Log File" url="/diag_logs_gateways.php"/>
</Gateways>
<Settings order="20" cssClass="fa fa-cogs fa-fw">
<General order="100" url="/system_general.php"/>
<General order="100" url="/system_general.php">
<workAround url="/system_general.php*"/>
</General>
<Administration order="200" url="/system_advanced_admin.php"/>
<Logging order="300" url="/diag_logs_settings.php"/>
<Notifications order="400" url="/system_advanced_notifications.php"/>
......
......@@ -68,6 +68,11 @@
<validate>^[a-z0-9.|-]+$</validate>
<message>Domain name field is invalid</message>
</field>
<field>
<name>Language</name>
<type>language_select</type>
<bindstofield>system->language</bindstofield>
</field>
<field>
<name>Primary DNS Server</name>
<type>input</type>
......
......@@ -49,25 +49,6 @@ session_write_close();
/* CSRF END: THANK YOU FOR YOUR COOPERATION */
function set_language()
{
global $config;
$lang = 'en_US';
if (!empty($config['system']['language'])) {
$lang = $config['system']['language'];
}
$lang_encoding = $lang . '.UTF-8';
$textdomain = 'OPNsense';
putenv('LANG=' . $lang_encoding);
setlocale(LC_ALL, $lang_encoding);
textdomain($textdomain);
bindtextdomain($textdomain, '/usr/local/share/locale');
bind_textdomain_codeset($textdomain, $lang_encoding);
}
function get_current_theme()
{
global $config;
......@@ -89,7 +70,20 @@ function html_safe($text)
header("X-Frame-Options: SAMEORIGIN");
set_language();
/* set language */
$lang = 'en_US';
if (!empty($config['system']['language'])) {
$lang = $config['system']['language'];
}
$lang_encoding = $lang . '.UTF-8';
$textdomain = 'OPNsense';
putenv('LANG=' . $lang_encoding);
setlocale(LC_ALL, $lang_encoding);
textdomain($textdomain);
bindtextdomain($textdomain, '/usr/local/share/locale');
bind_textdomain_codeset($textdomain, $lang_encoding);
require_once("authgui.inc");
......
This diff is collapsed.
......@@ -749,6 +749,35 @@ function showchange() {
echo "<br /> " . $field['description'];
}
break;
case "language_select":
$languagelist = get_locale_list();
if ($field['displayname']) {
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
echo $field['displayname'];
echo ":</td>\n";
} else if(!$field['dontdisplayname']) {
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
echo fixup_string($field['name']);
echo ":</td>";
}
if(!$field['dontcombinecells'])
echo "<td class=\"vtable\">";
echo "<select class='form-control' name='{$name}'>\n";
foreach ($languagelist as $langkey => $langval) {
$SELECTED = "";
if ($value == $langkey) $SELECTED = " selected=\"selected\"";
echo "<option value=\"" . htmlspecialchars($langkey) . "\" {$SELECTED}>";
echo htmlspecialchars($langval);
echo "</option>\n";
}
echo "</select>\n";
if($field['description'] <> "") {
echo "<br /> " . $field['description'];
}
break;
case "timezone_select":
$timezonelist = get_zoneinfo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment