From 47d5404f38767ef783d13d3af56e7ba7003e136b Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 12:18:24 +0000 Subject: [PATCH 1/3] Add beginnings of translation progress API * Add totally legit and optimised code to find the number of strings in each language. * Add this as an API call * Add strings for ``na'vi``, ``es`` and ``nl`` for their own language names * Optimise CSS a bit * Add classes for the languages, for testing purposes --- modules/project/pages.js | 11 ++++++++ modules/project/project.js | 40 ++++++++++++++++++++++------- modules/project/strings.json | 10 +++++--- public/project.css | 30 ++++++++++++++++++---- views/project/project.jade | 50 ++++++++++++++++++++---------------- 5 files changed, 102 insertions(+), 39 deletions(-) diff --git a/modules/project/pages.js b/modules/project/pages.js index 7d964de..944064f 100644 --- a/modules/project/pages.js +++ b/modules/project/pages.js @@ -15,6 +15,16 @@ var pages = function(dbot) { } }); + var trans = []; + // THIS IS TOTALLY LEGIT AND OPTIMISED CODE + /* for (var j = 0; j < Object.keys(dbot.strings).length; j++) { + var str = dbot.strings.j; + for (var k = 0; k < Object.keys(dbot.strings.str).length; k++) { + var lang = str.lang; + trans[lang]++; + } + } */ + exec("git rev-list --all | wc -l", function(error, stdout, stderr) { rev = stdout; }); @@ -43,6 +53,7 @@ var pages = function(dbot) { } res.render('project', { + "translation": dbot.modules.project.api.translationProgress(), "configList": dbot.modules.project.api.configList(), "authors": authors, //dbot.modules.project.api.getAuthors(), "credits": dbot.t("credits"), diff --git a/modules/project/project.js b/modules/project/project.js index 48ed053..b177dbe 100644 --- a/modules/project/project.js +++ b/modules/project/project.js @@ -42,16 +42,38 @@ var project = function(dbot) { } return list; }, - 'getAuthors': function(callback) { - var foo = ['a','b','c']; - exec("git rev-list --all | wc -l", function(error, stdout, stderr){ - foo.push(stdout); - }); - callback(foo); + 'translationProgress' : function(callback){ + var translation = []; + var str = _.values(dbot.strings); + for (var i = 0; i < str.length; i++){ + var cur = _.keys(str[i]); + for (var j = 0; j < cur.length; j++) { + translation = translation.concat(cur[j]); + } + } + // optimise this, someone who isn't me + var t = []; + for (var k = 0; k < str.length; k++) { + var curr = translation[k]; + if (t[curr]) { + t[curr]["count"] += 1; + } else { + t[curr] = []; + // t[curr]["839"] = curr; + t[curr]["count"] = 1; + t[curr]["own"] = dbot.strings[curr][curr]; + t[curr]["local"] = dbot.t(curr); + t[curr]["english"] = dbot.strings[curr]["en"]; + } + } + _.compact(t); + console.log(t); + return t; } - } -} + }; + this.api['translationProgress'].external = true; +}; exports.fetch = function(dbot){ return new project(dbot); -} +}; diff --git a/modules/project/strings.json b/modules/project/strings.json index f3c80b5..e03f30a 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -63,17 +63,21 @@ "fr": "na'vi", "de": "Na'vi", "it": "Na'vi", - "nl": "Na'vi" + "nl": "Na'vi", + "na'vi": "Na'vi" + }, "es": { "en": "Spanish", "fr": "espagnole", "de": "Spanisch", "it": "spagnolo", - "nl": "Spaans" + "nl": "Spaans", + "es": "EspaƱol" }, "nl": { - "en": "Dutch" + "en": "Dutch", + "nl": "Nederlands" }, "revnum": { "en": "{name} is at revision {rev}", diff --git a/public/project.css b/public/project.css index 6b36846..b0793a8 100644 --- a/public/project.css +++ b/public/project.css @@ -4,11 +4,9 @@ pre#gitdiff { margin:auto; } div#main { - text-align:inherit; font-size:18px; } h2,h3,h4,h5,h6,.center { - text-align:center; text-transform:lowercase; } table#milestones { @@ -19,7 +17,6 @@ table#milestones td { padding:5px; } p.intro { - text-align:center; border:1px solid #ccc; padding:20px; border-radius:4px; @@ -51,12 +48,10 @@ div.progress-inner.closed { } #config { - text-align:center; text-transform:lowercase; } ul { - text-align:center; margin-left:0; margin-bottom:5px; font-size:80%; @@ -72,3 +67,28 @@ li { #footer { font-size:80%; } +/* testing stuff */ +.en { + background-color:red; + background-image:none; +} +.fr { + background-color:blue; + background-image:none; +} +.de { + background-color:yellow; + background-image:none; +} +.nl { + background-color:darkorange; + background-image:none; +} +.cy { + background-image:palevioletred; + background-image:none; +} +.es { + background-image:none; + background-color:orchid; +} diff --git a/views/project/project.jade b/views/project/project.jade index 9f5e3cd..02c18bc 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -8,23 +8,28 @@ html(lang='#{curr839}') link(rel='stylesheet', type='text/css', href='/styles.css') link(rel="stylesheet", href="/project.css") title #{pagetitle} + - var mstone = "milestone" + style(type="text/css") + each milestone in milestones + - current = mstone+milestone.number + - wdth = ((milestone.open_issues/(milestone.open_issues + milestone.closed_issues))*100) + .current { width: wdth% } body div.container div#page div#title #{pagetitle} div.container#main + p.intro + p.intro #{dquote} - section#development + section#git h3 #{development} - h4 #{git} p.center #{revnum} - ul - li #{branch} pre#gitdiff #{diff} - h4 #{milestonehead} + h4 #{milestoneprog} table#milestones.center tr th #{milestonename} @@ -32,34 +37,35 @@ html(lang='#{curr839}') th #{openmilestone} th #{closedmilestone} each milestone in milestones - - var width = ((milestone.closed_issues/(milestone.open_issues + milestone.closed_issues))*100) - tr(id="milestone"+milestone.number) + - var mstone = "milestone" + - var wd = "width:" + - var pc = "%" + - var wdth = ((milestone.closed_issues/(milestone.open_issues + milestone.closed_issues))*100) + tr(id=mstone+milestone.number) td - a(href="https://github.com/"+repo+"/issues?milestone="+milestone.number) - #{milestone.title} + a(href=milestone.url) + #{milestone.title} td div.progress(class=milestone.state) - div.progress-inner(style="width:"+width+"%")(class=milestone.state) + div.progress-inner(style=wd+wdth+pc)(class=milestone.state)   - print #{Math.round(width)+"%"} td #{milestone.open_issues} td #{milestone.closed_issues} - p.center - a(href="https://github.com/"+repo) #{propaganda} - h4 - #{credits} - p.center - #{thanks} - ul#credits - each author in authors - li #{author} + h4 Translations + ul + each key in translation + li #{translation[0][1]} + h4 #{credits} + #{thanks} + ul + each author in authors + li + #{author} section#config h3 #{config} ul li #{currlang} li #{debugmode} - each message in configList - li #{message} h4 #{loadmod} ul#modules each module in modules From ad3e597ad21d2edc9a2a6d89341363d5f2eb897f Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 14:28:33 +0000 Subject: [PATCH 2/3] update translation information * Remove commented out code * Covert translationProgress from an array to an object * Enlargen progress meters * Add translation table --- modules/project/pages.js | 12 +----------- modules/project/project.js | 10 ++++------ public/project.css | 5 +++-- views/project/project.jade | 25 ++++++++++++++++++++++--- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/modules/project/pages.js b/modules/project/pages.js index 944064f..084a2d5 100644 --- a/modules/project/pages.js +++ b/modules/project/pages.js @@ -15,16 +15,6 @@ var pages = function(dbot) { } }); - var trans = []; - // THIS IS TOTALLY LEGIT AND OPTIMISED CODE - /* for (var j = 0; j < Object.keys(dbot.strings).length; j++) { - var str = dbot.strings.j; - for (var k = 0; k < Object.keys(dbot.strings.str).length; k++) { - var lang = str.lang; - trans[lang]++; - } - } */ - exec("git rev-list --all | wc -l", function(error, stdout, stderr) { rev = stdout; }); @@ -55,7 +45,7 @@ var pages = function(dbot) { res.render('project', { "translation": dbot.modules.project.api.translationProgress(), "configList": dbot.modules.project.api.configList(), - "authors": authors, //dbot.modules.project.api.getAuthors(), + "authors": authors, "credits": dbot.t("credits"), "thanks": dbot.t("thanks"), "name": dbot.config.name, diff --git a/modules/project/project.js b/modules/project/project.js index b177dbe..5d6c3a7 100644 --- a/modules/project/project.js +++ b/modules/project/project.js @@ -43,7 +43,7 @@ var project = function(dbot) { return list; }, 'translationProgress' : function(callback){ - var translation = []; + var translation = [] ; var str = _.values(dbot.strings); for (var i = 0; i < str.length; i++){ var cur = _.keys(str[i]); @@ -51,22 +51,20 @@ var project = function(dbot) { translation = translation.concat(cur[j]); } } - // optimise this, someone who isn't me - var t = []; + var t = {}; for (var k = 0; k < str.length; k++) { var curr = translation[k]; if (t[curr]) { t[curr]["count"] += 1; } else { - t[curr] = []; - // t[curr]["839"] = curr; + t[curr] = {}; + t[curr]["iso"] = curr; t[curr]["count"] = 1; t[curr]["own"] = dbot.strings[curr][curr]; t[curr]["local"] = dbot.t(curr); t[curr]["english"] = dbot.strings[curr]["en"]; } } - _.compact(t); console.log(t); return t; } diff --git a/public/project.css b/public/project.css index b0793a8..9049548 100644 --- a/public/project.css +++ b/public/project.css @@ -9,11 +9,11 @@ div#main { h2,h3,h4,h5,h6,.center { text-transform:lowercase; } -table#milestones { +table { margin:auto; width:80%; } -table#milestones td { +table td { padding:5px; } p.intro { @@ -31,6 +31,7 @@ div.progress { text-align:left; font-size:50%; color:gray; + min-width:200px; } div.progress-inner.open { background-color: #3fff3f; diff --git a/views/project/project.jade b/views/project/project.jade index 02c18bc..3743218 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -52,9 +52,28 @@ html(lang='#{curr839}') td #{milestone.open_issues} td #{milestone.closed_issues} h4 Translations - ul - each key in translation - li #{translation[0][1]} + table + tr + th Current + th Native + th English + th Progress + th Translations + each language in translation + - var w = ((language.count/translation.en.count)*100) + tr + td #{language.local} + td #{language.own} + td #{language.english} + td.prog + div.progress(class="open") + unless (language.iso == curr839) + div.progress-inner(style="width:"+w+"%")(class="open") +   + else + div.progress-inner(style="width:"+w+"%")(class="closed") +   + td #{language.count} / #{translation.en.count} h4 #{credits} #{thanks} ul From 151d0e6fcbc77e237ac6d9bfe128d068f9e1e573 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 14:53:04 +0000 Subject: [PATCH 3/3] Add translations; toggle lowercase; remove testCSS --- modules/project/pages.js | 8 +++++++- modules/project/strings.json | 15 +++++++++++++++ public/project.css | 32 +------------------------------- views/project/project.jade | 27 +++++++++++++-------------- 4 files changed, 36 insertions(+), 46 deletions(-) diff --git a/modules/project/pages.js b/modules/project/pages.js index 084a2d5..ed94690 100644 --- a/modules/project/pages.js +++ b/modules/project/pages.js @@ -86,7 +86,13 @@ var pages = function(dbot) { }), "git": dbot.t("git"), "milestonehead": dbot.t("milestones"), - "propaganda": dbot.t("propaganda") + "propaganda": dbot.t("propaganda"), + "languagecurr": dbot.t(dbot.config.language), + "languagenati": dbot.t("langhead-native"), + "languageeng": dbot.t("en"), + "languageprog": dbot.t("langhead-progress"), + "languagetrans": dbot.t("langhead-translations"), + "languagetranshead": dbot.t("translations") }); }, }; diff --git a/modules/project/strings.json b/modules/project/strings.json index e03f30a..8960da3 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -174,5 +174,20 @@ }, "git": { "en": "version control" + }, + "langhead-current": { + "en": "Current" + }, + "langhead-translations": { + "en": "Completion" + }, + "translations": { + "en": "Translations" + }, + "langhead-progress": { + "en": "Translation Progress" + }, + "langhead-native": { + "en": "Native" } } diff --git a/public/project.css b/public/project.css index 9049548..3e71250 100644 --- a/public/project.css +++ b/public/project.css @@ -2,11 +2,10 @@ pre#gitdiff { text-align:left; width:80; margin:auto; + text-transform:none; } div#main { font-size:18px; -} -h2,h3,h4,h5,h6,.center { text-transform:lowercase; } table { @@ -48,10 +47,6 @@ div.progress-inner.closed { background-image: linear-gradient(to bottom,#ff3f3f,#ff7f7f); } -#config { - text-transform:lowercase; -} - ul { margin-left:0; margin-bottom:5px; @@ -68,28 +63,3 @@ li { #footer { font-size:80%; } -/* testing stuff */ -.en { - background-color:red; - background-image:none; -} -.fr { - background-color:blue; - background-image:none; -} -.de { - background-color:yellow; - background-image:none; -} -.nl { - background-color:darkorange; - background-image:none; -} -.cy { - background-image:palevioletred; - background-image:none; -} -.es { - background-image:none; - background-color:orchid; -} diff --git a/views/project/project.jade b/views/project/project.jade index 3743218..d447388 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -19,8 +19,6 @@ html(lang='#{curr839}') div#page div#title #{pagetitle} div.container#main - p.intro - p.intro #{dquote} section#git @@ -51,14 +49,14 @@ html(lang='#{curr839}')   td #{milestone.open_issues} td #{milestone.closed_issues} - h4 Translations + h4 #{languagetranshead} table tr - th Current - th Native - th English - th Progress - th Translations + th #{languagecurr} + th #{languagenati} + th #{languageeng} + th #{languageprog} + th #{languagetrans} each language in translation - var w = ((language.count/translation.en.count)*100) tr @@ -66,13 +64,14 @@ html(lang='#{curr839}') td #{language.own} td #{language.english} td.prog - div.progress(class="open") - unless (language.iso == curr839) - div.progress-inner(style="width:"+w+"%")(class="open") -   + unless (language.iso == curr839) + div.progress(class="open") + div.progress-inner(style="width:"+w+"%")(class="open") +   else - div.progress-inner(style="width:"+w+"%")(class="closed") -   + div.progress(class="closed") + div.progress-inner(style="width:"+w+"%")(class="closed") +   td #{language.count} / #{translation.en.count} h4 #{credits} #{thanks}