Skip to content

Commit 4e4b25d

Browse files
committed
Translate ban message
1 parent b9eeba2 commit 4e4b25d

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

src/session.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ function nowPlaying(): readonly NowPlayingGame[] {
103103
)
104104
}
105105

106-
function currentBan(): Date | undefined {
107-
const playban = session && session.playban
108-
return playban && new Date(playban.date + playban.mins * 60000)
109-
}
110-
111106
function isKidMode(): boolean {
112107
return !!(session && session.kid)
113108
}
@@ -370,8 +365,7 @@ export default {
370365
lichessBackedProp,
371366
setKidMode,
372367
confirmEmail,
373-
currentBan,
374368
hasCurrentBan(): boolean {
375-
return currentBan() !== undefined
369+
return session?.playban !== undefined
376370
},
377371
}

src/styl/home.styl

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
line-height 2em
193193
> p
194194
font-size 0.9em
195+
text-align left
195196
> ul
196197
list-style initial
197198
margin-left 2em

src/ui/home/homeView.tsx

+17-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import socket from '../../socket'
44
import { openExternalBrowser } from '../../utils/browse'
55
import { emptyFen } from '../../utils/fen'
66
import { hasNetwork } from '../../utils'
7-
import i18n, { plural, formatNumber, fromNow } from '../../i18n'
7+
import i18n, { plural, formatNumber, distanceToNowStrict } from '../../i18n'
88
import session from '../../session'
99
import { PongMessage, CorrespondenceSeek } from '../../lichess/interfaces'
1010
import spinner from '../../spinner'
@@ -55,7 +55,8 @@ function offline(ctrl: HomeCtrl) {
5555
}
5656

5757
function online(ctrl: HomeCtrl) {
58-
const playbanEndsAt = session.currentBan()
58+
const playban = session.get()?.playban
59+
const playbanEndsAt = playban && new Date(playban.date + playban.mins * 60000)
5960

6061
return (
6162
<div className="home">
@@ -350,31 +351,29 @@ function renderTimeline(ctrl: HomeCtrl) {
350351
}
351352

352353
function renderPlayban(endsAt: Date) {
353-
const seconds = (endsAt.valueOf() - Date.now()) / 1000
354354
return (
355355
<div className="home-playbanInfo">
356-
<h2>Sorry :(</h2>
357-
<p>We had to time you out for a {seconds < 3600 ? 'little ' : ''}while.</p>
356+
<h2>{i18n('sorry')}</h2>
357+
<p>{i18n('weHadToTimeYouOutForAWhile')}</p>
358358
<br />
359-
<p>The timeout expires <strong>{fromNow(endsAt)}</strong>.</p>
360-
<h2>Why?</h2>
359+
<p>{h.trust(i18n('timeoutExpires', `<strong>${distanceToNowStrict(endsAt)}</strong>`))}</p>
360+
<h2>{i18n('why')}</h2>
361361
<p>
362-
We aim to provide a pleasant chess experience for everyone.
363-
To that effect, we must ensure that all players follow good practices.
364-
When a potential problem is detected, we display this message.
362+
{i18n('pleasantChessExperience')}<br />
363+
{i18n('goodPractice')}<br />
364+
{i18n('potentialProblem')}
365365
</p>
366-
<h2>How to avoid this?</h2>
366+
<h2>{i18n('howToAvoidThis')}</h2>
367367
<ul>
368-
<li>Play every game you start</li>
369-
<li>Try to win (or at least draw) every game you play</li>
370-
<li>Resign lost games (don't let the clock run down)</li>
368+
<li>{i18n('playEveryGame')}</li>
369+
<li>{i18n('tryToWin')}</li>
370+
<li>{i18n('resignLostGames')}</li>
371371
</ul>
372372
<br />
373-
<br />
374373
<p>
375-
We apologize for the temporary inconvenience,<br />
376-
and wish you great games on lichess.org.<br />
377-
Thank you for reading!
374+
{i18n('temporaryInconvenience')}<br />
375+
{i18n('wishYouGreatGames')}<br />
376+
{i18n('thankYouForReading')}
378377
</p>
379378
</div>
380379
)

0 commit comments

Comments
 (0)