mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Fix broken translation (#7580)
This commit is contained in:
parent
a3e7d5ccb6
commit
30e1dcbcdd
@ -8,7 +8,6 @@ import com.unciv.models.stats.Stat
|
|||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.utils.Log
|
import com.unciv.utils.Log
|
||||||
import com.unciv.utils.debug
|
import com.unciv.utils.debug
|
||||||
import java.time.temporal.ChronoUnit
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -391,15 +390,14 @@ fun String.tr(): String {
|
|||||||
|
|
||||||
// Take the terms in the message, WITHOUT square brackets
|
// Take the terms in the message, WITHOUT square brackets
|
||||||
val termsInMessage = this.getPlaceholderParametersIgnoringLowerLevelBraces()
|
val termsInMessage = this.getPlaceholderParametersIgnoringLowerLevelBraces()
|
||||||
// Take the term from the placeholder, INCLUDING the square brackets
|
// Take the terms from the placeholder
|
||||||
val termsInTranslationPlaceholder =
|
val termsInTranslationPlaceholder = originalEntry.getPlaceholderParametersIgnoringLowerLevelBraces()
|
||||||
squareBraceRegex.findAll(originalEntry).map { it.value }.toList()
|
|
||||||
if (termsInMessage.size != termsInTranslationPlaceholder.size)
|
if (termsInMessage.size != termsInTranslationPlaceholder.size)
|
||||||
throw Exception("Message $this has a different number of terms than the placeholder $translationEntry!")
|
throw Exception("Message $this has a different number of terms than the placeholder $translationEntry!")
|
||||||
|
|
||||||
for (i in termsInMessage.indices) {
|
for (i in termsInMessage.indices) {
|
||||||
languageSpecificPlaceholder = languageSpecificPlaceholder.replace(
|
languageSpecificPlaceholder = languageSpecificPlaceholder.replace(
|
||||||
termsInTranslationPlaceholder[i],
|
"[${termsInTranslationPlaceholder[i]}]", // re-add square brackets to placeholder terms
|
||||||
termsInMessage[i].tr()
|
termsInMessage[i].tr()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user