Skip to content

Commit

Permalink
chore: Fix chat translator displaying translations similar to origina…
Browse files Browse the repository at this point in the history
…l text
  • Loading branch information
phinner committed Nov 3, 2023
1 parent 87449f3 commit 389f321
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import kotlinx.coroutines.withTimeoutOrNull
import mindustry.game.EventType.PlayerJoin

class ChatTranslatorListener(instances: InstanceManager) : ImperiumApplication.Listener {
private val translator: Translator = instances.get()
private val pipeline: ChatMessagePipeline = instances.get()
private val config = instances.get<ImperiumConfig>()
private val translator = instances.get<Translator>()
private val pipeline = instances.get<ChatMessagePipeline>()

override fun onImperiumInit() {
pipeline.register("translator", Priority.LOW) { context ->
Expand Down Expand Up @@ -68,7 +68,9 @@ class ChatTranslatorListener(instances: InstanceManager) : ImperiumApplication.L
sourceLocale,
targetLocale)
is TranslatorResult.Success -> {
return@register if (rawMessage == result.text) rawMessage
return@register if (rawMessage.lowercase(sourceLocale) ==
result.text.lowercase(targetLocale))
rawMessage
else "${context.message} [lightgray](${result.text})"
}
}
Expand Down

0 comments on commit 389f321

Please sign in to comment.