From a87d477323640a3db6ee0990239f91a7fd408a58 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Sun, 12 Sep 2021 19:09:30 +0200 Subject: [PATCH] tweak and complete tablebase i18n --- app/views/board/userAnalysisI18n.scala | 5 ++++- bin/trans-lint.py | 2 +- modules/i18n/src/main/I18nKeys.scala | 5 ++++- translation/source/site.xml | 8 ++++---- ui/analyse/src/explorer/explorerView.ts | 19 +++++++++++++------ 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/views/board/userAnalysisI18n.scala b/app/views/board/userAnalysisI18n.scala index 0bae9c027c..2503521990 100644 --- a/app/views/board/userAnalysisI18n.scala +++ b/app/views/board/userAnalysisI18n.scala @@ -155,7 +155,10 @@ object userAnalysisI18n { trans.averageRatingX, trans.masterDbExplanation, trans.mateInXHalfMoves, - trans.nextCaptureOrPawnMoveInXHalfMoves, + trans.dtzWithRounding, + trans.winOr50MovesByPriorMistake, + trans.lossOr50MovesByPriorMistake, + trans.unknownDueToRounding, trans.noGameFound, trans.maybeIncludeMoreGamesFromThePreferencesMenu, trans.winPreventedBy50MoveRule, diff --git a/bin/trans-lint.py b/bin/trans-lint.py index 982811bf38..4a9f55d9d6 100755 --- a/bin/trans-lint.py +++ b/bin/trans-lint.py @@ -142,7 +142,7 @@ def lint_string(ctx, dest, source, allow_missing=0): for placeholder in re.findall(r"%\d+\$s", dest): ctx.error(f"mixing placeholder styles: {placeholder} and %s") - for pattern in ["O-O", "SAN", "FEN", "PGN", "K, Q, R, B, N"]: + for pattern in ["O-O", "SAN", "FEN", "PGN", "K, Q, R, B, N", "DTZ50''"]: m_source = source if pattern.isupper() else source.lower() m_dest = dest if pattern.isupper() else dest.lower() if pattern in m_source and pattern not in m_dest: diff --git a/modules/i18n/src/main/I18nKeys.scala b/modules/i18n/src/main/I18nKeys.scala index 13c073f721..9062665357 100644 --- a/modules/i18n/src/main/I18nKeys.scala +++ b/modules/i18n/src/main/I18nKeys.scala @@ -88,6 +88,7 @@ val `averageRatingX` = new I18nKey("averageRatingX") val `recentGames` = new I18nKey("recentGames") val `topGames` = new I18nKey("topGames") val `masterDbExplanation` = new I18nKey("masterDbExplanation") +val `dtzWithRounding` = new I18nKey("dtzWithRounding") val `noGameFound` = new I18nKey("noGameFound") val `maybeIncludeMoreGamesFromThePreferencesMenu` = new I18nKey("maybeIncludeMoreGamesFromThePreferencesMenu") val `openingExplorer` = new I18nKey("openingExplorer") @@ -95,6 +96,9 @@ val `openingEndgameExplorer` = new I18nKey("openingEndgameExplorer") val `xOpeningExplorer` = new I18nKey("xOpeningExplorer") val `winPreventedBy50MoveRule` = new I18nKey("winPreventedBy50MoveRule") val `lossSavedBy50MoveRule` = new I18nKey("lossSavedBy50MoveRule") +val `winOr50MovesByPriorMistake` = new I18nKey("winOr50MovesByPriorMistake") +val `lossOr50MovesByPriorMistake` = new I18nKey("lossOr50MovesByPriorMistake") +val `unknownDueToRounding` = new I18nKey("unknownDueToRounding") val `allSet` = new I18nKey("allSet") val `importPgn` = new I18nKey("importPgn") val `delete` = new I18nKey("delete") @@ -768,7 +772,6 @@ val `resignTheGame` = new I18nKey("resignTheGame") val `youCantStartNewGame` = new I18nKey("youCantStartNewGame") val `opponentLeftCounter` = new I18nKey("opponentLeftCounter") val `mateInXHalfMoves` = new I18nKey("mateInXHalfMoves") -val `nextCaptureOrPawnMoveInXHalfMoves` = new I18nKey("nextCaptureOrPawnMoveInXHalfMoves") val `nbBlunders` = new I18nKey("nbBlunders") val `nbMistakes` = new I18nKey("nbMistakes") val `nbInaccuracies` = new I18nKey("nbInaccuracies") diff --git a/translation/source/site.xml b/translation/source/site.xml index e54de1fc03..ae3b0a3eb7 100644 --- a/translation/source/site.xml +++ b/translation/source/site.xml @@ -92,10 +92,7 @@ Mate in %s half-move Mate in %s half-moves - - Next capture or pawn move in %s half-move (Distance To Zeroing of the 50 move counter) - Next capture or pawn move in %s half-moves (Distance To Zeroing of the 50 move counter) - + DTZ50'' with rounding, based on number of half moves until next capture or pawn move No game found Maybe include more games from the preferences menu? Opening explorer @@ -103,6 +100,9 @@ %s opening explorer Win prevented by 50-move rule Loss prevented by 50-move rule + Win or 50 moves by prior mistake + Loss or 50 moves by prior mistake + Win/loss only guaranteed if recommended tablebase line has been followed since the last capture or pawn move, due to possible rounding. All set! Import PGN Delete diff --git a/ui/analyse/src/explorer/explorerView.ts b/ui/analyse/src/explorer/explorerView.ts index b2162e6bfd..b9908b3249 100644 --- a/ui/analyse/src/explorer/explorerView.ts +++ b/ui/analyse/src/explorer/explorerView.ts @@ -232,10 +232,16 @@ function gameActions(ctrl: AnalyseCtrl, game: OpeningGame): VNode { ); } -function showTablebase(ctrl: AnalyseCtrl, fen: Fen, title: string, moves: TablebaseMoveStats[]): VNode[] { +function showTablebase( + ctrl: AnalyseCtrl, + fen: Fen, + title: string, + tooltip: string | undefined, + moves: TablebaseMoveStats[] +): VNode[] { if (!moves.length) return []; return [ - h('div.title', title), + h('div.title', tooltip ? { attrs: { title: tooltip } } : {}, title), h('table.tablebase', [ h( 'tbody', @@ -286,7 +292,7 @@ function showDtz(ctrl: AnalyseCtrl, fen: Fen, move: TablebaseMoveStats): VNode | 'result.' + winnerOf(fen, move), { attrs: { - title: ctrl.trans.plural('nextCaptureOrPawnMoveInXHalfMoves', Math.abs(move.dtz)), + title: trans('dtzWithRounding') + ' (Distance To Zeroing)', }, }, 'DTZ ' + Math.abs(move.dtz) @@ -362,22 +368,23 @@ function show(ctrl: AnalyseCtrl): MaybeVNode { ]); else lastShow = showEmpty(ctrl, data.opening); } else if (data && isTablebase(data)) { - const row = (category: TablebaseCategory, title: string) => + const row = (category: TablebaseCategory, title: string, tooltip?: string) => showTablebase( ctrl, data.fen, title, + tooltip, data.moves.filter(m => m.category == category) ); if (data.moves.length) lastShow = h('div.data', [ ...row('loss', trans('winning')), ...row('unknown', trans('unknown')), - ...row('maybe-loss', 'Winning or 50 moves by prior mistake'), + ...row('maybe-loss', trans('winOr50MovesByPriorMistake'), trans('unknownDueToRounding')), ...row('blessed-loss', trans('winPreventedBy50MoveRule')), ...row('draw', trans('drawn')), ...row('cursed-win', trans('lossSavedBy50MoveRule')), - ...row('maybe-win', 'Losing or 50 moves by prior mistake'), + ...row('maybe-win', trans('winOr50MovesByPriorMistake'), trans('unknownDueToRounding')), ...row('win', trans('losing')), ]); else if (data.checkmate) lastShow = showGameEnd(ctrl, trans('checkmate'));