Fix the tournament names after translating (#9866)

* Revert "Revert "Improve tournament names translation""

This reverts commit ec10605e20.

* Fix tournament names when `Speed` different from `Perf`

Only `Rapid` and `Classical` are concerned by translation anyway.
8a1a7396f5/modules/rating/src/main/PerfType.scala (L297)

Co-authored-by: kraktus <kraktus@users.noreply.github.com>
pull/9874/head
kraktus 2021-09-23 07:44:31 +02:00 committed by GitHub
parent 649c388731
commit c8e0571b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 24 deletions

View File

@ -24,13 +24,13 @@ object bits {
)
}
def enterable(tours: List[Tournament]) =
def enterable(tours: List[Tournament])(implicit ctx: Context) =
table(cls := "tournaments")(
tours map { tour =>
tr(
td(cls := "name")(
a(cls := "text", dataIcon := tournamentIconChar(tour), href := routes.Tournament.show(tour.id))(
tour.name
tour.name(full = false)
)
),
tour.schedule.fold(td) { s =>

View File

@ -5,6 +5,8 @@ import chess.variant.Variant
import org.joda.time.DateTime
import play.api.i18n.Lang
import lila.i18n.I18nKeys
import lila.rating.PerfType
case class Schedule(
@ -26,55 +28,55 @@ case class Schedule(
(freq, speed) match {
case (Hourly, Rapid) if full => hourlyRapidArena.txt()
case (Hourly, Rapid) => hourlyRapid.txt()
case (Hourly, speed) if full => hourlyXArena.txt(speed.name)
case (Hourly, speed) => hourlyX.txt(speed.name)
case (Hourly, speed) if full => hourlyXArena.txt(speed.trans)
case (Hourly, speed) => hourlyX.txt(speed.trans)
case (Daily, Rapid) if full => dailyRapidArena.txt()
case (Daily, Rapid) => dailyRapid.txt()
case (Daily, Classical) if full => dailyClassicalArena.txt()
case (Daily, Classical) => dailyClassical.txt()
case (Daily, speed) if full => dailyXArena.txt(speed.name)
case (Daily, speed) => dailyX.txt(speed.name)
case (Daily, speed) if full => dailyXArena.txt(speed.trans)
case (Daily, speed) => dailyX.txt(speed.trans)
case (Eastern, Rapid) if full => easternRapidArena.txt()
case (Eastern, Rapid) => easternRapid.txt()
case (Eastern, Classical) if full => easternClassicalArena.txt()
case (Eastern, Classical) => easternClassical.txt()
case (Eastern, speed) if full => easternXArena.txt(speed.name)
case (Eastern, speed) => easternX.txt(speed.name)
case (Eastern, speed) if full => easternXArena.txt(speed.trans)
case (Eastern, speed) => easternX.txt(speed.trans)
case (Weekly, Rapid) if full => weeklyRapidArena.txt()
case (Weekly, Rapid) => weeklyRapid.txt()
case (Weekly, Classical) if full => weeklyClassicalArena.txt()
case (Weekly, Classical) => weeklyClassical.txt()
case (Weekly, speed) if full => weeklyXArena.txt(speed.name)
case (Weekly, speed) => weeklyX.txt(speed.name)
case (Weekly, speed) if full => weeklyXArena.txt(speed.trans)
case (Weekly, speed) => weeklyX.txt(speed.trans)
case (Monthly, Rapid) if full => monthlyRapidArena.txt()
case (Monthly, Rapid) => monthlyRapid.txt()
case (Monthly, Classical) if full => monthlyClassicalArena.txt()
case (Monthly, Classical) => monthlyClassical.txt()
case (Monthly, speed) if full => monthlyXArena.txt(speed.name)
case (Monthly, speed) => monthlyX.txt(speed.name)
case (Monthly, speed) if full => monthlyXArena.txt(speed.trans)
case (Monthly, speed) => monthlyX.txt(speed.trans)
case (Yearly, Rapid) if full => yearlyRapidArena.txt()
case (Yearly, Rapid) => yearlyRapid.txt()
case (Yearly, Classical) if full => yearlyClassicalArena.txt()
case (Yearly, Classical) => yearlyClassical.txt()
case (Yearly, speed) if full => yearlyXArena.txt(speed.name)
case (Yearly, speed) => yearlyX.txt(speed.name)
case (Yearly, speed) if full => yearlyXArena.txt(speed.trans)
case (Yearly, speed) => yearlyX.txt(speed.trans)
case (Shield, Rapid) if full => rapidShieldArena.txt()
case (Shield, Rapid) => rapidShield.txt()
case (Shield, Classical) if full => classicalShieldArena.txt()
case (Shield, Classical) => classicalShield.txt()
case (Shield, speed) if full => xShieldArena.txt(speed.name)
case (Shield, speed) => xShield.txt(speed.name)
case _ if full => xArena.txt(s"${freq.toString} ${speed.name}")
case _ => s"${freq.toString} ${speed.name}"
case (Shield, speed) if full => xShieldArena.txt(speed.trans)
case (Shield, speed) => xShield.txt(speed.trans)
case _ if full => xArena.txt(s"${freq.toString} ${speed.trans}")
case _ => s"${freq.toString} ${speed.trans}"
}
case (Some(_), _) if full => eliteXArena.txt(speed.name)
case (Some(_), _) => eliteX.txt(speed.name)
case (_, Some(max)) if full => s"<${max.rating} ${xArena.txt(speed.name)}"
case (_, Some(max)) => s"<${max.rating} ${speed.name}"
case (Some(_), _) if full => eliteXArena.txt(speed.trans)
case (Some(_), _) => eliteX.txt(speed.trans)
case (_, Some(max)) if full => s"<${max.rating} ${xArena.txt(speed.trans)}"
case (_, Some(max)) => s"<${max.rating} ${speed.trans}"
}
else if (variant.standard) {
val n = position.flatMap(Thematic.byFen).fold(speed.name) { pos =>
s"${pos.shortName} ${speed.name}"
val n = position.flatMap(Thematic.byFen).fold(speed.trans) { pos =>
s"${pos.shortName} ${speed.trans}"
}
if (full) xArena.txt(n) else n
} else
@ -200,6 +202,11 @@ object Schedule {
sealed abstract class Speed(val id: Int) {
val name = toString
val key = lila.common.String lcfirst name
def trans(implicit lang: Lang): String = this match {
case Speed.Rapid => I18nKeys.rapid.txt()
case Speed.Classical => I18nKeys.classical.txt()
case _ => name
}
}
object Speed {
case object UltraBullet extends Speed(5)