Skip to content

Commit

Permalink
Merge pull request #13 from cmengler/feature/bootstrap
Browse files Browse the repository at this point in the history
Bootstrap 3 theme
  • Loading branch information
erickok committed Apr 20, 2018
2 parents 788cb63 + 0d0f47a commit 3bf97b7
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 82 deletions.
2 changes: 2 additions & 0 deletions includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
?>


<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<p id="pasttfooter">This translation tool is powered by <a href="https://github.com/erickok/pastt">PASTT: PHP Android String Translation Tool</a> under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></p>

</body>
Expand Down
32 changes: 24 additions & 8 deletions includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,33 @@

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $pageTitle; ?></title>
<style type="text/css">
@import url("includes/default.css");
</style>
<?php if ($requirecaptcha) { echo "<script src=\"https://www.google.com/recaptcha/api.js\" async defer></script>"; } ?>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $pageTitle; ?></title>
<?php if ($requirecaptcha) { echo "<script src=\"https://www.google.com/recaptcha/api.js\" async defer></script>"; } ?>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<style type="text/css">
body {
padding-top: 50px;
}
#pasttfooter {
padding: 10px;
text-align: center;
}
</style>
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href=".">PASTT</a>
</div>
</div>
</nav>
52 changes: 24 additions & 28 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@
include('includes/header.php');

echo '
<h1>' . $appname . '</h1>';

echo '
<table>
<tr>
<th colspan="3">Existing translations</td>
</tr>';

$isuneven = false;
$classuneven = ' class="uneven"';
<div class="container">
<h3>' . $appname . '</h3>
<h4>Existing translations</h4>
<table class="table table-striped">';

if (isset($languages)) {
sort($languages);
Expand All @@ -38,22 +32,21 @@
// Show the language and an edit link
$langgroup = substr($language, 0, 2);
echo '
<tr' . ($isuneven? $classuneven: '') . '>
<td>' . $language . '</td>
<td>' . $iso639[$langgroup] . '</td>
<td><a href="translation.php?lang=' . $language . '">Edit translation</a></td>
</tr>';

$isuneven = !$isuneven;
<tr>
<td>' . $language . '</td>
<td>' . $iso639[$langgroup] . '</td>
<td><a class="btn btn-sm btn-primary" href="translation.php?lang=' . $language . '">Edit</a></td>
</tr>';
}
}

echo '
<tr>
<td colspan="3">
<form id="addtranslation" name="addtranslation" method="GET" action="translation.php">
Add a new translation for:
<select id="lang" name="lang">';
</table>
<div class="well">
<form class="form-inline" id="addtranslation" name="addtranslation" method="GET" action="translation.php">
<div class="form-group">
<label for="lang">Add a new translation</label>
<select class="form-control" id="lang" name="lang">';
foreach ($iso639 as $langcode => $langname) {
$selected = '';
if ($defaultLanguage == $langcode) {
Expand All @@ -64,12 +57,15 @@
}
echo '
</select>
<strong>-r</strong><input type="text" id="region" name="region" /> (optional region code)
<input type="submit" id="submit" name="submit" value="Add" />
</form>
</td>
</tr>
</table>';
</div>
<div class="form-group">
<label for="region">-r</label>
<input class="form-control" type="text" id="region" name="region" placeholder="Region code (optional)" />
</div>
<input class="btn btn-primary" type="submit" id="submit" name="submit" value="Add" />
</form>
</div>
</div>';

include('includes/footer.php');

Expand Down
100 changes: 54 additions & 46 deletions translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ function requireCaptcha() {
}
</script>
<h1>Translating to ' . $langname . ' (' . $lang . ')</h1>';
<div class="container">
<h3>' . $langname . ' (' . $lang . ')</h3>
<div class="container">';

function parseStrings($file) {
$lines = file($file);
Expand Down Expand Up @@ -318,16 +320,20 @@ function dp($in) {
$strings = parseStrings($basedir . '/values/strings.xml');
//dp($strings);

echo '
<div class="row">';
// Load the translation XML file, if it exists
if (isset($newesttranslation)) {
echo '
<p>You are working with the last-saved translation \'<a href="res/values-' . $lang . '/' . $newesttranslation . '">' . $newesttranslation . '</a>\' (saved ' . date('d F Y H:i', filemtime($basedir . '/values-' . $lang . '/' . $newesttranslation)) . '). When you save your updates it will not override it but make a new copy.</p>
<p id="showmissingrow"><input type="button" id="showmissing" name="showmissing" value="Show only missing translations" onclick="javascript:flipShowOnlyMissing();" /></p>';
<p>You are working with the last-saved translation \'<a href="res/values-' . $lang . '/' . $newesttranslation . '">' . $newesttranslation . '</a>\' (saved ' . date('d F Y H:i', filemtime($basedir . '/values-' . $lang . '/' . $newesttranslation)) . '). When you save your updates it will not override it but make a new copy.</p>
<p id="showmissingrow"><input class="btn btn-large btn-primary" type="button" id="showmissing" name="showmissing" value="Show only missing translations" onclick="javascript:flipShowOnlyMissing();" /></p>';
$translations = parseStrings($basedir . '/values-' . $lang . '/' . $newesttranslation);
} else {
echo '
<p>No translation for this language currently exists. When saving for the first time, it will create a directory and the first strings.{timestamp}.xml for this new language.</p>';
<p>No translation for this language currently exists. When saving for the first time, it will create a directory and the first strings.{timestamp}.xml for this new language.</p>';
}
echo '
</div>';

// Require the input of a name and email address and/or captcha?
if ($requireemail && $requireCaptcha) {
Expand All @@ -339,17 +345,20 @@ function dp($in) {
} else {
$requirehtml = '';
}

echo '
<form id="translationform" name="translationform" method="post" action="translation.php?lang=' . $lang . '" onsubmit="javascript:unloadOk=true;' . $requirehtml . '">
<table id="translationtable">
<tr>
<th id="key">Key</th>
<th id="org">English</th>
<th id="trans">' . $langname . ' (' . $lang . ')</th>
</tr>';

$isuneven = false;
$classuneven = ' class="uneven"';
<form id="translationform" name="translationform" method="post" action="translation.php?lang=' . $lang . '" onsubmit="javascript:unloadOk=true;' . $requirehtml . '">
<div class="row">
<div class="table-responsive">
<table class="table table-striped" id="translationtable">
<thead>
<tr>
<th class="col-xs-1 col-sm-2" id="key">Key</th>
<th class="col-xs-1 col-sm-2" id="org">English</th>
<th class="col-xs-10 col-sm-8" id="trans">' . $langname . ' (' . $lang . ')</th>
</tr>
</thead>
<tbody>';

function encodeForHtml($in) {
return htmlspecialchars($in);
Expand Down Expand Up @@ -385,51 +394,50 @@ function encodeForInput($in) {

// Show a table row that has the key, the original English text and a input box with the translation text that is editable
echo '
<tr' . ($isuneven? $classuneven: '') . '>
<td>' . $name . '</td>
<td>' . str_replace("\\n","<br/>",encodeForHtml($value)) . '</td>
<td>';
<tr>
<td class="col-sm-2">' . $name . '</td>
<td class="col-sm-2">' . str_replace("\\n","<br/>",encodeForHtml($value)) . '</td>
<td class="col-sm-8">';

if (strpos(encodeForInput($value),"\\n") !== FALSE) echo '<textarea style="word-wrap: break-word;height:10em;width:100%" id="' . $name . '" name="' . $name . '">' . str_replace("\\n","\n",encodeForInput($transtext)) . '</textarea>';
else echo '<input style="word-wrap: break-word;" type="text" id="' . $name . '" name="' . $name . '" value="' . encodeForInput($transtext) . '" /></td>';
echo '</tr>';

$isuneven = !$isuneven;

if (strpos(encodeForInput($value),"\\n") !== FALSE) echo '<textarea class="form-control" id="' . $name . '" name="' . $name . '">' . str_replace("\\n","\n",encodeForInput($transtext)) . '</textarea>';
else echo '<input class="form-control" type="text" id="' . $name . '" name="' . $name . '" value="' . encodeForInput($transtext) . '" /></td>';
echo '
</tr>';
}

echo '
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="well">';
if ($askforemail) {
$requiredfieldhtml = $requireemail? ' <strong>Your are required to fill in your name and e-mail address:</strong>': 'Please fill in your name and e-mail address:';
echo '
<tr>
<td colspan="3">' . $requiredfieldhtml . '</td>
</tr>
<tr>
<td>Name:</td>
<td colspan="2"><input type="input" id="pastt_translator_name" name="pastt_translator_name" value="" /></td>
</tr>
<tr>
<td>E-mail:</td>
<td colspan="2"><input type="input" id="pastt_translator_email" name="pastt_translator_email" value="" /></td>
</tr>';
<p>' . $requiredfieldhtml . '</p>
<div class="form-group">
<label for="pastt_translator_name">Name</label>
<input type="input" class="form-control" id="pastt_translator_name" name="pastt_translator_name" value="" />
</div>
<div class="form-group">
<label for="pastt_translator_email">E-mail:</label>
<input type="input" class="form-control" id="pastt_translator_email" name="pastt_translator_email" value="" />
</div>';
}

if($requirecaptcha) {
echo '
<tr>
<td colspan="3"><div style="text-align: center">' . render_captcha($recaptcha_site_key) . '</div></td>
</tr>';
<div style="text-align: center">' . render_captcha($recaptcha_site_key) . '</div>';
}

echo '
<tr>
<td colspan="3"><input type="submit" id="submit" name="submit" value="Save updated translation" /></td>
</tr>
<tr>
<td colspan="3" style="text-align: center;"><a href="./">or go back without saving</a></td>
</tr>
</table>
</form>';
<input type="submit" class="btn btn-primary" id="submit" name="submit" value="Save updated translation" />
</div>
</div>
</form>
</div>
</div>';

include('includes/footer.php');

Expand Down

0 comments on commit 3bf97b7

Please sign in to comment.