From bd60137a10e079a02a52af951582ae6d90a35397 Mon Sep 17 00:00:00 2001
From: Benedikt Werner <1benediktwerner@gmail.com>
Date: Fri, 25 Jun 2021 01:36:27 +0200
Subject: [PATCH 1/2] More swiss translations
---
app/views/swiss/bits.scala | 18 +++++++++---------
app/views/swiss/side.scala | 3 +--
modules/i18n/src/main/I18nKeys.scala | 8 ++++++++
translation/source/swiss.xml | 22 ++++++++++++++++++++++
ui/swiss/src/view/header.ts | 4 ++--
ui/swiss/src/view/main.ts | 2 +-
6 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/app/views/swiss/bits.scala b/app/views/swiss/bits.scala
index 325462c85e..34cc747cd7 100644
--- a/app/views/swiss/bits.scala
+++ b/app/views/swiss/bits.scala
@@ -72,15 +72,11 @@ object bits {
def showInterval(s: Swiss): Frag =
s.settings.dailyInterval match {
- case Some(1) => frag("One round per day")
- case Some(d) => frag(s"One round every $d days")
- case None if s.settings.manualRounds => frag("Rounds are started manually")
+ case Some(d) => trans.swiss.oneRoundEveryXDays.pluralSame(d)
+ case None if s.settings.manualRounds => trans.swiss.roundsAreStartedManually()
case None =>
- frag(
- if (s.settings.intervalSeconds < 60) pluralize("second", s.settings.intervalSeconds)
- else pluralize("minute", s.settings.intervalSeconds / 60),
- " between rounds"
- )
+ if (s.settings.intervalSeconds < 60) trans.swiss.xSecondsBetweenRounds.pluralSame(s.settings.intervalSeconds)
+ else trans.swiss.xMinutesBetweenRounds.pluralSame(s.settings.intervalSeconds / 60)
}
def jsI18n(implicit ctx: Context) = i18nJsObject(i18nKeys)
@@ -102,6 +98,10 @@ object bits {
trans.averageOpponent,
trans.tournamentComplete,
trans.password,
- trans.swiss.viewAllXRounds
+ trans.swiss.viewAllXRounds,
+ trans.swiss.ongoingGames,
+ trans.swiss.startingIn,
+ trans.swiss.nextRound,
+ trans.team.joinTeam,
).map(_.key)
}
diff --git a/app/views/swiss/side.scala b/app/views/swiss/side.scala
index 753a89671a..1332cef7fa 100644
--- a/app/views/swiss/side.scala
+++ b/app/views/swiss/side.scala
@@ -33,8 +33,7 @@ object side {
if (s.settings.rated) trans.ratedTournament() else trans.casualTournament()
),
p(
- span(cls := "swiss__meta__round")(s"${s.round}/${s.settings.nbRounds}"),
- " rounds",
+ span(cls := "swiss__meta__round")(trans.swiss.nbRounds.plural(s.settings.nbRounds, s"${s.round}/${s.settings.nbRounds}")),
separator,
a(href := routes.Swiss.home)("Swiss"),
(isGranted(_.ManageTournament) || (ctx.userId.has(s.createdBy) && !s.isFinished)) option frag(
diff --git a/modules/i18n/src/main/I18nKeys.scala b/modules/i18n/src/main/I18nKeys.scala
index d2559fb028..499cb7ee87 100644
--- a/modules/i18n/src/main/I18nKeys.scala
+++ b/modules/i18n/src/main/I18nKeys.scala
@@ -1842,7 +1842,15 @@ val `lagCompensationExplanation` = new I18nKey("lag:lagCompensationExplanation")
object swiss {
val `swissTournaments` = new I18nKey("swiss:swissTournaments")
+val `roundsAreStartedManually` = new I18nKey("swiss:roundsAreStartedManually")
+val `startingIn` = new I18nKey("swiss:startingIn")
+val `nextRound` = new I18nKey("swiss:nextRound")
val `viewAllXRounds` = new I18nKey("swiss:viewAllXRounds")
+val `nbRounds` = new I18nKey("swiss:nbRounds")
+val `oneRoundEveryXDays` = new I18nKey("swiss:oneRoundEveryXDays")
+val `xSecondsBetweenRounds` = new I18nKey("swiss:xSecondsBetweenRounds")
+val `xMinutesBetweenRounds` = new I18nKey("swiss:xMinutesBetweenRounds")
+val `ongoingGames` = new I18nKey("swiss:ongoingGames")
}
object puzzle {
diff --git a/translation/source/swiss.xml b/translation/source/swiss.xml
index 65e7602582..b85e1531f3 100644
--- a/translation/source/swiss.xml
+++ b/translation/source/swiss.xml
@@ -5,4 +5,26 @@
- View the round
- View all %s rounds
+
+ - %s rounds
+
+
+ - One round per day
+ - One round every %s days
+
+ Rounds are started manually
+
+ - %s second between rounds
+ - %s seconds between rounds
+
+
+ - %s minunte between rounds
+ - %s minutes between rounds
+
+ Starting in
+ Next round
+
+ - Ongoing game
+ - Ongoing games
+
diff --git a/ui/swiss/src/view/header.ts b/ui/swiss/src/view/header.ts
index c4f43efb4c..0114fb12d1 100644
--- a/ui/swiss/src/view/header.ts
+++ b/ui/swiss/src/view/header.ts
@@ -27,7 +27,7 @@ function clock(ctrl: SwissCtrl): VNode | undefined {
}),
]);
return h(`div.clock.clock-created.time-cache-${next.at}`, [
- h('span.shy', ctrl.data.status == 'created' ? 'Starting in' : 'Next round'),
+ h('span.shy', ctrl.data.status == 'created' ? ctrl.trans.noarg('startingIn') : ctrl.trans.noarg('nextRound')),
h('span.time.text', {
hook: startClock(next.in + 1),
}),
@@ -36,7 +36,7 @@ function clock(ctrl: SwissCtrl): VNode | undefined {
function ongoing(ctrl: SwissCtrl): VNode | undefined {
const nb = ctrl.data.nbOngoing;
- return nb ? h('div.ongoing', [h('span.nb', [nb]), h('span.shy', 'Ongoing games')]) : undefined;
+ return nb ? h('div.ongoing', [h('span.nb', [nb]), h('span.shy', ctrl.trans.plural('ongoingGames', nb))]) : undefined;
}
export default function (ctrl: SwissCtrl): VNode {
diff --git a/ui/swiss/src/view/main.ts b/ui/swiss/src/view/main.ts
index b228b95d7a..b58bee04da 100644
--- a/ui/swiss/src/view/main.ts
+++ b/ui/swiss/src/view/main.ts
@@ -150,7 +150,7 @@ function joinButton(ctrl: SwissCtrl): VNode | undefined {
'data-icon': '',
},
},
- 'Join the team'
+ ctrl.trans.noarg('joinTeam')
);
if (d.canJoin)
From 502b19c6bb16b3c230d4136040e752378371e073 Mon Sep 17 00:00:00 2001
From: Benedikt Werner <1benediktwerner@gmail.com>
Date: Fri, 25 Jun 2021 06:31:41 +0200
Subject: [PATCH 2/2] Add 'implicit lang'
---
app/views/swiss/bits.scala | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/views/swiss/bits.scala b/app/views/swiss/bits.scala
index 34cc747cd7..d06e8c19d9 100644
--- a/app/views/swiss/bits.scala
+++ b/app/views/swiss/bits.scala
@@ -5,6 +5,7 @@ import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.i18n.{ I18nKeys => trans }
import lila.swiss.Swiss
+import play.api.i18n.Lang
import controllers.routes
@@ -70,7 +71,7 @@ object bits {
)
)
- def showInterval(s: Swiss): Frag =
+ def showInterval(s: Swiss)(implicit lang: Lang): Frag =
s.settings.dailyInterval match {
case Some(d) => trans.swiss.oneRoundEveryXDays.pluralSame(d)
case None if s.settings.manualRounds => trans.swiss.roundsAreStartedManually()