This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Tschallacka
I've made a simple javascript function to capture all the translation fields I had defined in a yaml file. I don't know if there's an automated feature for that or not, but I needed this.
So here I am to share it with you guys, if you need to have quick translation too :-)
The jsfiddle for immedeate use: https://jsfiddle.net/mdibbets/httfqoc3/embedded/result/
The javascript code itself.
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));
}
Last updated
1-1 of 1