diff --git a/core/src/com/unciv/Constants.kt b/core/src/com/unciv/Constants.kt index 47e7384aa2..3a525897af 100644 --- a/core/src/com/unciv/Constants.kt +++ b/core/src/com/unciv/Constants.kt @@ -7,6 +7,8 @@ object Constants { const val spreadReligion = "Spread Religion" const val removeHeresy = "Remove Foreign religions from your own cities" + const val english = "English" + const val impassable = "Impassable" const val ocean = "Ocean" diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index 2adf48f790..38674cb885 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -679,7 +679,8 @@ class MapUnit : IsPartOfGameInfoSerialization { for (stat in gainedStats) civInfo.addStat(stat.key, stat.value.toInt()) - civInfo.addNotification("By expending your [$name] you gained [${gainedStats}]!", + + civInfo.addNotification("By expending your [$name] you gained [${gainedStats.toStringForNotifications()}]!", getTile().position, NotificationCategory.Units, name) } diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt index e825e6301f..796417c5b3 100644 --- a/core/src/com/unciv/models/metadata/GameSettings.kt +++ b/core/src/com/unciv/models/metadata/GameSettings.kt @@ -32,7 +32,7 @@ class GameSettings { var checkForDueUnits: Boolean = true var autoUnitCycle: Boolean = true var singleTapMove: Boolean = false - var language: String = "English" + var language: String = Constants.english @Transient var locale: Locale? = null @Deprecated("Since 4.3.6 - replaces with screenSize") @@ -71,7 +71,7 @@ class GameSettings { var showZoomButtons: Boolean = false var notificationsLogMaxTurns = 5 - + var showAutosaves: Boolean = false var androidCutout: Boolean = false diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index 294ec0e4ba..d965e47b9c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -369,7 +369,7 @@ object UniqueTriggerActivation { else notification val notificationText = getNotificationText(filledNotification, triggerNotificationText, - "Gained [$stats]") + "Gained [${stats.toStringForNotifications()}]") ?: return true civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon) @@ -394,7 +394,7 @@ object UniqueTriggerActivation { else notification val notificationText = getNotificationText(filledNotification, triggerNotificationText, - "Gained [$stats]") + "Gained [${stats.toStringForNotifications()}]") ?: return true civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon) diff --git a/core/src/com/unciv/models/stats/Stats.kt b/core/src/com/unciv/models/stats/Stats.kt index b0ed9cf9ca..ca9906b402 100644 --- a/core/src/com/unciv/models/stats/Stats.kt +++ b/core/src/com/unciv/models/stats/Stats.kt @@ -1,5 +1,6 @@ package com.unciv.models.stats +import com.unciv.Constants import com.unciv.models.translations.tr import kotlin.reflect.KMutableProperty0 @@ -149,6 +150,11 @@ open class Stats( } } + /** Since notificaitons 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) + } + // For display in diplomacy window fun toStringWithDecimals(): String { return this.joinToString { diff --git a/core/src/com/unciv/models/translations/Translations.kt b/core/src/com/unciv/models/translations/Translations.kt index 18ac446218..0afbebb59b 100644 --- a/core/src/com/unciv/models/translations/Translations.kt +++ b/core/src/com/unciv/models/translations/Translations.kt @@ -1,6 +1,7 @@ package com.unciv.models.translations import com.badlogic.gdx.Gdx +import com.unciv.Constants import com.unciv.UncivGame import com.unciv.models.ruleset.RulesetCache import com.unciv.models.ruleset.unique.Unique @@ -32,7 +33,7 @@ import java.util.* class Translations : LinkedHashMap(){ var percentCompleteOfLanguages = HashMap() - .apply { put("English",100) } // So even if we don't manage to load the percentages, we can still pass the language screen + .apply { put(Constants.english, 100) } // So even if we don't manage to load the percentages, we can still pass the language screen internal var modsWithTranslations: HashMap = hashMapOf() // key == mod name @@ -290,9 +291,7 @@ object TranslationActiveModsCache { * defaults to the input string if no translation is available, * but with placeholder or sentence brackets removed. */ -fun String.tr(): String { - val language = UncivGame.Current.settings.language - +fun String.tr(language:String = UncivGame.Current.settings.language): String { if (contains('<') && contains('>')) { // Conditionals! /** * So conditionals can contain placeholders, such as , which themselves diff --git a/core/src/com/unciv/ui/LanguagePickerScreen.kt b/core/src/com/unciv/ui/LanguagePickerScreen.kt index 96a4ed6325..1f046e7fbc 100644 --- a/core/src/com/unciv/ui/LanguagePickerScreen.kt +++ b/core/src/com/unciv/ui/LanguagePickerScreen.kt @@ -1,5 +1,6 @@ package com.unciv.ui +import com.unciv.Constants import com.unciv.MainMenuScreen import com.unciv.models.translations.tr import com.unciv.ui.options.OptionsPopup @@ -14,7 +15,7 @@ import com.unciv.ui.utils.extensions.onClick * Reusable code is in [LanguageTable] and [addLanguageTables]. */ class LanguagePickerScreen : PickerScreen() { - var chosenLanguage = "English" + var chosenLanguage = Constants.english private val languageTables: ArrayList diff --git a/core/src/com/unciv/ui/utils/LanguageTable.kt b/core/src/com/unciv/ui/utils/LanguageTable.kt index 272ebb0cda..a905238615 100644 --- a/core/src/com/unciv/ui/utils/LanguageTable.kt +++ b/core/src/com/unciv/ui/utils/LanguageTable.kt @@ -2,6 +2,7 @@ package com.unciv.ui.utils import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.unciv.Constants import com.unciv.UncivGame import com.unciv.ui.civilopedia.FormattedLine import com.unciv.ui.civilopedia.MarkupRenderer @@ -58,7 +59,7 @@ internal class LanguageTable(val language:String, val percentComplete: Int): Tab val languageCompletionPercentage = UncivGame.Current.translations .percentCompleteOfLanguages languageTables.addAll(languageCompletionPercentage - .map { LanguageTable(it.key, if (it.key == "English") 100 else it.value) } + .map { LanguageTable(it.key, if (it.key == Constants.english) 100 else it.value) } .sortedByDescending { it.percentComplete} ) languageTables.forEach { diff --git a/tests/src/com/unciv/testing/TranslationTests.kt b/tests/src/com/unciv/testing/TranslationTests.kt index 933aafba0c..9aa074700b 100644 --- a/tests/src/com/unciv/testing/TranslationTests.kt +++ b/tests/src/com/unciv/testing/TranslationTests.kt @@ -2,6 +2,7 @@ package com.unciv.testing import com.badlogic.gdx.Gdx +import com.unciv.Constants import com.unciv.UncivGame import com.unciv.models.metadata.GameSettings import com.unciv.models.ruleset.Ruleset @@ -258,7 +259,7 @@ class TranslationTests { fun addTranslation(original:String, result:String){ UncivGame.Current.translations[original.getPlaceholderText()] =TranslationEntry(original) - .apply { this["English"] = result } + .apply { this[Constants.english] = result } } addTranslation("The brother of [person]", "The sibling of [person]") Assert.assertEquals("The sibling of bob", "The brother of [bob]".tr())