Commit a4f9af68 authored by Franco Fichtner's avatar Franco Fichtner

wizard: add language selection; closes #648

(cherry picked from commit 2a76c4ab)
parent 2e3cf91c
......@@ -228,6 +228,22 @@ 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['fr_FR'] = gettext('French');
$locales['de_DE'] = gettext('German');
$locales['it_IT'] = gettext('Italian');
$locales['ja_JP'] = gettext('Japanese');
$locales['ru_RU'] = gettext('Russian');
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");
......
......@@ -34,25 +34,13 @@ require_once("unbound.inc");
require_once("interfaces.inc");
require_once("services.inc");
function get_locale_list()
{
$locales = array();
/* first one is the default */
$locales['en_US'] = gettext('English');
$locales['zh_CN'] = gettext('Chinese (Simplified)');
$locales['fr_FR'] = gettext('French');
$locales['de_DE'] = gettext('German');
$locales['it_IT'] = gettext('Italian');
$locales['ja_JP'] = gettext('Japanese');
$locales['ru_RU'] = gettext('Russian');
return $locales;
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array();
if (isset($_GET['savemsg'])) {
$savemsg = htmlspecialchars($_GET['savemsg']);
}
$pconfig['dns1gw'] = null;
$pconfig['dns2gw'] = null;
$pconfig['dns3gw'] = null;
......@@ -153,8 +141,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($pconfig['language']) && $pconfig['language'] != $config['system']['language']) {
$config['system']['language'] = $pconfig['language'];
/* XXX while this is very proactive, we should defer in favour of a unified language transition point ;) */
set_language();
}
if (!empty($pconfig['prefer_ipv4'])) {
......@@ -252,10 +238,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
filter_configure();
$savemsg = get_std_save_message();
header(url_safe('Location: /system_general.php?savemsg=%s', array(get_std_save_message())));
exit;
}
unset($ignore_posted_dnsgw);
}
legacy_html_escape_form_data($pconfig);
......@@ -263,7 +248,6 @@ legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
......
......@@ -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