Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BoondoggleLabs committed Aug 3, 2017
1 parent 24f3ea1 commit 30cb2c0
Show file tree
Hide file tree
Showing 229 changed files with 20,847 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RewriteEngine On
RewriteRule ^([a-z]*)$ index.php?lang=$1 [NC,QSA]
96 changes: 96 additions & 0 deletions getStrings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
function get_comments($xmlstr){
$doc = new DOMDocument;

$doc->preserveWhiteSpace = false;
$doc->loadXML($xmlstr);

$xpath = new DOMXPath($doc);

$comments = [];

foreach ($xpath->query('//comment()') as $comment)
{
$comments[trim($comment->nextSibling->attributes->item(0)->value)] = $comment->textContent;
}
return $comments;
}

function getNeatFileName($filename){
$filename = str_replace("strings_", "", $filename);
$filename = str_replace("_", " ", $filename);
$filename = str_replace(".xml", "", $filename);
return ucfirst($filename);
}

function find_by_name($resources, $name){
foreach($resources as $resNode) {
if ($resNode['name'] == $name)
return $resNode;
}
}
function get_file_as_id($file){
return str_replace(".xml", "", $file);
}

$resources_dir = 'xml/';
$default_lang = $resources_dir.'values/';
$default_lang_strings = scandir($default_lang);
$default_lang_strings = array_splice($default_lang_strings, 2); // remove . and ..
$translations_directorys = scandir($resources_dir);
$translations_directorys = array_splice($translations_directorys, 3); // remove . and .. and values/

$comments = [];

foreach($default_lang_strings as $file) {
$resources[$file]['default'] =
new SimpleXMLElement(
file_get_contents($default_lang.$file)
);

$comments = array_merge($comments, get_comments(file_get_contents($default_lang.$file)));
// Delete untranslatable strings
error_reporting(E_ERROR | E_PARSE);
foreach ($resources[$file]['default']->children() as $string) {
if ($string['translatable'] == "false")
unset($string[0][0]);
}
error_reporting(E_ALL);
}

foreach($translations_directorys as $directory) {
foreach($resources as $key => $resource){
$file_address = $resources_dir.$directory."/".$key;
if (file_exists($file_address)){
$lang = str_replace("values-", "", $directory);
$resources[$key][$lang] =
simplexml_load_string(
file_get_contents($file_address)
);/* $resources[$key][$lang] =
new SimpleXMLElement(
file_get_contents($file_address)
);*/
}
}
}

//echo Locale::getDisplayLanguage($key, "en")
//print_r($resources);



$strings = new SimpleXMLElement($xmlstr);

//echo find_by_name($resources["error_strings.xml"]['default'], 'connection_suspended_error')


//$strings = $strings->resources;

/*foreach ($strings as $string) {
print_r($string);
echo $string;
echo $string['name'];
}*/


?>
156 changes: 156 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php
require_once "getStrings.php";
$locale = isset($_GET['lang'])?$_GET['lang']:"es";
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Translate Forecaster</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script src="lang-selector/jquery.uls.data.js"></script>
<script src="lang-selector/jquery.uls.data.utils.js"></script>
<script src="lang-selector/jquery.uls.lcd.js"></script>
<script src="lang-selector/jquery.uls.languagefilter.js"></script>
<script src="lang-selector/jquery.uls.regionfilter.js"></script>
<script src="lang-selector/jquery.uls.core.js"></script>
<link href="lang-selector/css/jquery.uls.css" rel="stylesheet">
<link href="lang-selector/css/jquery.uls.grid.css" rel="stylesheet">
<link href="lang-selector/css/jquery.uls.lcd.css" rel="stylesheet">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<script type="text/javascript" src="sisyphus.min.js"></script>
<style>
.border-bottom {
border:none;border-bottom:1px solid rgba(0,0,0,.06);
}
.mdl-typography--headline{
margin-top:40px;
}
.mdl-typography--caption{
padding-top:10px;
}
.bottom{
padding-top:10px;
}
</style>
<script>
$( function() {
// or you can persist all forms data at one command
$( "form" ).sisyphus({

customKeySuffix: "<?=$locale?>",
});
} );

$( document ).ready( function() {
$( '.uls-trigger' ).uls( {
onSelect : function( language ) {
document.location.href = language;
},
quickList: ['de', 'es','fr'] //FIXME
} );
} );
</script>
</head>

<body>
<form action="submit.php" id="basic_form" method="post" name="basic_form">
<!-- Simple header with scrollable tabs. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Create a <?=Locale::getDisplayLanguage($locale, "en")?> translation for Forecaster</span>
<!--
<div class="mdl-layout-spacer"></div>
<span class="mdl-typography--caption mdl-color-text--white">Saved!</span>-->
</div>
<!-- Tabs -->
<div class="mdl-layout__tab-bar mdl-js-ripple-effect">
<a href="#start" class="mdl-layout__tab is-active">Welcome</a>
<? foreach($resources as $key => $unused){ ?>
<i class="material-icons bottom">navigate_next</i>
<a href="#<?=get_file_as_id($key)?>" class="mdl-layout__tab"><? echo getNeatFileName($key)?></a>
<? } ?>

<i class="material-icons bottom">navigate_next</i>
<a href="#finish" class="mdl-layout__tab">Finish</a>
</div>
</header>

<main class="mdl-layout__content">
<section class="mdl-layout__tab-panel is-active" id="start">
<div class="page-content">
<div class="mdl-grid ">
<div class="mdl-layout-spacer"></div>
<div class="mdl-cell mdl-cell--10-col">
<div class=" mdl-typography--headline">
<span class=" mdl-typography--headline" style="margin-right:20px">Thanks for offering to translate to <?=Locale::getDisplayLanguage($locale, "en")?>!</span>

<button class="active uls-trigger mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary"type="button">Change Language</button>
</div>
<p style="
margin-top:20px;">This tool helps create a complete translation of all the text used in Forecaster. To use it, click through the tabs above to view the text. The English is shown on the left and text boxes are available to enter your translation on the right. Notes are sometimes shown below the English to help explain where the text is used - these don't need translating.</p>
<p>Anything you enter in the form will be auto-saved! If you get half way through a translation you can leave the website and come back to it later.</p>
<p>Once finished you can submit the translation to me in the last page and I'll try and get it released as soon as I can.</p>
<p>If you have any questions, or if I can help with anything please email me at: <a href="mailto:boondogglelabs@gmail.com">boondogglelabs@gmail.com</a></p>
</div>
<div class="mdl-layout-spacer"></div>
</div>
</div>
</section>
<? foreach($resources as $key => $strings){?>
<section class="mdl-layout__tab-panel" id="<?=get_file_as_id($key)?>">
<div class="page-content">
<div class="mdl-grid border-bottom">
<div class="mdl-layout-spacer"></div>
<div class="mdl-cell mdl-cell--4-col mdl-typography--font-bold">Original (English)</div>
<div class="mdl-cell mdl-cell--6-col mdl-typography--font-bold">Translated (<?=Locale::getDisplayLanguage($locale, "en")?>)</div>
<div class="mdl-layout-spacer"></div>
</div>

<? foreach ($resources[$key][$locale] as $string) {
$formElementName = get_file_as_id($key).'-'.trim($string['name']);?>
<div class="mdl-grid border-bottom">
<div class="mdl-layout-spacer"></div>
<div class="mdl-cell mdl-cell--4-col"><div class=" mdl-typography--body-1"><? echo find_by_name($resources[$key]['default'], trim($string['name'])) ;?>
<? if (isset($comments[trim($string['name'])])){ ?>
<br>
<div class="mdl-typography--caption mdl-color-text--grey">Note: <? echo $comments[trim($string['name'])];?></div>
<? } ?></div></div>
<div class="mdl-cell mdl-cell--6-col"><div class="mdl-textfield mdl-js-textfield mdl-textfield--full-width" style="padding: 0px;">
<textarea class="mdl-textfield__input " type="text" rows= "1" id="<?=$formElementName?>" name="<?=$formElementName?>" style="width:100%; font-size:14px;"><?=$string?></textarea>
<label class="mdl-textfield__label" for="<?=$formElementName?>">Translation...</label>
</div></div>
<div class="mdl-layout-spacer"></div>
</div>

<? }?>

</div>
</section>
<? } ?>
<section class="mdl-layout__tab-panel" id="finish">
<div class="page-content">
<div class="mdl-grid ">
<div class="mdl-layout-spacer"></div>
<div class="mdl-cell mdl-cell--10-col">
<div class=" mdl-typography--headline">Nearly done!</div>
<p>Clicking submit will save your translations and email them to me. I'll add them into the next release of the app.</p>
<div class="mdl-textfield mdl-js-textfield" style=" width: 50%">
<input class="mdl-textfield__input " type="text" id="email_address" name="email_address" style="font-size:14px;">
<label class="mdl-textfield__label" for="email_address">Enter your email address for updates on the translation (optional)</label>
</div><br>

<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="submit"> Submit </button></div>
<div class="mdl-layout-spacer"></div>
</div>
</div>
</section>
</main>
</div>
</form>
</body>
</html>
132 changes: 132 additions & 0 deletions lang-selector/css/jquery.uls.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
.uls-trigger {

}

.uls-menu {
position: absolute;
z-index: 1000;
display: none;
margin-top: 1px;
/* Styling */
background-color: #ffffff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}

.uls-wide {
min-width: 715px;
width: 45%;
}

.uls-medium {
min-width: 360px;
width: 30%;
}

/* Override the grid */
.uls-medium.grid .row {
min-width: 300px;
}

.uls-narrow {
min-width: 180px;
width: 20%;
}

/* Override the grid */
.uls-narrow.grid .row {
min-width: 150px;
}

.uls-search {
background-color: white;
padding: 5px 16px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #DDD;
}

.grid .uls-search {
padding-left: 0;
}

/* Make space for magnifying class on the front */
.uls-search-wrapper {
position: relative;
padding-left: 44px;
margin-right: 5px;
height: 32px;
}

.uls-search-label {
background: transparent url('../images/search.png') no-repeat scroll right center;
background-image: -webkit-linear-gradient(transparent, transparent), url('../images/search.svg');
/* @embed */
background-image: linear-gradient(transparent, transparent), url('../images/search.svg');
background-size: 20px;
background-position: center center;
height: 32px;
width: 44px;
display: block;
position: absolute;
left: 0;
opacity: 0.8;
}

.uls-search-input-wrapper {
position: relative;
}

/* There are two input boxes. This class applies to both of them */
.uls-filterinput {
font-size: 16px;
height: 32px;
width: 100%;
/* For the custom clear (X) icon */
padding: 6px 25px 6px 0;

outline: none;
border: none;

display: block;
position: absolute;
top: 0;
left: 0;
}

/* This is the actual input */
.uls-languagefilter {
background-color: transparent;
border: none;
color: #333;
}

/* This is the shadow input box showing completion suggestions */
.uls-filtersuggestion {
background-color: white;
color: #888;
}

.uls-languagefilter-clear {
background: transparent url('../images/clear.png') no-repeat scroll left center;
background-image: -webkit-linear-gradient(transparent, transparent), url('../images/clear.svg');
/* @embed */
background-image: linear-gradient(transparent, transparent), url('../images/clear.svg');
background-size: 15px;
cursor: pointer;
height: 15px;
width: 15px;

/* Vertical margins: (32 - 15) / 2 */
margin: 8.5px 5px;
position: absolute;
right: 0;
/* Make it appear above the input boxes */
z-index: 1;
}
Loading

0 comments on commit 30cb2c0

Please sign in to comment.