3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-30 16:09:27 +01:00

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
This commit is contained in:
Douglas Gardner 2013-04-21 12:18:24 +00:00
parent 24387200bc
commit 47d5404f38
5 changed files with 102 additions and 39 deletions

View File

@ -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"),

View File

@ -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);
}
};

View File

@ -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}",

View File

@ -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;
}

View File

@ -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)
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)
&nbsp;
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
h4 Translations
ul
each key in translation
li #{translation[0][1]}
h4 #{credits}
#{thanks}
ul#credits
ul
each author in authors
li #{author}
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