Available languages are sorted by their true names

This commit is contained in:
Loïc Chapeaux
2001-08-28 10:08:20 +00:00
parent a6c0edc9e5
commit 872cf43d62
3 changed files with 32 additions and 3 deletions

View File

@@ -8,6 +8,11 @@ $Source$
2001-08-28 Lo<4C>c Chapeaux <lolo@phpheaven.net> 2001-08-28 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* lang/galician.inc.php3, select_lang.inc.php3: new Galician lang thanks to * lang/galician.inc.php3, select_lang.inc.php3: new Galician lang thanks to
Xose Calvo <xosecalvo@terra.es>. Xose Calvo <xosecalvo@terra.es>.
* select_lang.inc.php3: added the possible use of a cookie to retain the
language choosen by the user.
* main.php3:
- lines 425-426: form is submitted with post method;
- lines 431-447: languages are sorted by their true names.
2001-08-28 Olivier M<>ller <om@omnis.ch> 2001-08-28 Olivier M<>ller <om@omnis.ch>
* db_stats.php3: fixed the sql query so that the script won't die, even if * db_stats.php3: fixed the sql query so that the script won't die, even if

View File

@@ -422,11 +422,29 @@ if (empty($cfgLang)) {
<tr> <tr>
<td valign="baseline"><img src="images/item.gif" width="7" height="7" alt="item" /></td> <td valign="baseline"><img src="images/item.gif" width="7" height="7" alt="item" /></td>
<td> <td>
<form method="get" action="index.php3?&server=<?php echo urlencode($server); ?>" target="_top"> <form method="post" action="index.php3" target="_top">
<input type="hidden" name="server" value="<?php echo $server; ?>" />
Language: Language:
<select name="lang" onchange="this.form.submit();"> <select name="lang" onchange="this.form.submit();">
<?php <?php
echo "\n"; echo "\n";
/**
* Compares values of keys and sorts them
*
* @param array the array to be sorted
* @param mixed a required parameter
*
* @return the sorted array
*
* @access private
*/
function pmaComp(&$a, $b)
{
return (strcmp($a[1], $b[1]));
} // end of the 'pmaComp()' function
uasort($available_languages, 'pmaComp');
reset($available_languages); reset($available_languages);
while (list($id, $tmplang) = each($available_languages)) { while (list($id, $tmplang) = each($available_languages)) {
$lang_name = ucfirst(substr(strstr($tmplang[0], '|'), 1)); $lang_name = ucfirst(substr(strstr($tmplang[0], '|'), 1));

View File

@@ -114,9 +114,12 @@ if (!isset($lang)) {
if (isset($HTTP_GET_VARS) && !empty($HTTP_GET_VARS['lang'])) { if (isset($HTTP_GET_VARS) && !empty($HTTP_GET_VARS['lang'])) {
$lang = $HTTP_GET_VARS['lang']; $lang = $HTTP_GET_VARS['lang'];
} }
if (isset($HTTP_POST_VARS) && !empty($HTTP_POST_VARS['lang'])) { else if (isset($HTTP_POST_VARS) && !empty($HTTP_POST_VARS['lang'])) {
$lang = $HTTP_POST_VARS['lang']; $lang = $HTTP_POST_VARS['lang'];
} }
else if (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['lang'])) {
$lang = $HTTP_COOKIE_VARS['lang'];
}
} }
@@ -154,7 +157,10 @@ if (empty($lang)) {
$lang = $cfgDefaultLang; $lang = $cfgDefaultLang;
} }
// Define the associated filename and load the translation // Puts the retained language in a cookie that will expire in one year
setcookie('lang', $lang, time() + 60*60*24*365);
// Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php3'; $lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php3';
require('./' . $lang_file); require('./' . $lang_file);
?> ?>