diff options
-rw-r--r-- | include/cancelgame.php | 14 | ||||
-rw-r--r-- | include/game.php | 96 | ||||
-rw-r--r-- | include/newgame.php | 42 | ||||
-rw-r--r-- | include/reminder.php | 29 | ||||
-rw-r--r-- | include/user.php | 8 |
5 files changed, 114 insertions, 75 deletions
diff --git a/include/cancelgame.php b/include/cancelgame.php index df6e98d..a6a4fe9 100644 --- a/include/cancelgame.php +++ b/include/cancelgame.php @@ -52,22 +52,24 @@ $myname = DB_get_name('hash',$me); $r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " ); if(time()-strtotime($r[0]) > 60*60*24*30) /* = 1 month */ { - $message = "Game ".DB_format_gameid($gameid). - " has been canceled since nothing happend for a while and $myname requested it.\n\n"; - /* email to all players */ $userids = DB_get_all_userid_by_gameid($gameid); foreach($userids as $user) { + set_language($user, 'uid'); + $message = sprintf(_('Game %s has been canceled since nothing happend for a while and %s requested it.'),DB_format_gameid($gameid),$myname)."\n\n"; + mymail($user,$gameid, GAME_CANCELED_TIMEOUT, $message); } + set_language($myid, 'uid'); /* set gamestatus to canceled */ cancel_game('timedout',$gameid); - echo "<p style=\"background-color:red\";>Game ".DB_format_gameid($gameid). - " has been canceled.<br /><br /></p>"; + echo '<p style="background-color:red";>'. + sprintf(_('Game %s has been canceled.'),DB_format_gameid($gameid)). + "<br /><br /></p>\n"; } else /* game can't be canceled yet */ - echo "<p>You need to wait longer before you can cancel a game...</p>\n"; + echo "<p>"._('You need to wait longer before you can cancel a game...')."</p>\n"; ?>
\ No newline at end of file diff --git a/include/game.php b/include/game.php index 177b7f3..16359ed 100644 --- a/include/game.php +++ b/include/game.php @@ -492,12 +492,15 @@ switch($mystatus) if(!$skip && $_REQUEST['in'] == 'no' ) { /* cancel the game */ - $email_message = "Hello, \n\n". - "the game has been canceled due to the request of one of the players.\n\n"; - $userids = DB_get_all_userid_by_gameid($gameid); foreach($userids as $user) + { + set_language($user,'uid'); + $email_message = _("Hello, \n\n". + "the game has been canceled due to the request of one of the players.")."\n\n"; mymail($user,$gameid,GAME_CANCELED,$email_message); + }; + set_language($myid,'uid'); $card_status = CARDS_EMPTY; @@ -694,36 +697,47 @@ switch($mystatus) /* cancel game */ if($cancelsick == 'nines') { - $email_message = 'The game has been canceled because '.DB_get_name('userid',$cancel). - " has five or more nines and nobody is playing solo.\n\n". - "To redeal either start a new game or, in case the game was part of a tournament,\n". - "go to the last game and use the link at the bottom of the page to redeal.\n\n"; - /* update game status */ cancel_game('nines',$gameid); - $messages[] = 'The game has been canceled because '.DB_get_name('userid',$cancel). - " has five or more nines and nobody is playing solo."; + $messages[] = sprintf(_('The game has been canceled because %s'. + ' has five or more nines and nobody is playing solo.'),DB_get_name('userid',$cancel) ); } else if ($cancelsick == 'lowtrump') { - $email_message = 'The game has been canceled because '.DB_get_name('userid',$cancel). - " has low trump and nobody is playing solo.\n\n". - "To redeal either start a new game or, in case the game was part of a tournament,\n". - "go to the last game and use the link at the bottom of the page to redeal.\n\n"; - /* update game status */ cancel_game('lowtrump',$gameid); - $messages[] = 'The game has been canceled because '.DB_get_name('userid',$cancel). - ' has low trump and nobody is playing solo.'; + $messages[] = sprintf(('The game has been canceled because %s'. + ' has low trump and nobody is playing solo.'),DB_get_name('userid',$cancel)); }; $userids = DB_get_all_userid_by_gameid($gameid); foreach($userids as $user) { + set_language($user,'uid'); + if($cancelsick == 'nines') + { + $email_message = sprintf(_('The game has been canceled because %s'. + ' has five or more nines and nobody is playing solo.'),DB_get_name('userid',$cancel) ). + "\n\n". + _("To redeal either start a new game or, in case the game was part of a tournament,\n". + "go to the last game and use the link at the bottom of the page to redeal."). + "\n\n"; + } + else if ($cancelsick == 'lowtrump') + { + $email_message = sprintf(_('The game has been canceled because %s'. + " has low trump and nobody is playing solo."),DB_get_name('userid',$cancel)). + "\n\n". + _("To redeal either start a new game or, in case the game was part of a tournament,\n". + "go to the last game and use the link at the bottom of the page to redeal."). + "\n\n"; + }; + mymail($user,$gameid, GAME_CANCELED, $email_message); } + set_language($myid,'uid'); break; } @@ -856,9 +870,11 @@ switch($mystatus) if(DB_get_email_pref_by_hash($hash)!='emailaddict') { /* email startplayer */ - $email_message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". - "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + set_language($userid,'uid'); + $email_message = sprintf(_("It's your turn now in game %s.\n". + "Use this link to play a card:"),DB_format_gameid($gameid))." ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; mymail($userid,$gameid,GAME_READY,$email_message); + set_language($myid,'uid'); } } else @@ -881,9 +897,11 @@ switch($mystatus) if(DB_get_email_pref_by_hash($hash)!='emailaddict') { /* email player for poverty */ - $email_message = "Poverty: It's your turn now in game ".DB_format_gameid($gameid).".\n". - 'Use this link to play a card: '.$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ; + set_language($whoid,'uid'); + $email_message = sprintf(_("Poverty: It's your turn now in game %s.\n". + 'Use this link to play a card: '),DB_format_gameid($gameid)).$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ; mymail($whoid,$gameid,GAME_POVERTY,$email_message); + set_language($myid,'uid'); } } } @@ -952,9 +970,11 @@ switch($mystatus) if(DB_get_email_pref_by_hash($hash)!='emailaddict') { /* email startplayer */ - $email_message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". - 'Use this link to play a card: '.$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + set_language($userid,'uid'); + $email_message = sprintf(_("It's your turn now in game %s.\n". + 'Use this link to play a card: '),DB_format_gameid($gameid)).$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; mymail($userid,$gameid,GAME_READY,$email_message); + set_language($myid,'uid'); } } else @@ -1025,14 +1045,16 @@ switch($mystatus) /* no more people to ask, need to cancel the game */ if($mypos+$next>4) { - $email_message = "Hello, \n\n". - 'Game '.DB_format_gameid($gameid)." has been canceled since nobody wanted to take the trump.\n\n"; - $userids = DB_get_all_userid_by_gameid($gameid); foreach($userids as $user) { + set_language($user,'uid'); + $email_message = sprintf("Hello, \n\n". + 'Game %s has been canceled since nobody wanted to take the trump.',DB_format_gameid($gameid)). + "\n\n"; mymail($user, $gameid, GAME_CANCELED_POVERTY, $email_message); } + set_language($myid,'uid'); /* update game status */ cancel_game('trump',$gameid); @@ -1049,9 +1071,11 @@ switch($mystatus) DB_set_player_by_gameid($gameid,$userid); DB_set_hand_status_by_hash($userhash,'poverty'); - $email_message = "Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:". + set_language($userid,'uid'); + $email_message = _("Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:"). " ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ; mymail($userid,$gameid, GAME_POVERTY, $email_message); + set_language($myid,'uid'); } $cards_status = CARDS_SHOW; @@ -1142,9 +1166,11 @@ switch($mystatus) DB_set_player_by_gameid($gameid,$userid); DB_set_hand_status_by_hash($userhash,'poverty'); - $email_message = "Two people have poverty, it's your turn to decide, if you want to take the trump. Please visit:". + set_langauge($userid,'uid'); + $email_message = _("Two people have poverty, it's your turn to decide, if you want to take the trump. Please visit:"). " ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ; mymail($userid,$gameid, GAME_DPOVERTY, $email_message); + set_language($myid,'uid'); } } $messages[] = "Please, <a href=\"$INDEX?action=game&me=$me\">continue</a> here"; @@ -1214,9 +1240,11 @@ switch($mystatus) if($hash!=$me && DB_get_email_pref_by_hash($hash)!='emailaddict') { /* email startplayer) */ - $email_message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". - 'Use this link to play a card: '.$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + set_language($userid,'uid'); + $email_message = sprintf(_("It's your turn now in game %s.\n". + 'Use this link to play a card: '),DB_format_gameid($gameid)).$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; mymail($userid,$gameid, GAME_READY, $email_message); + set_language($myid,'uid'); } } } @@ -1666,12 +1694,14 @@ switch($mystatus) $userid = DB_get_userid('hash',$next_hash); DB_set_player_by_gameid($gameid,$userid); - $email_message = 'A card has been played in game '.DB_format_gameid($gameid).".\n\n". - "It's your turn now.\n". - 'Use this link to play a card: '.$HOST.$INDEX.'?action=game&me='.$next_hash."\n\n" ; if( DB_get_email_pref_by_uid($userid)!='emailaddict' ) { + set_language($userid,'uid'); + $email_message = sprintf(_("A card has been played in game %s.\n\n". + "It's your turn now.\n". + 'Use this link to play a card: '),DB_format_gameid($gameid)).$HOST.$INDEX.'?action=game&me='.$next_hash."\n\n" ; mymail($userid,$gameid, GAME_YOUR_TURN, $email_message); + set_language($myid,'uid'); } } else /* send out final email */ diff --git a/include/newgame.php b/include/newgame.php index b29cc56..a5d35c6 100644 --- a/include/newgame.php +++ b/include/newgame.php @@ -27,7 +27,7 @@ if(!isset($HOST)) /* user needs to be logged in to do this */ if(! isset($_SESSION["name"]) ) { - echo "<div class=\"message\">Please <a href=\"$INDEX\">log in</a>.</div>"; + echo '<div class="message">'._('Please')." <a href=\"$INDEX\">"._('log in')."</a>.</div>\n"; } else { @@ -72,7 +72,7 @@ else /* the person who sets up the game has to be one of the players */ if(!in_array($name,array($PlayerA,$PlayerB,$PlayerC,$PlayerD))) { - echo "<div class=\"message\">You need to be one of the players to start a <a href=\"$INDEX?action=new\">new game</a>.</div>"; + echo '<div class="message">'."You need to be one of the players to start a <a href=\"$INDEX?action=new\">new game</a>.</div>\n"; return; } @@ -91,7 +91,7 @@ else /* this is used to check if the player names are all ok */ if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="") { - echo "couldn't find one of the names, please start a new game"; + echo _("couldn't find one of the names, please start a new game"); return; } @@ -190,22 +190,26 @@ else DB_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')"); /* send out email, TODO: check for error with email */ - $message = "You are invited to play a game of DoKo.\n". - "Please, place comments and bug reports here:\n$WIKI\n\n". - "The whole round would consist of the following players:\n". - "$PlayerA\n". - "$PlayerB\n". - "$PlayerC\n". - "$PlayerD\n\n". - "If you want to join this game, please follow this link:\n". - "".$HOST.$INDEX."?action=game&me="; - - mymail($useridA, $gameid, GAME_NEW, $message.$hashA."\n\n"); - mymail($useridB, $gameid, GAME_NEW, $message.$hashB."\n\n"); - mymail($useridC, $gameid, GAME_NEW, $message.$hashC."\n\n"); - mymail($useridD, $gameid, GAME_NEW, $message.$hashD."\n\n"); - - echo "<div class=\"message\">You started a new game. The emails have been sent out!</div>\n"; + + $users = array( $useridA => $hashA, $useridB => $hashB, $useridC => $hashC, $useridD => $hashD ); + foreach ( $users as $uid => $hash ) + { + set_language($uid,'uid'); + $message = _('You are invited to play a game of DoKo.')."\n". + _('Please, place comments and bug reports here:')."\n$WIKI\n\n". + _('The whole round would consist of the following players:')."\n". + "$PlayerA\n". + "$PlayerB\n". + "$PlayerC\n". + "$PlayerD\n\n". + _('If you want to join this game, please follow this link:')."\n". + "".$HOST.$INDEX."?action=game&me="; + + mymail($uid, $gameid, GAME_NEW, $message.$hash."\n\n"); + }; + set_language($myid,'uid'); + + echo '<div class="message">'._('You started a new game. The emails have been sent out!')."</div>\n"; display_user_menu($myid); } } diff --git a/include/reminder.php b/include/reminder.php index ba872a9..9d10b95 100644 --- a/include/reminder.php +++ b/include/reminder.php @@ -51,28 +51,31 @@ $myname = DB_get_name('hash',$me); $r = DB_query_array("SELECT mod_date,player,status from Game WHERE id='$gameid' " ); if( (time()-strtotime($r[0]) > 60*60*24*7) && ($r[2]!='gameover') ) /* = 1 week */ { - $name = DB_get_name('userid',$r[1]); - $userhash = DB_get_hash_from_gameid_and_userid($gameid,$r[1]); - - $message = "It's your turn in game ".DB_format_gameid($gameid)." \n". - "Actually everyone else is waiting for you for more than a week now ;)\n\n". - "Please visit this link now to continue: \n". - " ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ; + $uid = $r[1]; + $name = DB_get_name('userid',$uid); + $userhash = DB_get_hash_from_gameid_and_userid($gameid,$uid); /* make sure we don't send too many reminders to one person */ - if(DB_get_reminder($r[1],$gameid)>0) + if(DB_get_reminder($uid,$gameid)>0) { - echo "<p>An email has already been sent out.</p>\n"; + echo '<p>'._('An email has already been sent out.')."</p>\n"; } else { - DB_set_reminder($r[1],$gameid); + set_language($uid,'uid'); + $message = _("It's your turn in game ").DB_format_gameid($gameid)." \n". + _("Actually everyone else is waiting for you for more than a week now ;)")."\n\n". + _("Please visit this link now to continue").": \n". + " ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ; + + DB_set_reminder($uid,$gameid); mymail($r[1],$gameid, GAME_REMINDER, $message); + set_language($myid,'uid'); - echo "<p style=\"background-color:red\";>Game ".DB_format_gameid($gameid). - ": an email has been sent out.<br /><br /></p>"; + echo '<p>'._('Game')." ".DB_format_gameid($gameid).': '. + _('an email has been sent out.')."<br /><br /></p>\n"; } } else - echo '<p>You need to wait longer before you can send out a reminder...</p>\n'; + echo '<p>'._('You need to wait longer before you can send out a reminder...')."</p>\n"; ?>
\ No newline at end of file diff --git a/include/user.php b/include/user.php index 551e7d5..a80fddd 100644 --- a/include/user.php +++ b/include/user.php @@ -64,12 +64,12 @@ if(myisset('forgot')) $hash = md5('Anewpassword'.$email.$TIME); $newpw = substr($hash,1,8); - $message = "Someone (hopefully you) requested a new password. \n". - "You can use this email and the following password: \n". - " $newpw \n". + $message = sprintf( _("Someone (hopefully you) requested a new password.\n". + "You can use this email and the following password:\n". + " %s\n". "to log into the server. The new password is valid for 24h, so make\n". "sure you reset your password to something new. Your old password will\n". - "also still be valid until you set a new one.\n"; + "also still be valid until you set a new one.\n"), $newpw); mymail($myid,0, GAME_RECOVERY, $message); /* we save these in the database */ |