list of translatable languages with stats and contributors

pull/1/merge
Thibault Duplessis 2012-06-16 01:05:47 +02:00
parent 1a0874e233
commit ea17d15ec9
13 changed files with 231 additions and 9 deletions

View File

@ -3,7 +3,20 @@ package controllers
import lila._
import views._
import i18n._
object I18n extends LilaController {
val contribute = todo
def transInfos = env.i18n.transInfos
def pool = env.i18n.pool
val contribute = Open { implicit ctx
val all = transInfos
val mines = (pool fixedReqAcceptLanguages ctx.req map { lang
all find (_.lang == lang)
}).toList.flatten
Ok(html.i18n.contribute(all, mines))
}
def contributeTrans(lang: String) = TODO //Open { implicit ctx =>
}

View File

@ -0,0 +1,67 @@
package lila
package i18n
object Contributors {
val all = Map(
"fr" -> List("Thibault Duplessis"),
"ru" -> List("Nikita Milovanov"),
"de" -> List("Patrick Gawliczek"),
"tr" -> List("Yakup Ipek"),
"sr" -> List("Nenad Nikolić"),
"lv" -> List("Anonymous"),
"bs" -> List("Jacikka"),
"da" -> List("Henrik Bjornskov"),
"es" -> List("FennecFoxz"),
"ro" -> List("Cristian Niţă"),
"it" -> List("Marco Barberis"),
"fi" -> List("Juuso Vallius"),
"uk" -> List("alterionisto"),
"pt" -> List("Arthur Braz", "Eugênio Vázquez"),
"pl" -> List("M3n747"),
"nl" -> List("Kintaro"),
"vi" -> List("Xiblack"),
"sv" -> List("nizleib"),
"cs" -> List("Martin", "Claymes"),
"sk" -> List("taiga"),
"hu" -> List("LTBakemono"),
"ca" -> List("AI8"),
"sl" -> List("Klemen Grm"),
"az" -> List("elçin məmmədzadə", "amil isgəndərov"),
"nn" -> List("Peropaal"),
"eo" -> List("LaPingvino"),
"tp" -> List("jan Mimoku"),
"el" -> List("Tzortzakos Fivos", "Γιάννης Ανθυμίδης"),
"fp" -> List("Alex"),
"lt" -> List("Anonymous"),
"no" -> List("Anonymous"),
"et" -> List("Anonymous"),
"hy" -> List("Network.am"),
"af" -> List("secreteagle"),
"hi" -> List("Samarth Karia"),
"ar" -> List("Ziad Dabash"),
"zh" -> List("神爱"),
"gl" -> List("José Manuel Castroagudín Silva"),
"tk" -> List("Anonymous"),
"hr" -> List("Betyárcsimbók"),
"mk" -> List("Давид и Стефан Тимовски"),
"id" -> List("Night1301"),
"ja" -> List("ネイサン アイブス"),
"bg" -> List("Anonymous"),
"th" -> List("มาโนชญ์ สมศักดิ์"),
"fa" -> List("saeid monajiane"),
"he" -> List("Anonymous", " Tornado"),
"mr" -> List("Rahul"),
"mn" -> List("Tsbarsaa"),
"cy" -> List("cavejohnson"),
"gd" -> List("GunChleoc"),
"ga" -> List("Anonymous"),
"sq" -> List("Indrit Bleta"),
"be" -> List("Palenik Siarhei"),
"ka" -> List("Giorgi Javakhidze"),
"sw" -> List("Anonymous"),
"ps" -> List("Eimal Dorani"),
"is" -> List("Sir Gizmo Gunn Myr Basque"))
def apply(code: String): List[String] = ~(all get code)
}

View File

@ -40,4 +40,8 @@ final class I18nEnv(
pool = pool,
keys = keys,
api = messagesApi)
lazy val transInfos = TransInfo.all(
api = messagesApi,
keys = keys)
}

View File

@ -5,6 +5,8 @@ object LangList {
def name(code: String) = all get code getOrElse code
lazy val sortedList = all.toList sortBy (_._1)
val all = Map(
"ab" -> "аҧсуа",
"aa" -> "Afaraf",

View File

@ -0,0 +1,28 @@
package lila
package i18n
import play.api.i18n.{ MessagesApi, Lang }
case class TransInfo(
lang: Lang,
name: String,
contributors: List[String],
percent: Int) {
def code = lang.language
}
object TransInfo {
def all(api: MessagesApi, keys: I18nKeys): List[TransInfo] = {
val nbMessages = keys.keys.size
LangList.sortedList.filter(_._1 != "en") map {
case (code, name) TransInfo(
lang = Lang(code),
name = name,
contributors = Contributors(code),
percent = (api.messages get code).fold(_.size, 0) * 100 / nbMessages
)
}
}
}

View File

@ -7,7 +7,7 @@ import org.joda.time.DateTime
case class Translation(
@Key("_id") id: Int,
code: String, // 2-chars code
messages: String,
yaml: String,
author: Option[String],
comment: Option[String],
createdAt: DateTime) {

View File

@ -8,7 +8,13 @@ import com.mongodb.casbah.Imports._
import scalaz.effects._
class TranslationRepo(
collection: MongoCollection
) extends SalatDAO[Translation, String](collection) {
collection: MongoCollection) extends SalatDAO[Translation, String](collection) {
val maxId: IO[Int] = io {
collection.find(DBObject(), DBObject("_id" -> true))
.sort(DBObject("_id" -> -1))
.limit(1)
.toList
.headOption flatMap { _.getAs[Int]("_id") } getOrElse 0
}
}

View File

@ -1,9 +1,19 @@
@()(implicit ctx: Context)
@(all: List[lila.i18n.TransInfo], mines: List[lila.i18n.TransInfo])(implicit ctx: Context)
@i18n.layout(
title = "Contribute to translations") {
<div class="content_box small_box">
This feature is temporarily disabled. Will be back soon, promise!
<div class="content_box">
<h1 class="lichess_title">Help translate Lichess!</h1>
<br />
Lichess is OpenSource and needs contributors to get better.
<br />
@if(mines.nonEmpty) {
<h2>Do you speak @{ (mines.size > 1).fold("these languages", "this language") }?</h2>
@i18n.translations(mines)
}
<br />
<h2>What about these ones?</h2>
@i18n.translations(all)
</div>
}

View File

@ -3,8 +3,12 @@
@moreCss = {
@cssTag("translation.css")
}
@moreJs = {
@jsTag("translation.js")
}
@base.layout(
title = title,
moreCss = moreCss,
moreJs = moreJs,
active = none)(body)

View File

@ -0,0 +1,44 @@
@(transInfos: List[lila.i18n.TransInfo])(implicit ctx: Context)
<table class="translations">
<thead>
<tr>
<th>Language</th>
<th>Progress</th>
<th>Contributors</th>
</tr>
</thead>
<tbody>
@transInfos.map { info =>
<tr>
<td>
<a href="@routes.I18n.contributeTrans(info.code)">
@info.code - @info.name
</a>
</td>
<td class="progress">
<div class="progressbar">
<div style="width: @info.percent%"></div>
</div>
</td>
<td>@info.contributors.mkString(", ")</td>
<td>
<a href="@routes.I18n.contributeTrans(info.code)">
@info.percent match {
case 0 => {
Start it!
}
case 100 => {
Fix it!
}
case p => {
Complete it!
}
}
</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -56,6 +56,7 @@ POST /api/game/new controllers.Setup.api
# I18n
GET /translation/contribute controllers.I18n.contribute
GET /translation/contributeTrans controllers.I18n.contributeTrans(lang: String)
# Authentication
GET /login controllers.Auth.login

View File

@ -1,5 +1,42 @@
#lichess div.lichess_box {
width: auto;
h2 {
margin-top: 1em;
font-size: 1.5em;
}
table.translations {
margin-top: 1em;
width: 100%;
}
table.translations th {
font-weight: bold;
}
table.translations td, table.translations th {
padding: 5px 5px 5px 5px;
}
table.translations tbody tr:nth-child(odd) {
background: #f4f4f4;
}
table.translations td.progress {
white-space: nowrap;
}
table.translations div.progressbar {
background-color: #eaeaea;
border: 1px solid #e0e0e0;
border-radius: 5px;
padding: 1px;
width: 200px;
}
table.translations div.progressbar div {
background: #d85000;
background: -moz-linear-gradient(center top , #f49c00, #d85000) repeat scroll 0 0 #d85000;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f49c00), to(#d85000));
background: -webkit-linear-gradient(top , #f49c00, #d85000) repeat scroll 0 0 #d85000;
background: -ms-linear-gradient(top , #f49c00, #d85000) repeat scroll 0 0 #d85000;
background: -o-linear-gradient(top , #f49c00, #d85000) repeat scroll 0 0 #d85000;
background: linear-gradient(top , #f49c00, #d85000) repeat scroll 0 0 #d85000;
height: 12px;
border-radius: 4px;
}
div.field {

6
todo
View File

@ -23,6 +23,12 @@ fix game list translations
temporary mod IP ban to help stopping cheaters
more infos under realtime games
cheater slash timeline
board colorpicker
best game(s) to watch
copy spectator chat to rematch
prevent people giving their friend game await link
view pgn: overflow -> make it a textarea
reorder game_more links
new translations:
-rematchOfferCanceled=Rematch offer canceled