mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
Resolved #8968 - stats for notifications string'd without special characters
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
package com.unciv.models.stats
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.translations.tr
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
@ -152,7 +151,7 @@ open class Stats(
|
||||
|
||||
/** Since notifications are translated on the fly, when saving stats there we need to do so in English */
|
||||
fun toStringForNotifications() = this.joinToString {
|
||||
(if (it.value > 0) "+" else "") + it.value.toInt() + " " + it.key.toString().tr(Constants.english)
|
||||
(if (it.value > 0) "+" else "") + it.value.toInt() + " " + it.key.toString()
|
||||
}
|
||||
|
||||
// For display in diplomacy window
|
||||
|
@ -291,7 +291,8 @@ object TranslationActiveModsCache {
|
||||
* defaults to the input string if no translation is available,
|
||||
* but with placeholder or sentence brackets removed.
|
||||
*/
|
||||
fun String.tr(language:String = UncivGame.Current.settings.language): String {
|
||||
fun String.tr(): String {
|
||||
val language:String = UncivGame.Current.settings.language
|
||||
if (contains('<') && contains('>')) { // Conditionals!
|
||||
/**
|
||||
* So conditionals can contain placeholders, such as <vs [unitFilter] units>, which themselves
|
||||
|
@ -7,6 +7,7 @@ import com.unciv.UncivGame
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.*
|
||||
import com.unciv.utils.debug
|
||||
import org.junit.Assert
|
||||
@ -282,6 +283,14 @@ class TranslationTests {
|
||||
superNestedString.tr())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isStatsRecognizesStatsIncludingStatCharacter(){
|
||||
UncivGame.Current = UncivGame()
|
||||
UncivGame.Current.settings = GameSettings()
|
||||
|
||||
Assert.assertTrue(Stats.isStats(Stats(1f,2f,3f).toStringForNotifications()))
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// fun allConditionalsAreContainedInConditionalOrderTranslation() {
|
||||
|
Reference in New Issue
Block a user