Skip to content

Commit

Permalink
fix and improve embedded LPV translations
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 18, 2024
1 parent 7be54cd commit 0648652
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 4 additions & 3 deletions modules/analyse/src/main/ui/AnalyseUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
))
)})})""")

Expand Down
7 changes: 1 addition & 6 deletions ui/site/src/site.lpvEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ interface OptsWithI18n extends Opts {

(window as any).LpvEmbed = function (opts: Partial<OptsWithI18n>) {
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
Expand All @@ -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';
Expand Down

0 comments on commit 0648652

Please sign in to comment.