delete more translation code

pull/3072/head
Thibault Duplessis 2017-05-25 12:25:02 +02:00
parent b03a26c42e
commit 5c1618837b
5 changed files with 1 additions and 98 deletions

View File

@ -1,24 +0,0 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
lila_dir = pwd()
lila_trans_dir = lila_dir + '/conf'
puts 'Translate the site to 1337'
file = lila_trans_dir + '/messages'
dest = lila_trans_dir + '/messages.le'
lines = File.open(file).readlines
leet = lines.map { |l|
key = l.gsub(/(\w+)=.+/, '\1').strip
en = l.gsub(/\w+=(.+)/, '\1').strip.gsub(/\%s/,'%%')
command = "php /home/thib/leet/index.php \"#{en}\""
res = %x[ #{command} ].gsub(/\%\%/,'%s')
puts res
key + '=' + res
}
File.open(dest, 'w') { |f| f.puts leet }

View File

@ -1,26 +0,0 @@
package lila.i18n
import org.joda.time.DateTime
private[i18n] case class Translation(
_id: Int,
code: String, // 2-chars code
text: String,
author: Option[String] = None,
comment: Option[String] = None,
createdAt: DateTime
) {
def id = _id
def lines = text.split("\n").toList
override def toString = "#%d %s".format(id, code)
}
private[i18n] object Translation {
import play.api.libs.json._
private[i18n] implicit val translationI18nFormat = Json.format[Translation]
}

View File

@ -1,20 +0,0 @@
package lila.i18n
import lila.db.dsl._
import lila.db.BSON.BSONJodaDateTimeHandler
private[i18n] final class TranslationRepo(coll: Coll) {
private implicit val TranslationBSONHandler = reactivemongo.bson.Macros.handler[Translation]
def nextId: Fu[Int] = coll.primitiveOne[Int](
selector = $empty,
sort = $sort desc "_id",
"_id"
) map (opt => ~opt + 1)
def findFrom(id: Int): Fu[List[Translation]] =
coll.find($doc("_id" $gte id)).sort($sort asc "_id").cursor[Translation]().gather[List]()
def insert(t: Translation) = coll insert t
}

View File

@ -1,27 +0,0 @@
package lila.i18n
import play.api.libs.json._
import play.api.libs.ws.WS
import play.api.Play.current
private[i18n] final class UpstreamFetch(upstreamUrl: Int => String) {
private type Fetched = Fu[List[Translation]]
import Translation.translationI18nFormat
def apply(from: Int): Fetched =
fetch(upstreamUrl(from)) map parse flatMap {
_.fold(e => fufail(e.toString), fuccess(_))
}
def apply(from: String): Fetched =
parseIntOption(from).fold(fufail("Bad from argument"): Fetched)(apply)
private def fetch(url: String): Fu[JsValue] =
WS.url(url).get() map (_.json)
private def parse(json: JsValue): JsResult[List[Translation]] =
Json.fromJson[List[Translation]](json)
}

View File

@ -62,7 +62,7 @@ export function view(ctrl: LangsCtrl): VNode {
function langLinks(ctrl: LangsCtrl, list: Lang[]) {
const links = list.map(langView(ctrl.data.current, ctrl.data.accepted));
links.push(h('a', {
attrs: { href: '/translation/contribute' }
attrs: { href: 'https://crowdin.com/project/lichess' }
}, 'Help translate lichess'));
return links;
}