October CMS easy translation parser
This parses the yaml files for easy tarnslation matrix production.
by Michael Dibbets
July 14, 2015
HTML
Just paste the contents of the YAML file in here. <BR/>All tabs and labels will be automatically sorted to be displayed properly.<BR/><BR/>
You can copy and paste the resulting code in your <STRONG>/plugins/pluginname/lang/en/lang.php</STRONG><BR/>
<BR/>
<textarea id="fut" onchange="runme(this)" onkeyup="runme(this)"></textarea>
<pre id="showmethemoney">
</pre>
CSS
textarea {
width:600px;
height:200px;
}
#showmethemoney {
background:#000;
font-family:Terminal, FixedSys, Courier New, Courier, Sans Serif;
color:lime;
padding:20px;
border:2px inset gold;
}
JavaScript
function runme(what) {
var text = what.value.split('\n');
var labels = {};
for(var c=0;c<text.length;c++) {
var cur = text[c].trim();
if(cur.startsWith('label: ') || cur.startsWith('tab: ')) {
var spl = cur.split('lang.');
var spl = spl[1].split('.');
var totranslate = spl[1];
if(typeof labels[spl[0]] === 'undefined') {
labels[spl[0]] = {};
}
labels[spl[0]][totranslate] = '';
}
}
var str = '';
for(obj in labels) {
if(labels.hasOwnProperty(obj)) {
str += '\t\''+obj+'\' => [\n';
for(tr in labels[obj]) {
if(labels[obj].hasOwnProperty(tr)) {
str += '\t\t\''+tr+'\' => \'\',\n';
}
}
str += '\t],\n';
}
}
document.getElementById('showmethemoney').innerHTML = '';
document.getElementById('showmethemoney').appendChild(document.createTextNode(str));
}