*** empty log message ***

svn path=/trunk/boinc/; revision=5764
This commit is contained in:
David Anderson 2005-04-02 18:37:22 +00:00
parent 00f82cb4d9
commit 0dd0664134
5 changed files with 230 additions and 163 deletions

View File

@ -26522,3 +26522,9 @@ Janus 2 April 2005
img/ (new)
da.png (new)
David 2 April 2005
html/
inc/
translation.inc
ops/
repair_validator_problem.php

View File

@ -14,14 +14,16 @@ function getSupportedLanguages(){
global $lang_language_dir, $lang_compiled_dir;
//echo $lang_language_dir.$lang_compiled_dir;
if (is_dir($lang_language_dir.$lang_compiled_dir)) {
if ($dh = opendir($lang_language_dir.$lang_compiled_dir)) { //If dir exists
while (($file = readdir($dh)) !== false) { //read contents
if ($dh = opendir($lang_language_dir.$lang_compiled_dir)) { //If dir exists
while (($file = readdir($dh)) !== false) {
//read contents
if ($file==".." or $file=="."){
} else if (substr($file,-7)==".po.inc"){ //only files ending in .po.inc
$list[] = substr($file,0,-7);
}
}
}
} else if (substr($file,-7)==".po.inc"){
//only files ending in .po.inc
$list[] = substr($file,0,-7);
}
}
}
} else {echo "uh";}
//print_r($list);
return $list;
@ -30,12 +32,13 @@ function getSupportedLanguages(){
function trSpecific($tokennumber, $language=""){
global $lang_language_dir, $lang_compiled_dir;
$language= substr($language,0,5);
if ($language!="" && file_exists($lang_language_dir.$lang_compiled_dir.$language.".po.inc")){ //If we have the language
//echo "[$language]";
require($lang_language_dir.$lang_compiled_dir.$language.".po.inc"); //Include it
return stripslashes($language_lookup_array[$tokennumber]);
if ($language!="" && file_exists($lang_language_dir.$lang_compiled_dir.$language.".po.inc")){
//If we have the language, include it
//echo "[$language]";
require($lang_language_dir.$lang_compiled_dir.$language.".po.inc");
return stripslashes($language_lookup_array[$tokennumber]);
} else {
return false;
return false;
}
}
@ -45,13 +48,14 @@ function trSpecific($tokennumber, $language=""){
function parseLanguageInterface($file){
$translation_file = file($file);
for ($i = 0;$i<sizeof($translation_file);$i++){
$entry = ltrim(trim($translation_file[$i]));
if (($pos=strpos($entry, "msgid"))!==false){ //If found msgid entry
$token=getPOLineContent($entry);
if (ltrim(trim($token))!=""){
$interface[]=$token;
}
}
$entry = ltrim(trim($translation_file[$i]));
if (($pos=strpos($entry, "msgid"))!==false){
//If found msgid entry
$token=getPOLineContent($entry);
if (ltrim(trim($token))!=""){
$interface[]=$token;
}
}
}
return $interface;
}
@ -64,92 +68,115 @@ function parseLanguageInterface($file){
function buildLanguages($langdir,$transdir,$prjtransdir,$compdir){
global $lang_project_default;
$fh=fopen($langdir."last_compile_timer","w"); //Touching compile timer
//Touching compile timer
$fh=fopen($langdir."last_compile_timer","w");
fwrite($fh, time());
fclose($fh);
//First build the list of defines for the tokens
//and place it in an include file in the directory
$interface = parseLanguageInterface($langdir.$transdir.$lang_project_default.".po"); //Get the interface
if (!$fh = fopen($langdir.$compdir."language_interface.inc","w")) { language_log("Could not access $langdir $compdir - please check permissions",2); exit;};
//
$interface = parseLanguageInterface($langdir.$transdir.$lang_project_default.".po");
if (!$fh = fopen($langdir.$compdir."language_interface.inc","w")) {
language_log("Could not access $langdir $compdir - please check permissions",2);
exit;
};
fwrite($fh, "<?php\n");
for ($i=0;$i<sizeof($interface);$i++){
fwrite($fh, "define(".$interface[$i].",".$i.");\n"); //Translate to PHP
//Translate to PHP
fwrite($fh, "define(".$interface[$i].",".$i.");\n");
}
fwrite($fh, '?>');
fclose($fh);
$real_interface_size = sizeof($interface);
//Now run trough each language and recompile their
//lookup arrays.
//Now run trough each language and recompile their lookup arrays.
//
if (is_dir($langdir.$transdir)) {
if ($dh = opendir($langdir.$transdir)) { //If dir exists
while (($file = readdir($dh)) !== false) { //read contents
if ($dh = opendir($langdir.$transdir)) {
//If dir exists
while (($file = readdir($dh)) !== false) {
//read contents
if ($file==".." or $file=="."){
} else if (substr($file,-3)==".po"){ //only files ending in .po
///////////////////////////////////////////////////////////////////////////////////////////////////
language_log("----------------Compiling $file---------------",0);
$language = parseLanguage($langdir.$transdir.$file, $interface);
if (!$fh = fopen($langdir.$compdir.$file.".inc","w")) { language_log("ERROR: could not access $langdir $compdir - please check permissions",2); exit;};
fwrite($fh, "<?php\n");
$keys = array_keys($language);
for ($i=0;$i<sizeof($interface);$i++){
if ($language[$keys[$i]]!="")
fwrite($fh, "\$language_lookup_array[".$keys[$i]."] = \"".addslashes($language[$keys[$i]])."\";\n"); //Translate to PHP
}
fwrite($fh, '?>');
fclose($fh);
//////////////////////////////////////////////////////////////////////////////////////////////////
} else if (substr($file,-3)==".po"){
//only files ending in .po
language_log("----------------Compiling $file---------------",0);
$language = parseLanguage($langdir.$transdir.$file, $interface);
if (!$fh = fopen($langdir.$compdir.$file.".inc","w")) {
language_log("ERROR: could not access $langdir $compdir - please check permissions",2);
exit;
};
fwrite($fh, "<?php\n");
$keys = array_keys($language);
for ($i=0;$i<sizeof($interface);$i++){
if ($language[$keys[$i]]!="") {
//Translate to PHP
fwrite($fh, "\$language_lookup_array[".$keys[$i]."] = \"".addslashes($language[$keys[$i]])."\";\n");
}
}
fwrite($fh, '?>');
fclose($fh);
} else {
//debug("File $file with unknown extension found in $info_dir");
}
//debug("File $file with unknown extension found in $info_dir");
}
}
closedir($dh);
} else {
//debug("$info_dir could not be opened - check permissions?");
}
//debug("$info_dir could not be opened - check permissions?");
}
} else {
//debug("$info_dir not found or is not a directory");
//debug("$info_dir not found or is not a directory");
}
//Do the same again, this time for the project specific language files and instead of
//creating new compiled files just add to whatever existing ones
//Do the same again, this time for the project specific language files
// and instead of creating new compiled files
// just add to whatever existing ones
//
if (is_dir($langdir.$prjtransdir)) {
$interface = parseLanguageInterface($langdir.$prjtransdir.$lang_project_default.".po"); //Get the interface
if (!$fh = fopen($langdir.$compdir."language_interface.inc","a")) { language_log("ERROR: could not access $langdir $compdir - please check permissions",2); exit;};
fwrite($fh, "<?php\n");
for ($i=0;$i<sizeof($interface);$i++){
fwrite($fh, "define(".$interface[$i].",".($i+$real_interface_size).");\n"); //Translate to PHP
}
fwrite($fh, '?>');
fclose($fh);
if ($dh = opendir($langdir.$prjtransdir)) { //If dir exists
while (($file = readdir($dh)) !== false) { //read contents
$interface = parseLanguageInterface($langdir.$prjtransdir.$lang_project_default.".po");
if (!$fh = fopen($langdir.$compdir."language_interface.inc","a")) {
language_log("ERROR: could not access $langdir $compdir - please check permissions",2);
exit;
};
fwrite($fh, "<?php\n");
for ($i=0;$i<sizeof($interface);$i++){
fwrite($fh, "define(".$interface[$i].",".($i+$real_interface_size).");\n");
}
fwrite($fh, '?>');
fclose($fh);
if ($dh = opendir($langdir.$prjtransdir)) {
//If dir exists
while (($file = readdir($dh)) !== false) {
//read contents
if ($file==".." or $file=="."){
} else if (substr($file,-3)==".po"){ //only files ending in .po
///////////////////////////////////////////////////////////////////////////////////////////////////
language_log("----------------Compiling project specific $file---------------",0);
$language = parseLanguage($langdir.$prjtransdir.$file, $interface);
if (!$fh = fopen($langdir.$compdir.$file.".inc","a")) { language_log("ERROR: could not access $langdir $compdir - please check permissions",2); exit;};
fwrite($fh, "<?php\n");
$keys = array_keys($language);
for ($i=0;$i<sizeof($interface);$i++){
if ($language[$keys[$i]]!="")
fwrite($fh, "\$language_lookup_array[".($real_interface_size+$keys[$i])."] = \"".addslashes($language[$keys[$i]])."\";\n"); //Translate to PHP
}
fwrite($fh, '?>');
fclose($fh);
//////////////////////////////////////////////////////////////////////////////////////////////////
} else if (substr($file,-3)==".po"){
//only files ending in .po
language_log("----------------Compiling project specific $file---------------",0);
$language = parseLanguage($langdir.$prjtransdir.$file, $interface);
if (!$fh = fopen($langdir.$compdir.$file.".inc","a")) {
language_log("ERROR: could not access $langdir $compdir - please check permissions",2);
exit;
};
fwrite($fh, "<?php\n");
$keys = array_keys($language);
for ($i=0;$i<sizeof($interface);$i++){
if ($language[$keys[$i]]!="") {
fwrite($fh, "\$language_lookup_array[".($real_interface_size+$keys[$i])."] = \"".addslashes($language[$keys[$i]])."\";\n"); //Translate to PHP
}
}
fwrite($fh, '?>');
fclose($fh);
} else {
//debug("File $file with unknown extension found in $info_dir");
}
//debug("File $file with unknown extension found in $info_dir");
}
}
closedir($dh);
} else {
//debug("$info_dir could not be opened - check permissions?");
}
//debug("$info_dir could not be opened - check permissions?");
}
} else {
//debug("$info_dir not found or is not a directory");
//debug("$info_dir not found or is not a directory");
}
@ -162,38 +189,48 @@ function buildLanguages($langdir,$transdir,$prjtransdir,$compdir){
**************************/
function languagesNeedsRebuild($langdir,$transdir,$prjtransdir, $compdir){
if (!file_exists($langdir.$compdir)){ //This directory does not exist - try to create one
mkdir($langdir.$compdir,0733);
return true; //and force an update since we need it
if (!file_exists($langdir.$compdir)){
//This directory does not exist - try to create one
mkdir($langdir.$compdir,0733);
return true;
//and force an update since we need it
}
// return false; //Uncomment this to speed up things when you know that you will manually recompile the languages when updated...
// return false; //Uncomment this to speed up things when you know that you will manually recompile the languages when updated...
$last_compile = filemtime($langdir."last_compile_timer"); //This file gets touched each time a compile finishes
$last_compile = filemtime($langdir."last_compile_timer");
//This file gets touched each time a compile finishes
if (is_dir($langdir.$transdir)) {
if ($dh = opendir($langdir.$transdir)) { //If dir exists
while (($file = readdir($dh)) !== false) { //read contents
if ($dh = opendir($langdir.$transdir)) {
//If dir exists
while (($file = readdir($dh)) !== false) {
//read contents
if ($file==".." or $file=="."){
} else if (substr($file,-3)==".po"){ //only files ending in .po
if (filemtime($langdir.$transdir.$file)>$last_compile) return true;
}
} else if (substr($file,-3)==".po"){
//only files ending in .po
if (filemtime($langdir.$transdir.$file)>$last_compile) return true;
}
}
closedir($dh);
}
}
if (is_dir($langdir.$prjtransdir)) {
if ($dh = opendir($langdir.$prjtransdir)) { //If dir exists
while (($file = readdir($dh)) !== false) { //read contents
if ($dh = opendir($langdir.$prjtransdir)) {
//If dir exists
while (($file = readdir($dh)) !== false) {
//read contents
if ($file==".." or $file=="."){
} else if (substr($file,-3)==".po"){ //only files ending in .po
if (filemtime($langdir.$prjtransdir.$file)>$last_compile) return true;
}
} else if (substr($file,-3)==".po"){
//only files ending in .po
if (filemtime($langdir.$prjtransdir.$file)>$last_compile) return true;
}
}
closedir($dh);
}
}
return false; //All checks say that nothing has changed.
return false;
//All checks say that nothing has changed.
}
/**************************
@ -202,28 +239,34 @@ function languagesNeedsRebuild($langdir,$transdir,$prjtransdir, $compdir){
* The $file is parsed and validated against $interface
*************************/
function parseLanguage($file, $interface){
if (sizeof($interface)<1){ language_log("No interface defined for 'compileLanguages()'",2); exit;}
if (sizeof($interface)<1){
language_log("No interface defined for 'compileLanguages()'",2);
exit;
}
$translation_file = file($file);
$first_entry = true;
for ($i = 0;$i<sizeof($translation_file);$i++){
$entry = ltrim(trim($translation_file[$i]));
//echo $entry;
if (($pos=strpos($entry, "msgid"))!==false){ //If found msgid entry
if (!$first_entry){ //If this is not the first, save the previous entry
//Does token msgid entry exist in interface?
//If so, add to output
$id = checkToken($current_token, $interface, $i);
if ($id!==false){
$output[$id]=$current_token_text;
}
}
$current_token = getPOLineContent($entry);
$current_token_text="";
$first_entry=false; //Now it is no longer the first entry
} elseif (substr($translation_file[$i],0,1)!="#") {
//echo "Else";
$current_token_text.=getPOLineContent($entry);
}
$entry = ltrim(trim($translation_file[$i]));
//echo $entry;
if (($pos=strpos($entry, "msgid"))!==false){
//If found msgid entry
if (!$first_entry){
//If this is not the first, save the previous entry
//Does token msgid entry exist in interface?
//If so, add to output
$id = checkToken($current_token, $interface, $i);
if ($id!==false){
$output[$id]=$current_token_text;
}
}
$current_token = getPOLineContent($entry);
$current_token_text="";
$first_entry=false;
//Now it is no longer the first entry
} elseif (substr($translation_file[$i],0,1)!="#") {
//echo "Else";
$current_token_text.=getPOLineContent($entry);
}
}
$id = checkToken($current_token, $interface, $i);
if ($id!==false){
@ -241,9 +284,9 @@ function checkToken($current_token, $interface, $line){
$id = array_search($current_token,$interface);
if ($id===false){
language_log("Above line ".$line.": Language file $file has a token (".$current_token.") that is not defined in the interface.",1);
return false;
return false;
} else {
return $id;
return $id;
}
}
@ -253,7 +296,7 @@ function checkToken($current_token, $interface, $line){
function checkMissingTokens($language_array, $interface){
$diff = array_values(array_diff( array_keys($interface),array_keys($language_array)));
for ($i=0; $i<sizeof($diff); $i++){
language_log("Language file is missing token (".$interface[$diff[$i]].")",1);
language_log("Language file is missing token (".$interface[$diff[$i]].")",1);
}
}
@ -273,15 +316,16 @@ function getPOLineContent($line){
function tr($tokennumber){
global $language_lookup_array;
if (strval(intval($tokennumber))!=$tokennumber){
echo "token $tokennumber missing from language interface.";
language_log("token $tokennumber missing from language interface.");
echo "token $tokennumber missing from language interface.";
language_log("token $tokennumber missing from language interface.");
}
if (array_key_exists($tokennumber,$language_lookup_array)){ //If language has got the token
//If found in client language, return that
return stripslashes($language_lookup_array[$tokennumber]);
if (array_key_exists($tokennumber,$language_lookup_array)){
//If language has got the token
//If found in client language, return that
return stripslashes($language_lookup_array[$tokennumber]);
}
return "[MISSING TEXT]"; //If not found there display "MISSING TEXT"
return "[MISSING TEXT]"; //If not found there display "MISSING TEXT"
}
function language_log($message, $loglevel=0){
@ -291,9 +335,9 @@ function language_log($message, $loglevel=0){
if ($loglevel==2) $msg = "[ CRITICAL ]";
if ($loglevel>=$lang_log_level){
$fh = fopen($lang_log_file,"a");
fwrite($fh, date("Y-m-d H:i:s",time())." ".$msg." ".$message."\n");
fclose($fh);
$fh = fopen($lang_log_file,"a");
fwrite($fh, date("Y-m-d H:i:s",time())." ".$msg." ".$message."\n");
fclose($fh);
}
}
@ -315,13 +359,13 @@ if (file_exists($lang_language_dir.$lang_compiled_dir."language_interface.inc"))
//cookies have highest priority.
if ($_COOKIE['lang']){
$language_string = $_COOKIE['lang'].",";
$language_string = $_COOKIE['lang'].",";
}
$language_string .= strtolower($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);
//Find out which language to use by iterating trough list
//The list is commaseperated, so split it into an array of the following type:
// Array (
// Array (
// [0] => da
// [1] => en-us;q=0.7
// [2] => en;q=0.3
@ -335,22 +379,32 @@ if (file_exists($lang_language_dir.$lang_compiled_dir."language_interface.inc"))
//we just ignore this attribute. (TODO: don't ignore this attribute)
//A missing quality attribute means q=1
require_once($lang_language_dir.$lang_compiled_dir.$lang_project_default.".po.inc"); //Always include the project default as fallback
for ($i=sizeof($client_languages);$i>=0;$i--){ //Now for each language that the client requests
if (substr($client_languages[$i],2,1)=="_" || substr($client_languages[$i],2,1)=="-"){ //If this is defined as primary-secondary
$language = substr($client_languages[$i],0,2)."_".strtoupper(substr($client_languages[$i],3,2)); //represent it as xx_YY
} else {
$language = substr($client_languages[$i],0,2); //else just use xx
}
if (file_exists($lang_language_dir.$lang_compiled_dir.$language.".po.inc")){ //If we have the language
//echo "[$language]";
require($lang_language_dir.$lang_compiled_dir.$language.".po.inc"); //Include it
}
require_once($lang_language_dir.$lang_compiled_dir.$lang_project_default.".po.inc");
//Always include the project default as fallback
for ($i=sizeof($client_languages);$i>=0;$i--){
//Now for each language that the client requests
if (substr($client_languages[$i],2,1)=="_" || substr($client_languages[$i],2,1)=="-"){
//If this is defined as primary-secondary
$language = substr(
$client_languages[$i],0,2)."_".strtoupper(substr($client_languages[$i],3,2)
);
//represent it as xx_YY
} else {
$language = substr($client_languages[$i],0,2);
//else just use xx
}
if (file_exists($lang_language_dir.$lang_compiled_dir.$language.".po.inc")) {
//If we have the language, include it
//echo "[$language]";
require($lang_language_dir.$lang_compiled_dir.$language.".po.inc");
}
}
} else {
language_log("Could not load language interface.",2);
echo "ERROR: Could not load language interface. This is a fatal error, exitting."; flush; exit;
echo "ERROR: Could not load language interface. This is a fatal error, exitting.";
flush;
exit;
};
?>

View File

@ -29,7 +29,7 @@ while ($wu = mysql_fetch_object($result)) {
mysql_free_result($r2);
$nunsent = $x[0];
if ($nsuccess==3 and $nunsent==0) {
if ($nsuccess>=3 and $nunsent==0) {
echo "WU $wu->id has $nsuccess success, $nunsent unsent \n";
mysql_query("update workunit set need_validate=1 where id=$wu->id");
}

View File

@ -17,13 +17,12 @@ if (parse_bool($config, "disable_account_creation")) {
page_tail();
exit();
}
echo "<p><b>";
printf(tr(CREATE_AC_READ_RULES), "<a href=info.php>".tr(RULES_TITLE)."</a>");
echo "</b></p> <p>";
printf(tr(CREATE_AC_ALREADY_GOT), "<a href=account_created.php>".tr(AC_CREATED_TITLE)."</a>");
echo "
<p><b>"; printf(tr(CREATE_AC_READ_RULES), "<a href=info.php>".tr(RULES_TITLE)."</a>");echo "</b></p>
<p>"; printf(tr(CREATE_AC_ALREADY_GOT), "<a href=account_created.php>".tr(AC_CREATED_TITLE)."</a>"); echo "
</p>
<form action=create_account_action.php method=post>
";
$teamid = get_int("teamid", true);
@ -34,10 +33,8 @@ if ($teamid) {
echo "No such user";
} else {
echo "<b>";
printf(tr(CREATE_AC_TEAM), "<a href=\"show_team.php?teamid=$team->id\">$team->name</a>");
echo "</b>
<p>
";
printf(tr(CREATE_AC_TEAM), "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>");
echo "</b> <p> ";
echo "
<input type=hidden name=teamid value=$teamid>
";

View File

@ -8,23 +8,30 @@ $languages = getSupportedLanguages();
if (get_str("set_lang")){
if (!in_array(get_str("set_lang"), $languages) && get_str("set_lang")!="auto"){
echo "You must select a supported language";
exit;
echo "You must select a supported language";
exit;
} else {
setcookie('lang', get_str("set_lang"), time()+3600*24*365);
header("Location: language_select.php");
flush();
exit;
setcookie('lang', get_str("set_lang"), time()+3600*24*365);
header("Location: language_select.php");
flush();
exit;
}
}
page_head("Language selection");
echo "
<p>This website may be displayed to you in one of the following languages. Usually the server will automatically determine
which language you use but you can override this by clicking on one of the links. Clicking a link will send you a cookie which
stores your language selection on your computer (if you experience any problems please check that your browser accepts
cookies from our domain).</p>";
<p>
This website is available in the following languages.
Normally the choice of language
is determined by your web browser's language settings.
You can override this by clicking on one of the links.
This will send your browser a cookie which
stores your language selection on your computer.
If you experience any problems please check that your browser accepts
cookies from our domain.
</p>
";
echo "<p>The currently selected language is: <em>".tr(LANG_NAME_INTERNATIONAL)."</em> (".tr(LANG_NAME_NATIVE).")</p>";
@ -39,15 +46,18 @@ array_multisort($lang_international, $languages, $lang_native);
for ($i=0; $i<sizeof($languages);$i++){
if (file_exists($imgdir.$languages[$i].".png")){
$im = "<a href=\"language_select.php?set_lang=".$languages[$i]."\"><img height=\"12\" width=\"16\" src=\"".$imgdir.$languages[$i].".png\" border=0></a>";
$im = "<a href=\"language_select.php?set_lang=".$languages[$i]."\"><img height=\"12\" width=\"16\" src=\"".$imgdir.$languages[$i].".png\" border=0></a>";
} else {
$im="";
$im="";
}
row3($im,
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$languages[$i]."</a>",
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$lang_international[$i]." (".$lang_native[$i].")</a>");
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$languages[$i]."</a>",
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$lang_international[$i]." (".$lang_native[$i].")</a>"
);
}
end_table();
echo "<p>You can always go back to automatic language selection by pressing <a href=\"language_select.php?set_lang=auto\">this link</a></p>";
echo "<p>You can always go back to automatic language selection by pressing
<a href=\"language_select.php?set_lang=auto\">this link</a></p>
";
page_tail();
?>