From 06486527bd8dc54f38528a1ea3dea7c4ab553f1f Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Fri, 18 Oct 2024 10:22:33 +0200 Subject: [PATCH] fix and improve embedded LPV translations --- modules/analyse/src/main/ui/AnalyseUi.scala | 7 ++++--- ui/site/src/site.lpvEmbed.ts | 7 +------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/analyse/src/main/ui/AnalyseUi.scala b/modules/analyse/src/main/ui/AnalyseUi.scala index 207d9d3e8a860..e44e01c05e50e 100644 --- a/modules/analyse/src/main/ui/AnalyseUi.scala +++ b/modules/analyse/src/main/ui/AnalyseUi.scala @@ -80,10 +80,11 @@ final class AnalyseUi(helpers: Helpers)(externalEngineEndpoint: String): def lpvJs(lpvConfig: JsObject)(using Translate): WithNonce[Frag] = embedJsUnsafe(s"""document.addEventListener("DOMContentLoaded",function(){LpvEmbed(${safeJsonValue( lpvConfig + ("i18n" -> Json.obj( - "flipBoard" -> trans.site.flipBoard.txt(), - "analysis" -> trans.site.analysis.txt(), + "flipTheBoard" -> trans.site.flipBoard.txt(), + "analysisBoard" -> trans.site.analysis.txt(), "practiceWithComputer" -> trans.site.practiceWithComputer.txt(), - "download" -> trans.site.download + "getPgn" -> trans.study.copyChapterPgn.txt(), + "download" -> trans.site.download.txt() )) )})})""") diff --git a/ui/site/src/site.lpvEmbed.ts b/ui/site/src/site.lpvEmbed.ts index ff201b0ec2118..67cbe09b29267 100644 --- a/ui/site/src/site.lpvEmbed.ts +++ b/ui/site/src/site.lpvEmbed.ts @@ -10,11 +10,6 @@ interface OptsWithI18n extends Opts { (window as any).LpvEmbed = function (opts: Partial) { const elem = document.body.firstChild!.firstChild as HTMLElement; - const i18n = { - ...(opts.i18n || {}), - flipTheBoard: opts.i18n.flipBoard, - analysisBoard: opts.i18n.analysis, - }; const lpv = Lpv(elem, { initialPly: parseInt(location.hash.slice(1)) || undefined, ...(opts.gamebook @@ -32,7 +27,7 @@ interface OptsWithI18n extends Opts { }), ...opts, pgn: elem.innerHTML, - translate: key => i18n[key], + translate: key => opts.i18n?.[key], }); if (opts.gamebook) { const text = lpv.game.initial.comments[0] || 'Start';