Skip to content

Commit

Permalink
remove now unnecessary i18n.JsDump - after #16223
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 18, 2024
1 parent c533117 commit 7be54cd
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 64 deletions.
1 change: 0 additions & 1 deletion app/UiEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ object UiEnv
lazy val isOnline = env.socket.isOnline
lazy val lightUserSync = env.user.lightUserSync
def manifest = env.web.manifest
protected val jsDump = lila.i18n.JsDump
protected val translator = lila.i18n.Translator
val langList = lila.i18n.LangList
protected val namer = lila.game.Namer
Expand Down
16 changes: 6 additions & 10 deletions modules/analyse/src/main/ui/AnalyseUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ final class AnalyseUi(helpers: Helpers)(externalEngineEndpoint: String):

def lpvJs(lpvConfig: JsObject)(using Translate): WithNonce[Frag] =
embedJsUnsafe(s"""document.addEventListener("DOMContentLoaded",function(){LpvEmbed(${safeJsonValue(
lpvConfig ++ Json.obj(
"i18n" -> i18nJsObject(lpvI18n)
)
lpvConfig + ("i18n" -> Json.obj(
"flipBoard" -> trans.site.flipBoard.txt(),
"analysis" -> trans.site.analysis.txt(),
"practiceWithComputer" -> trans.site.practiceWithComputer.txt(),
"download" -> trans.site.download
))
)})})""")

def lpvConfig(orientation: Option[Color], getPgn: Boolean) = Json
Expand All @@ -91,10 +94,3 @@ final class AnalyseUi(helpers: Helpers)(externalEngineEndpoint: String):
)
)
.add("orientation", orientation.map(_.name))

private val lpvI18n = List(
trans.site.flipBoard,
trans.site.analysis,
trans.site.practiceWithComputer,
trans.site.download
)
1 change: 0 additions & 1 deletion modules/challenge/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ final class Env(
getLagRating: lila.core.socket.userLag.GetLagRating,
msgApi: lila.core.msg.MsgApi,
langPicker: lila.core.i18n.LangPicker,
jsDump: lila.core.i18n.JsDump,
setupForm: lila.core.setup.SetupForm,
oauthServer: lila.oauth.OAuthServer,
baseUrl: BaseUrl
Expand Down
5 changes: 2 additions & 3 deletions modules/challenge/src/main/JsonView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package lila.challenge
import play.api.libs.json.*

import lila.common.Json.given
import lila.core.i18n.{ I18nKey as trans, JsDump, Translate }
import lila.core.i18n.{ I18nKey as trans, Translate }
import lila.core.id.GameFullId
import lila.core.socket.{ SocketVersion, userLag }
import lila.game.JsonView.given
Expand All @@ -13,8 +13,7 @@ final class JsonView(
baseUrl: lila.core.config.BaseUrl,
getLightUser: lila.core.LightUser.GetterSync,
getLagRating: userLag.GetLagRating,
isOnline: lila.core.socket.IsOnline,
jsDump: JsDump
isOnline: lila.core.socket.IsOnline
):

import Challenge.*
Expand Down
1 change: 0 additions & 1 deletion modules/i18n/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ import com.softwaremill.macwire.*
@Module
object Env:

val jsDump = JsDump
val langList = LangList
val langPicker = LangPicker
37 changes: 0 additions & 37 deletions modules/i18n/src/main/JsDump.scala

This file was deleted.

1 change: 0 additions & 1 deletion modules/notify/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ final class Env(
getLightUserSync: lila.core.LightUser.GetterSync,
cacheApi: lila.memo.CacheApi,
subsRepo: lila.core.relation.SubscriptionRepo,
jsDump: lila.core.i18n.JsDump,
langPicker: lila.core.i18n.LangPicker
)(using Executor, ActorSystem, Materializer, lila.core.i18n.Translator):

Expand Down
4 changes: 2 additions & 2 deletions modules/notify/src/main/JsonHandlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import scalalib.Json.given
import lila.common.Json.given
import lila.core.LightUser
import lila.core.i18n.I18nKey.{ site as trans }
import lila.core.i18n.{ I18nKey, Translate, JsDump }
import lila.core.i18n.{ I18nKey, Translate }
import lila.core.notify.*

final class JSONHandlers(getLightUser: LightUser.GetterSync, jsDump: JsDump):
final class JSONHandlers(getLightUser: LightUser.GetterSync):

given Writes[Notification] with

Expand Down
9 changes: 1 addition & 8 deletions modules/ui/src/main/helper/I18nHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package lila.ui
import play.api.i18n.Lang
import play.api.libs.json.JsObject

import lila.core.i18n.{ I18nKey, JsDump, LangList, Translator, fixJavaLanguage }
import lila.core.i18n.{ I18nKey, LangList, Translator, fixJavaLanguage }
import lila.ui.ScalatagsTemplate.*

trait I18nHelper:

protected val jsDump: JsDump
protected val translator: Translator
protected val ratingApi: lila.ui.RatingApi

Expand All @@ -32,12 +31,6 @@ trait I18nHelper:
def transKey(key: I18nKey, args: Seq[Matchable] = Nil)(using t: Translate): Frag =
translator.frag.literal(key, args, t.lang)

def i18nJsObject(keys: Seq[I18nKey])(using Translate): JsObject =
jsDump.keysToObject(keys)

def i18nOptionJsObject(keys: Option[I18nKey]*)(using Translate): JsObject =
jsDump.keysToObject(keys.flatten)

def langHref(call: Call)(using Context): String = langHref(call.url)
def langHref(path: String)(using ctx: Context): String =
if ctx.isAuth || ctx.lang.language == "en"
Expand Down

0 comments on commit 7be54cd

Please sign in to comment.