Skip to content

Commit

Permalink
download i18ns in broadcast embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Oct 20, 2024
1 parent 23612b7 commit d5d2924
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/views/base/embed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package views.base

import lila.app.UiEnv.{ *, given }
import lila.ui.ContentSecurityPolicy
import lila.core.i18n.I18nModule

object embed:
/* a minimalist embed that doesn't load site.ts */
Expand Down Expand Up @@ -49,7 +50,8 @@ object embed:
cssKeys: List[String] = Nil,
modules: EsmList = Nil,
pageModule: Option[PageModule] = None,
csp: Update[ContentSecurityPolicy] = identity
csp: Update[ContentSecurityPolicy] = identity,
i18nModules: List[I18nModule.Selector] = Nil
)(body: Modifier*)(using ctx: EmbedContext) = lila.ui.Snippet:
val allModules = modules ++ pageModule.so(module => esmPage(module.name))
frag(
Expand All @@ -65,7 +67,11 @@ object embed:
page.ui.pieceSprite(ctx.pieceSet.name),
cssTag("common.theme.embed"), // includes both light & dark colors
cssKeys.map(cssTag),
page.ui.sitePreload(Nil, allModules, isInquiry = false),
page.ui.sitePreload(
List[I18nModule.Selector](_.site, _.timeago) ++ i18nModules,
allModules,
isInquiry = false
),
page.ui.lichessFontFaceCss
),
st.body(bodyModifiers)(
Expand Down
4 changes: 3 additions & 1 deletion app/views/relay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ def embed(
data: lila.relay.JsonView.JsData,
socketVersion: SocketVersion
)(using ctx: EmbedContext) =
import lila.core.i18n.I18nModule
views.base.embed.site(
title = rt.fullName,
cssKeys = List("analyse.relay.embed"),
pageModule = ui.pageModule(rt, data, none, socketVersion, embed = true).some,
csp = _.withExternalAnalysisApis
csp = _.withExternalAnalysisApis,
i18nModules = List(_.site, _.timeago, _.study, _.broadcast)
)(
div(id := "main-wrap", cls := "is2d"):
ui.showPreload(rt, data)(cls := "relay-embed")
Expand Down

0 comments on commit d5d2924

Please sign in to comment.