forked from science-ation/science-ation
Update translation manager to work with unlimited number of languages as defined in the languages table
Update i18n function to accept a third parameter, which is an array that describes the arguments in the string to make translation much easier Update some of the config/admin pages to make sure i18n is properly used, and that argument descriptions are set
This commit is contained in:
parent
28ebf2ce30
commit
4d54bdbb1c
@ -27,18 +27,18 @@
|
||||
send_header("Administration");
|
||||
|
||||
echo "<br />";
|
||||
echo "<a href=\"registration.php\">Participant Registration</a> <br />";
|
||||
echo "<a href=\"reports.php\">Print / Export Reports</a> <br />";
|
||||
echo "<a href=\"registration.php\">".i18n("Participant Registration")."</a> <br />";
|
||||
echo "<a href=\"reports.php\">".i18n("Print / Export Reports")."</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"committees.php\">Committee Management</a> <br />";
|
||||
echo "<a href=\"awards.php\">Awards Management</a> <br />";
|
||||
echo "<a href=\"schools.php\">School Management</a> <br />";
|
||||
echo "<a href=\"judges.php\">Judging Management</a> <br />";
|
||||
echo "<a href=\"translations.php\">Translations Management</a> <br />";
|
||||
echo "<a href=\"committees.php\">".i18n("Committee Management")."</a> <br />";
|
||||
echo "<a href=\"awards.php\">".i18n("Awards Management")."</a> <br />";
|
||||
echo "<a href=\"schools.php\">".i18n("School Management")."</a> <br />";
|
||||
echo "<a href=\"judges.php\">".i18n("Judging Management")."</a> <br />";
|
||||
echo "<a href=\"translations.php\">".i18n("Translations Management")."</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"winners.php\">Enter Winning Projects</a> <br />";
|
||||
echo "<a href=\"winners.php\">".i18n("Enter Winning Projects")."</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"communication.php\">Communication (Send Emails)</a> <br />";
|
||||
echo "<a href=\"communication.php\">".i18n("Communication (Send Emails)")."</a> <br />";
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
@ -27,6 +27,13 @@
|
||||
|
||||
send_header("Translations");
|
||||
|
||||
//by default, we will edit the french translations
|
||||
if($_GET['translang']) $_SESSION['translang']=$_GET['translang'];
|
||||
|
||||
if(!$_SESSION['translang'])
|
||||
$_SESSION['translang']="fr";
|
||||
|
||||
|
||||
if($_GET['show']) $show=$_GET['show'];
|
||||
else if($_POST['show']) $show=$_POST['show'];
|
||||
if(!$show) $show="missing";
|
||||
@ -43,6 +50,23 @@ if($_GET['action']=="delete" && $_GET['delete'] && $_GET['lang'])
|
||||
echo happy(i18n("Translation deleted"));
|
||||
}
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td>";
|
||||
echo i18n("Choose a language to manage translations for");
|
||||
echo "</td><td>";
|
||||
echo "<form name=\"langswitch\" method=\"get\" action=\"translations.php\">";
|
||||
echo "<select name=\"translang\" onchange=\"document.forms.langswitch.submit()\">";
|
||||
$q=mysql_query("SELECT * FROM languages WHERE lang!='en'");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($_SESSION['translang']==$r->lang){ $sel="selected=\"selected\""; $translangname=$r->langname;} else $sel="";
|
||||
echo "<option $sel value=\"$r->lang\">$r->langname</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
echo "</form>";
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
if($show=="missing")
|
||||
{
|
||||
echo i18n("Show missing translations");
|
||||
@ -55,21 +79,22 @@ else
|
||||
echo " | ";
|
||||
echo i18n("Show all translations");
|
||||
}
|
||||
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo i18n("Instructions: Enter the translation below the string and click Save. Only one translation can be saved at a time. The terms %1, %2, etc get substituded with various arguments to the string, so they must appear in the translation if they are in the original string.");
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
if($show=="missing") $showquery="WHERE val is null OR val=''";
|
||||
if($show=="missing") $showquery="AND ( val is null OR val='' )";
|
||||
else $showquery="";
|
||||
|
||||
$q=mysql_query("SELECT * FROM translations $showquery ORDER BY str");
|
||||
$q=mysql_query("SELECT * FROM translations WHERE lang='".$_SESSION['translang']."' $showquery ORDER BY str");
|
||||
$num=mysql_num_rows($q);
|
||||
echo i18n("Showing %1 translation strings",array($num));
|
||||
echo i18n("Showing %1 translation strings",array($num),array("number of strings"));
|
||||
|
||||
echo "<table class=\"tableedit\">";
|
||||
echo "<tr><th>".i18n("English / French")."</th><th>".i18n("Save")."</th></tr>";
|
||||
echo "<tr><th>".i18n("English")." / ".$translangname."</th><th>".i18n("Save")."</th></tr>";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<form method=\"post\" action=\"translations.php\">";
|
||||
@ -80,7 +105,11 @@ while($r=mysql_fetch_object($q))
|
||||
echo "<td valign=\"top\">";
|
||||
echo "<a onclick=\"return confirmClick('Are you sure you want to delete this translation?');\" href=\"translations.php?show=$show&action=delete&delete=$r->strmd5&lang=$r->lang\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
echo " ";
|
||||
echo "$r->str</td>";
|
||||
echo htmlspecialchars($r->str);
|
||||
if($r->argsdesc)
|
||||
echo "<br /><i>".i18n("Arguments:")." $r->argsdesc </i>";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td rowspan=\"2\" valign=\"middle\" ><input type=\"submit\" value=\"".i18n("Save")."\" /></td>";
|
||||
echo "</tr>";
|
||||
echo "<tr>";
|
||||
|
@ -226,7 +226,7 @@ if($_GET['switchlanguage'])
|
||||
}
|
||||
|
||||
|
||||
function i18n($str,$args=array())
|
||||
function i18n($str,$args=array(),$argsdesc=array())
|
||||
{
|
||||
if(!$str)
|
||||
return "";
|
||||
@ -262,18 +262,33 @@ function i18n($str,$args=array())
|
||||
{
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
return "<font color=\"red\">$str</font>";
|
||||
return "{{".$str."}}";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("INSERT INTO translations (lang,strmd5,str) VALUES ('".$_SESSION['lang']."','".md5($str)."','".mysql_escape_string($str)."')");
|
||||
if(count($argsdesc))
|
||||
{
|
||||
$argsdescstring="";
|
||||
$n=1;
|
||||
foreach($argsdesc AS $ad)
|
||||
{
|
||||
$argsdescstring.="%$n=$ad, ";
|
||||
$n++;
|
||||
}
|
||||
$argsdescstring=substr($argsdescstring,0,-2);
|
||||
$argsdescstring="'".mysql_escape_string($argsdescstring)."'";
|
||||
}
|
||||
else
|
||||
$argsdescstring="null";
|
||||
|
||||
mysql_query("INSERT INTO translations (lang,strmd5,str,argsdesc) VALUES ('".$_SESSION['lang']."','".md5($str)."','".mysql_escape_string($str)."',$argsdescstring)");
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
return "<font color=\"red\">$str</font>";
|
||||
return "{{".$str."}}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -750,7 +765,7 @@ function email_send($val,$to,$sub_subject=array(),$sub_body=array())
|
||||
}
|
||||
else
|
||||
{
|
||||
echo error(i18n("CRITICAL ERROR: email '%1' not found",array($val)));
|
||||
echo error(i18n("CRITICAL ERROR: email '%1' not found",array($val),array("email address")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
echo mysql_error();
|
||||
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
||||
{
|
||||
echo error(i18n("Category ID %1 already exists",array($_POST['id'])));
|
||||
echo error(i18n("Category ID %1 already exists",array($_POST['id']),array("category ID")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -62,7 +62,7 @@
|
||||
$q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
echo error(i18n("Category ID %1 already exists",array($_POST['id'])));
|
||||
echo error(i18n("Category ID %1 already exists",array($_POST['id']),array("category ID")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -131,7 +131,7 @@
|
||||
{
|
||||
echo "<tr>";
|
||||
echo " <td>$r->id</td>";
|
||||
echo " <td>$r->category</td>";
|
||||
echo " <td>".i18n($r->category)."</td>";
|
||||
echo " <td>$r->mingrade</td>";
|
||||
echo " <td>$r->maxgrade</td>";
|
||||
echo " <td>";
|
||||
|
@ -43,7 +43,7 @@
|
||||
echo "<form method=\"post\" action=\"dates.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
|
||||
echo "<table>";
|
||||
echo "<tr><td colspan=\"3\"><h3>".i18n("Dates for fair year %1",array($config['FAIRYEAR']))."</h3></td></tr>";
|
||||
echo "<tr><td colspan=\"3\"><h3>".i18n("Dates for fair year %1",array($config['FAIRYEAR']),array("fair year"))."</h3></td></tr>";
|
||||
|
||||
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."' ORDER BY date");
|
||||
while($r=mysql_fetch_object($q))
|
||||
|
@ -34,7 +34,7 @@
|
||||
$q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
||||
{
|
||||
echo error(i18n("Division ID %1 already exists",array($_POST['id'])));
|
||||
echo error(i18n("Division ID %1 already exists",array($_POST['id']),array("division ID")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -59,7 +59,7 @@
|
||||
$q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
echo error(i18n("Division ID %1 already exists",array($_POST['id'])));
|
||||
echo error(i18n("Division ID %1 already exists",array($_POST['id']),array("division ID")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -126,7 +126,7 @@
|
||||
{
|
||||
echo "<tr>";
|
||||
echo " <td>$r->id</td>";
|
||||
echo " <td>$r->division</td>";
|
||||
echo " <td>".i18n($r->division)."</td>";
|
||||
echo " <td align=\"center\">$r->division_shortform</td>";
|
||||
echo " <td>";
|
||||
echo "<a title=\"Edit\" href=\"".$_SERVER['PHP_SELF']."?action=edit&edit=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\" border=0></a>";
|
||||
|
@ -54,16 +54,16 @@ if($_POST['action']=="addimage")
|
||||
|
||||
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"images.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"addimage\">\n";
|
||||
echo "<h3>Fair Logo Image</h3>";
|
||||
echo "<h3>".i18n("Fair Logo Image")."</h3>";
|
||||
echo "<table>";
|
||||
if(file_exists("../data/logo.gif"))
|
||||
{
|
||||
echo "<tr><td>";
|
||||
echo "<img src=\"../data/logo-100.gif\" border=\"0\">";
|
||||
echo "</td><td>";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo.gif\">Original size</a><br />";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo-100.gif\">100 Pixel width</a><br />";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo-200.gif\">200 Pixel width</a><br />";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo.gif\">",i18n("Original size")."</a><br />";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo-100.gif\">".i18n("100 Pixel width")."</a><br />";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo-200.gif\">".i18n("200 Pixel width")."</a><br />";
|
||||
echo "<a target=\"_blank\" href=\"../data/logo-500.gif\">500 Pixel width</a><br />";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
@ -27,16 +27,16 @@
|
||||
|
||||
send_header("Configuration");
|
||||
|
||||
echo "<a href=\"variables.php\">Configuration Variables</a> <br />";
|
||||
echo "<a href=\"dates.php\">Important Dates</a> <br />";
|
||||
echo "<a href=\"categories.php\">Project Age Categories</a> <br />";
|
||||
echo "<a href=\"divisions.php\">Project Divisons</a> <br />";
|
||||
echo "<a href=\"subdivisions.php\">Project Sub-Divisons</a> <br />";
|
||||
echo "<a href=\"pagetexts.php\">Page Texts</a> <br />";
|
||||
echo "<a href=\"safetyquestions.php\">Project Safety Questions</a> <br />";
|
||||
echo "<a href=\"images.php\">Images (Fair Logo)</a> <br />";
|
||||
echo "<a href=\"variables.php\">".i18n("Configuration Variables")."</a> <br />";
|
||||
echo "<a href=\"dates.php\">".i18n("Important Dates")."</a> <br />";
|
||||
echo "<a href=\"categories.php\">".i18n("Project Age Categories")."</a> <br />";
|
||||
echo "<a href=\"divisions.php\">".i18n("Project Divisons")."</a> <br />";
|
||||
echo "<a href=\"subdivisions.php\">".i18n("Project Sub-Divisons")."</a> <br />";
|
||||
echo "<a href=\"pagetexts.php\">".i18n("Page Texts")."</a> <br />";
|
||||
echo "<a href=\"safetyquestions.php\">".i18n("Project Safety Questions")."</a> <br />";
|
||||
echo "<a href=\"images.php\">".i18n("Images (Fair Logo)")."</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"rollover.php\">Rollover Fair Year</a> <br />";
|
||||
echo "<a href=\"rollover.php\">".i18n("Rollover Fair Year")."</a> <br />";
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
@ -72,7 +72,7 @@
|
||||
echo "<table class=\"summarytable\">";
|
||||
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE year='".$config['FAIRYEAR']."' ORDER BY textname");
|
||||
echo "<tr><th>Page Text Name</th><th>Last Update</th></tr>";
|
||||
echo "<tr><th>".i18n("Page Text Name")."</th><th>".i18n("Last Update")."</th></tr>";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<tr><td><a href=\"pagetexts.php?textname=$r->textname\">$r->textname</a></td>";
|
||||
|
@ -125,7 +125,7 @@
|
||||
}
|
||||
}
|
||||
echo "<br />";
|
||||
echo "<a href=\"safetyquestions.php?action=new\">Add new safety question</a>";
|
||||
echo "<a href=\"safetyquestions.php?action=new\">".i18n("Add new safety question")."</a>";
|
||||
|
||||
echo "<table class=\"summarytable\">";
|
||||
$q=mysql_query("SELECT * FROM safetyquestions WHERE year='".$config['FAIRYEAR']."' ORDER BY ord");
|
||||
|
@ -75,7 +75,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
echo "<tr><td colspan=\"3\"><hr /><br /><h3>".i18n("Configuration settings for fair year %1",array($config['FAIRYEAR']))."</h3></td></tr>";
|
||||
echo "<tr><td colspan=\"3\"><hr /><br /><h3>".i18n("Configuration settings for fair year %1",array($config['FAIRYEAR']),array("fair year"))."</h3></td></tr>";
|
||||
|
||||
$q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."' ORDER BY var");
|
||||
while($r=mysql_fetch_object($q))
|
||||
|
@ -1,3 +1,4 @@
|
||||
UPDATE `config` SET `description` = 'Self nominations for special awards are due either with registration or on a specific date. If "date" is used, it must be configured under "Important Dates" section. If you do not wish to allow students to self-nominate for special awards, set to "none" (none|date|registration)' WHERE `var` = 'specialawardnomination';
|
||||
ALTER TABLE `schools` ADD `projectlimit` INT NOT NULL , ADD `projectlimitper` ENUM( 'total', 'agecategory' ) NOT NULL ;
|
||||
INSERT INTO `config` ( `var` , `val` , `description` , `year` ) VALUES ( 'participant_student_tshirt', 'yes', 'Ask for students their T-Shirt size (yes/no).', '-1');
|
||||
ALTER TABLE `translations` ADD `argsdesc` TEXT DEFAULT NULL ;
|
||||
|
@ -101,7 +101,7 @@
|
||||
{
|
||||
email_send("register_judges_resend_password",$_SESSION['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("PASSWORD"=>$r->password,"EMAIL"=>$r->email));
|
||||
send_header("Judges Registration");
|
||||
echo notice(i18n("Your judge registration password has been sent to your email addess <b>%1</b>",array($_SESSION['email'])));
|
||||
echo notice(i18n("Your judge registration password has been sent to your email addess <b>%1</b>",array($_SESSION['email']),array("email address") ));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -272,7 +272,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
echo i18n("Judges registration for the %1 %2 is now closed",array($config['FAIRYEAR'],$config['fairname']));
|
||||
echo i18n("Judges registration for the %1 %2 is now closed",array($config['FAIRYEAR'],$config['fairname']),array("Fair year","Fair name"));
|
||||
}
|
||||
}
|
||||
send_footer();
|
||||
|
@ -45,7 +45,7 @@
|
||||
else
|
||||
{
|
||||
send_header("Participant Registration");
|
||||
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email'])));
|
||||
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email']),array("registration number","email address")));
|
||||
$_POST['action']="login";
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
else
|
||||
{
|
||||
send_header("Participant Registration");
|
||||
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email'])));
|
||||
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email']),array("registration number","email address")));
|
||||
$_POST['action']="login";
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@
|
||||
{
|
||||
email_send("register_participants_resend_regnum",$_SESSION['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("REGNUM"=>$r->num));
|
||||
send_header("Participant Registration");
|
||||
echo notice(i18n("Your registration number has been resent to your email addess <b>%1</b>",array($_SESSION['email'])));
|
||||
echo notice(i18n("Your registration number has been resent to your email addess <b>%1</b>",array($_SESSION['email']),array("email address")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -323,7 +323,7 @@
|
||||
|
||||
email_send("new_participant",$_SESSION['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("REGNUM"=>$regnum));
|
||||
|
||||
echo i18n("You have been identified as a new registrant. An email has been sent to <b>%1</b> which contains your new <b>registration number</b>. Please check your email to obtain your <b>registration number</b> and then enter it below:",array($_SESSION['email']));
|
||||
echo i18n("You have been identified as a new registrant. An email has been sent to <b>%1</b> which contains your new <b>registration number</b>. Please check your email to obtain your <b>registration number</b> and then enter it below:",array($_SESSION['email']),array("email address"));
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@
|
||||
//this will return 1 if its between the dates, 0 otherwise.
|
||||
if($datecheck->datecheck==0)
|
||||
{
|
||||
echo notice(i18n("Registration for the %1 %2 is now closed. Existing registrants can login and view (read only) their information, as well as apply for special awards (if applicable).",array($config['FAIRYEAR'],$config['fairname'])));
|
||||
echo notice(i18n("Registration for the %1 %2 is now closed. Existing registrants can login and view (read only) their information, as well as apply for special awards (if applicable).",array($config['FAIRYEAR'],$config['fairname']),array("fair year","fair name")));
|
||||
echo i18n("Please enter your email address to login");
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
Loading…
x
Reference in New Issue
Block a user