Skip to content

Commit

Permalink
A bunch of changes to allow translation via gettext. Not finished yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
dooglus committed Sep 11, 2011
1 parent 38b71ec commit 075131d
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 163 deletions.
12 changes: 8 additions & 4 deletions 404.php
@@ -1,10 +1,14 @@
<div class='content_box'> <div class='content_box'>
<h3>Page Not Found</h3> <h3><?php echo _("Page Not Found"); ?></h3>

<p> <p>
Sorry, but <a href="<?php echo getenv("REQUEST_URI") ?>">that page</a> no longer exists. <?php printf(_("Sorry, but %sthat page%s no longer exists."),
sprintf('<a href="%s">', getenv("REQUEST_URI")),
"</a>"); ?>
</p> </p>
<p> <p>
<center><img width='300' src="/images/tumblbeasts/tb_sign1.png" /><br/><small>thanks to <a target="_blank" href="http://TheOatmeal.com/">Matthew Inman</a> for the image</small></center> <center><img width='300' src="/images/tumblbeasts/tb_sign1.png" /><br/><small>
<?php printf(_("thanks to %sMatthew Inman%s for the image"),
'<a target="_blank" href="http://TheOatmeal.com/">',
"</a>"); ?></small></center>
</p> </p>
</div> </div>
23 changes: 12 additions & 11 deletions add_cash.php
Expand Up @@ -31,8 +31,8 @@ function show_similar_codes($reference)
if ($score >= 50) { if ($score >= 50) {
if ($first) { if ($first) {
$first = false; $first = false;
echo "<p>Did you mean one of these? Higher percentage = closer match.</p>\n"; echo "<p>" . _("Did you mean one of these? Higher percentage = closer match.") . "</p>\n";
echo "<p>Click an entry to copy it to the form below, then click 'Deposit' again.</p>\n"; echo "<p>" . _("Click an entry to copy it to the form below, then click 'Deposit' again.") . "</p>\n";
echo "<table class='display_data'>\n"; echo "<table class='display_data'>\n";
} }
echo "<tr", echo "<tr",
Expand All @@ -56,7 +56,7 @@ function show_similar_codes($reference)
} }


echo "<div class='content_box'>\n"; echo "<div class='content_box'>\n";
echo "<h3>Deposit cash</h3>\n"; echo "<h3>" . _("Deposit cash") . "</h3>\n";


if (!$is_admin) throw new Error("GTFO", "How did you get here?"); if (!$is_admin) throw new Error("GTFO", "How did you get here?");


Expand All @@ -78,15 +78,16 @@ function show_similar_codes($reference)
VALUES ('DEPOS', '" . CURRENCY . "', $user, $amount_internal) VALUES ('DEPOS', '" . CURRENCY . "', $user, $amount_internal)
"; ";
do_query($query); do_query($query);
echo "<p><span style='font-weight: bold;'>added request to deposit $amount " . CURRENCY . printf("<p><span style='font-weight: bold;'>" . _("added request to deposit %s to user %s's purse (reference %s)") . "</span></p>\n",
" to user $user's purse (reference $reference)</span></p>\n"; ($amount . " " . CURRENCY), $user, $reference);
echo "<p>deposit should show up in their account <string>in a minute or two</strong></p>\n"; echo "<p>" . _("deposit should show up in their account") . " <string>" . _("in a minute or two") . "</strong></p>\n";
echo "<p>make another deposit?</p>\n"; echo "<p>" . _("make another deposit?") . "</p>\n";
$amount= $reference = ''; $amount= $reference = '';
} else { } else {
echo "<p>'$reference' isn't a valid reference code\n"; printf("<p>" . _("'%s' isn't a valid reference code") . "</p>\n",
$reference);
show_similar_codes($reference); show_similar_codes($reference);
echo "<p>try again?</p>\n"; echo "<p>" . _("try again?") . "</p>\n";
} }
} else } else
$amount = $reference = ''; $amount = $reference = '';
Expand All @@ -95,10 +96,10 @@ function show_similar_codes($reference)
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" /> <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='hidden' name='deposit_cash' value='true' /> <input type='hidden' name='deposit_cash' value='true' />


<label for='reference'>Reference</label> <label for='reference'><?php echo _("Reference"); ?></label>
<input id='reference' type='text' name='reference' value='<?php echo $reference; ?>'/> <input id='reference' type='text' name='reference' value='<?php echo $reference; ?>'/>


<label for='amount'>Amount</label> <label for='amount'><?php echo _("Amount"); ?></label>
<input id='amount' type='text' name='amount' value='<?php echo $amount; ?>' /> <input id='amount' type='text' name='amount' value='<?php echo $amount; ?>' />


<input type='submit' value='Deposit' /> <input type='submit' value='Deposit' />
Expand Down
24 changes: 13 additions & 11 deletions commission.php
Expand Up @@ -14,7 +14,7 @@ function active_table_cell($uid, $txid, $orderid, $sub, $amount, $precision)
echo "</div>\n"; echo "</div>\n";


echo "<div class='content_box'>\n"; echo "<div class='content_box'>\n";
echo "<h3>Commission</h3>\n"; echo "<h3>" . _("Commission") . "</h3>\n";


$query = " $query = "
SELECT txid, SELECT txid,
Expand Down Expand Up @@ -50,12 +50,12 @@ function active_table_cell($uid, $txid, $orderid, $sub, $amount, $precision)
echo "<th style='text-align: center;' colspan=2>BTC</th>"; echo "<th style='text-align: center;' colspan=2>BTC</th>";
echo "</tr>"; echo "</tr>";
echo "<tr>"; echo "<tr>";
echo "<th>TID</th>"; echo "<th>" . _("TID") . "</th>";
echo "<th>Got</th>"; echo "<th>" . _("Got") . "</th>";
echo "<th>Fee</th>"; echo "<th>" . _("Fee") . "</th>";
echo "<th>Got</th>"; echo "<th>" . _("Got") . "</th>";
echo "<th>Fee</th>"; echo "<th>" . _("Fee") . "</th>";
echo "<th>Date</th>"; echo "<th>" . _("Date") . "</th>";
echo "</tr>"; echo "</tr>";
} }


Expand Down Expand Up @@ -111,10 +111,12 @@ function active_table_cell($uid, $txid, $orderid, $sub, $amount, $precision)
} }


$commissions = fetch_balances('1'); $commissions = fetch_balances('1');
echo "<p>In the commission purse, there is ", printf("<p>" . _("In the commission purse, there is %s %s and %s %s.") . "\n",
internal_to_numstr($commissions[CURRENCY], FIAT_PRECISION), " " . CURRENCY . " and ", internal_to_numstr($commissions[CURRENCY], FIAT_PRECISION),
internal_to_numstr($commissions['BTC'], BTC_PRECISION), " BTC.\n"; CURRENCY,
echo "Hopefully that matches with the totals shown above.</p>\n"; internal_to_numstr($commissions['BTC'], BTC_PRECISION),
"BTC");
echo _("Hopefully that matches with the totals shown above.") . "</p>\n";
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var tx = []; var tx = [];
Expand Down
2 changes: 1 addition & 1 deletion db.php
Expand Up @@ -12,7 +12,7 @@ function do_query($query)
// echo "query: $query<br/>\n"; // echo "query: $query<br/>\n";
$result = mysql_query($query); $result = mysql_query($query);
if (!$result) if (!$result)
throw new Error("MySQL Error", mysql_error()); throw new Error(_("MySQL Error"), mysql_error());
return $result; return $result;
} }
function has_results($result) function has_results($result)
Expand Down
95 changes: 56 additions & 39 deletions deposit.php
Expand Up @@ -21,7 +21,7 @@ function show_deposit_voucher_form($code = '')
{ ?> { ?>
<p> <p>
<form action='' class='indent_form' method='post'> <form action='' class='indent_form' method='post'>
<label for='input_code'>Voucher</label> <label for='input_code'><?php echo _("Voucher"); ?></label>
<input type='text' onClick='select();' autocomplete='off' id='input_code' name='code' value='<?php echo $code; ?>' /> <input type='text' onClick='select();' autocomplete='off' id='input_code' name='code' value='<?php echo $code; ?>' />
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" /> <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='submit' value='Submit' /> <input type='submit' value='Submit' />
Expand All @@ -32,16 +32,16 @@ function show_deposit_voucher_form($code = '')


if (isset($_POST['code'])) { if (isset($_POST['code'])) {
echo "<div class='content_box'>\n"; echo "<div class='content_box'>\n";
echo "<h3>Deposit Voucher</h3>\n"; echo "<h3>" . _("Deposit Voucher") . "</h3>\n";
$code = post('code', '-'); $code = post('code', '-');
try { try {
redeem_voucher($code, $is_logged_in); redeem_voucher($code, $is_logged_in);
echo "<p>got any more?</p>\n"; echo "<p>" . _("got any more?") . "</p>\n";
show_deposit_voucher_form($code); show_deposit_voucher_form($code);
} catch (Exception $e) { } catch (Exception $e) {
$message = $e->getMessage(); $message = $e->getMessage();
echo "<p>error: $message</p>\n"; echo "<p>" . _("error") . ": $message</p>\n";
echo "<p>try again?</p>\n"; echo "<p>" . _("try again?") . "</p>\n";
show_deposit_voucher_form($code); show_deposit_voucher_form($code);
} }
echo "</div>\n"; echo "</div>\n";
Expand All @@ -67,68 +67,85 @@ function show_deposit_voucher_form($code = '')
?> ?>


<div class='content_box'> <div class='content_box'>
<h3>Deposit Voucher</h3> <h3><?php echo _("Deposit Voucher"); ?></h3>
<p>It's possible to withdraw BTC or <?php echo CURRENCY; ?> as 'vouchers' on the <p><?php printf(
_("It's possible to withdraw BTC or %s as 'vouchers' on the
withdraw page. These vouchers can be given to other exchange withdraw page. These vouchers can be given to other exchange
users and redeemed here. users and redeemed here."), CURRENCY); ?>
</p> </p>
<p> <p><?php printf(
If you have received a voucher for this exchange, please _("If you have received a voucher for this exchange, please
copy/paste the voucher code into the box below to redeem it. copy/paste the voucher code into the box below to redeem it.")); ?>
</p> </p>
<p> <p><?php printf(
We also accept MTGOX-<?php echo CURRENCY; ?>-... vouchers for instant transfers _("We also accept MTGOX-%s-... vouchers for instant transfers
of <?php echo CURRENCY; ?> from MtGox to this exchange. of %s from MtGox to this exchange."), CURRENCY, CURRENCY); ?>
</p> </p>
<?php show_deposit_voucher_form(); ?> <?php show_deposit_voucher_form(); ?>
</div> </div>


<div class='content_box'> <div class='content_box'>
<h3>Deposit <?php echo CURRENCY; ?></h3> <h3><?php echo _("Deposit") . " " . CURRENCY; ?></h3>
<p><b>Depositing is free by bank deposit (EFT). You are responsible for paying any incurred fees. If your deposit is insufficient to cover bank fees then it will be denied.</b></p> <p><b><?php echo _("Depositing is free by bank deposit (EFT). You are responsible for paying any incurred fees. If your deposit is insufficient to cover bank fees then it will be denied."); ?></b></p>
<p>You will need to quote <?php echo $deposref; ?> in the transaction's reference field.</p> <p><?php printf(_("You will need to quote <strong>%s</strong> in the transaction's reference field."), $deposref); ?></p>
<table class='display_data'> <table class='display_data'>
<tr> <tr>
<td>Account title:</td> <td><?php echo _("Account title") . ":"; ?></td>
<td>High Net Worth Property PTY LTD</td> <td><?php echo DEPOSIT_BANK_ACCOUNT_TITLE; ?></td>
</tr> </tr>
<tr> <tr>
<td>Bank:</td> <td><?php echo _("Bank") . ":"; ?></td>
<td>ANZ</td> <td><?php echo DEPOSIT_BANK_NAME; ?></td>
</tr> </tr>
<tr> <tr>
<td>Account number:</td> <td><?php echo _("Account number") . ":"; ?></td>
<td>2034-65422</td> <td><?php echo DEPOSIT_BANK_ACCOUNT_NUMBER; ?></td>
</tr> </tr>
<tr> <tr>
<td>BSB:</td> <td><?php echo _("BSB") . ":"; ?></td>
<td>014-506</td> <td><?php echo DEPOSIT_BANK_BRANCH_ID; ?></td>
</tr> </tr>
<tr> <tr>
<td>Reference:</td> <td><?php echo _("Reference") . ":"; ?></td>
<td><?php echo $deposref; ?></td> <td><?php echo $deposref; ?></td>
</tr> </tr>
</table> </table>
<p>Allow 3-5 working days for payments to pass through clearing.</p> <p><?php echo _("Allow 3-5 working days for payments to pass through clearing."); ?></p>
<p><b>Online Banking select your bank below to login.</b></p> <p><b><?php echo _("Online Banking select your bank below to login."); ?></b></p>
<p><a href="https://www.my.commbank.com.au/netbank/Logon/Logon.aspx" target="_blank" >CBA</a> - <a href="https://www.anz.com/INETBANK/bankmain.asp" target="_blank" >ANZ</a> - <p>
<a href="https://online.westpac.com.au/esis/Login/SrvPage/?h3&app=wol&referrer=http%3A%2F%2Fwww.westpac.com.au%2FHomepageAlternative%2F" target="_blank" >WESTPAC</a> - <a target="_blank"
<a href="https://ib.nab.com.au/nabib/index.jsp" target="_blank" >NAB</a> - href="https://www.my.commbank.com.au/netbank/Logon/Logon.aspx"
<a href="http://www.google.com.au/" target="_blank" >Other</a></p> >CBA</a>
<br> -
<a target="_blank"
href="https://www.anz.com/INETBANK/bankmain.asp"
>ANZ</a>
-
<a target="_blank"
href="https://online.westpac.com.au/esis/Login/SrvPage/?h3&app=wol&referrer=http%3A%2F%2Fwww.westpac.com.au%2FHomepageAlternative%2F"
>WESTPAC</a>
-
<a target="_blank"
href="https://ib.nab.com.au/nabib/index.jsp"
>NAB</a>
-
<a target="_blank"
href="http://www.google.com.au/"
>Other</a>
</p><br/>
<strong><p>For fast 24Hr clearing visit any ANZ bank to deposit funds.</p></strong> <strong><p>For fast 24Hr clearing visit any ANZ bank to deposit funds.</p></strong>
<p>(you will be required to use your<strong><a href="?page=profile"> 'User ID'</a></strong> as reference)</p></br> <p>(you will be required to use your<strong><a href="?page=profile"> 'User ID'</a></strong> as reference)</p><br/>


</div> </div>


<div class='content_box'> <div class='content_box'>
<h3>Deposit BTC</h3> <h3><?php echo _("Deposit"); ?> BTC</h3>
<?php <?php
if ($addy) { if ($addy) {
echo " <p>You can deposit to <b>$addy</b></p>\n"; echo " <p>" . sprintf(_("You can deposit to %s"), "<b>$addy</b>") . "</p>\n";
echo " <p>The above address is specific to your account. Each time you deposit, a new address will be generated for you.</p>\n"; echo " <p>" . _("The above address is specific to your account. Each time you deposit, a new address will be generated for you.") . "</p>\n";
echo " <p>It takes ", CONFIRMATIONS_FOR_DEPOSIT, " confirmations before funds are added to your account.</p>\n"; echo " <p>" . sprintf(_("It takes %s confirmations before funds are added to your account."), CONFIRMATIONS_FOR_DEPOSIT) . "</p>\n";
} else } else
echo " <p>We are currently experiencing trouble connecting to the Bitcoin network. Please try again in a few minutes.</p>\n"; echo " <p>" . _("We are currently experiencing trouble connecting to the Bitcoin network. Please try again in a few minutes.") . "</p>\n";
echo "</div>\n"; echo "</div>\n";
} }
2 changes: 1 addition & 1 deletion errors.php
Expand Up @@ -94,7 +94,7 @@ function report_exception($e, $severity)
$message = $e->getMessage(); $message = $e->getMessage();
$file = $e->getFile(); $file = $e->getFile();
$line = $e->getLine(); $line = $e->getLine();
report("Exception: $file $line\n==== $title ====\n$message\n================", $severity); report(_("Exception") . ": $file $line\n==== $title ====\n$message\n================", $severity);
} }


function reporting_error_handler($errno, $errstr, $errfile, $errline) function reporting_error_handler($errno, $errstr, $errfile, $errline)
Expand Down
30 changes: 15 additions & 15 deletions footer.php
Expand Up @@ -19,21 +19,21 @@ function show_links($is_logged_in, $is_admin)
$show_duo = !$row['use_duo']; $show_duo = !$row['use_duo'];
} }


if (!$is_logged_in) show_link('login', 'Login', 'Begin here' ); if (!$is_logged_in) show_link('login', _('Login'), _('Begin here') );
show_link ('trade', 'Trade', 'Buy and sell' ); show_link ('trade', _('Trade'), _('Buy and sell') );
if ($is_logged_in) show_link('profile', 'Profile', 'Dox on you' ); if ($is_logged_in) show_link('profile', _('Profile'), _('Dox on you') );
if ($is_logged_in) show_link('statement', 'Statement', 'Chronological ledger' ); if ($is_logged_in) show_link('statement', _('Statement'), _('Chronological ledger') );
if ($is_logged_in) show_link('deposit', 'Deposit', 'Top up your account' ); if ($is_logged_in) show_link('deposit', _('Deposit'), _('Top up your account') );
if ($is_logged_in) show_link('withdraw', 'Withdraw', 'Take out money' ); if ($is_logged_in) show_link('withdraw', _('Withdraw'), _('Take out money') );
show_link ('orderbook', 'Orderbook', 'Show orders' ); show_link ('orderbook', _('Orderbook'), _('Show orders') );
if ($show_duo) show_link('turn_on_duo', 'Security', 'Use two-factor authentification'); if ($show_duo) show_link('turn_on_duo', _('Security'), _('Use two-factor authentification') );
show_link ('help', 'Help', 'Seek support' ); show_link ('help', _('Help'), _('Seek support') );
if ($is_admin) show_link('users', 'Users', 'Show registered users', 1); if ($is_admin) show_link('users', _('Users'), _('Show registered users'), 1);
if ($is_admin) show_link('add_cash', 'Add cash', 'Deposit using bank statement', 1); if ($is_admin) show_link('add_cash', _('Add cash'), _('Deposit using bank statement'), 1);
if ($is_admin) show_link('commission', 'Commission', 'Show commission statement', 1); if ($is_admin) show_link('commission', _('Commission'), _('Show commission statement'), 1);
if ($is_admin) show_link('bank', 'Bank', 'Show bank statement &amp; pending withdrawals',1); if ($is_admin) show_link('bank', _('Bank'), _('Show bank statement &amp; pending withdrawals'), 1);
if ($is_admin) show_link('freeze', 'Freeze', 'Stop activity on the exchange',1); if ($is_admin) show_link('freeze', _('Freeze'), _('Stop activity on the exchange'), 1);
if ($is_logged_in) show_link('logout', 'Logout', 'End this session' ); if ($is_logged_in) show_link('logout', _('Logout'), _('End this session') );
} }


function show_footer($is_logged_in, $is_admin) function show_footer($is_logged_in, $is_admin)
Expand Down
19 changes: 9 additions & 10 deletions freeze.php
Expand Up @@ -11,35 +11,34 @@
} }


echo "<div class='content_box'>\n"; echo "<div class='content_box'>\n";
echo "<h3>Freeze!</h3>\n"; echo "<h3>" . _("Freeze!") . "</h3>\n";


if (isset($_POST['set_freeze'])) { if (isset($_POST['set_freeze'])) {
$state = post('set_freeze'); $state = post('set_freeze');


if ($state == 'freeze') { if ($state == 'freeze') {
set_frozen(true); set_frozen(true);
echo "<p>Exchange has been frozen. <a href=".">continue</a></p>\n"; echo "<p>" . _("Exchange has been frozen.") . ' <a href=".">' . _("continue") . "</a></p>\n";
} else if ($state == 'unfreeze') { } else if ($state == 'unfreeze') {
set_frozen(false); set_frozen(false);
echo "<p>Exchange has been unfrozen. <a href=".">continue</a></p>\n"; echo "<p>" . _("Exchange has been unfrozen.") . ' <a href=".">' . _("continue") . "</a></p>\n";
} else } else
throw Error("Unknown state", "State $state should be 'freeze' or 'unfreeze'."); throw Error("Unknown state", "State $state should be 'freeze' or 'unfreeze'.");
} else { } else {
$is_frozen = is_frozen(); $is_frozen = is_frozen();
if ($is_frozen) { if ($is_frozen) {
echo "<p>The exchange is currently frozen.</p>\n"; echo "<p>" . _("The exchange is currently frozen.") . "</p>\n";
echo "<p>Click 'unfreeze' below to resume order matching and withdrawal processing.</p>\n"; echo "<p>" . _("Click 'unfreeze' below to resume order matching and withdrawal processing.") . "</p>\n";
} else { } else {
echo "<p>The exchange isn't currently frozen.</p>\n"; echo "<p>" . _("The exchange isn't currently frozen.") . "</p>\n";
echo "<p>Click 'freeze' below to freeze order matching and withdrawal processing.</p>\n"; echo "<p>" . _("Click 'freeze' below to freeze order matching and withdrawal processing.") . "</p>\n";
echo "<p>Users will still be able to place and cancel orders,\n"; echo "<p>" . _("Users will still be able to place and cancel orders, they just won't be matched until after you unfreeze the exchange.") . "</p>\n";
echo "they just won't be matched until after you unfreeze the exchange.</p>\n";
} }
?> ?>
<form action='' class='indent_form' method='post'> <form action='' class='indent_form' method='post'>
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" /> <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='hidden' name='set_freeze'' value='<?php echo $is_frozen ? "unfreeze" : "freeze" ?>' /> <input type='hidden' name='set_freeze'' value='<?php echo $is_frozen ? "unfreeze" : "freeze" ?>' />
<input type='submit' value='<?php echo $is_frozen ? "Unfreeze" : "Freeze" ?>' /> <input type='submit' value='<?php echo $is_frozen ? _("Unfreeze") : _("Freeze") ?>' />
</form> </form>
<?php <?php
} }
Expand Down

0 comments on commit 075131d

Please sign in to comment.