From a2574c28315932eb20d0b20aa9aa273ffd4069f6 Mon Sep 17 00:00:00 2001 From: "Md. Touhidur Rahman" <46617994+touhidurrr@users.noreply.github.com> Date: Sun, 14 Jul 2024 12:22:38 +0600 Subject: [PATCH] More Numbers Translations Coverage (#11943) * `setText()` coverage * fix suggestions * fix victory status > our status issues * `toString()` coverage * fix build issues * Update MultiplayerTurnCheckWorker.kt --- .../com/unciv/app/MultiplayerTurnCheckWorker.kt | 7 ++++--- core/src/com/unciv/UncivGame.kt | 3 ++- core/src/com/unciv/logic/IdChecker.kt | 3 ++- core/src/com/unciv/logic/map/mapunit/MapUnit.kt | 3 ++- .../src/com/unciv/logic/simulation/MutableInt.kt | 4 +++- .../ruleset/unique/UniqueTriggerActivation.kt | 11 ++++++----- core/src/com/unciv/models/stats/Stats.kt | 8 ++++---- .../extensions/FormattingExtensions.kt | 2 +- .../components/extensions/Scene2dExtensions.kt | 2 +- .../unciv/ui/components/tilegroups/CityButton.kt | 11 ++++++----- .../ui/components/tilegroups/CityTileGroup.kt | 3 ++- .../unciv/ui/components/tilegroups/YieldGroup.kt | 3 ++- .../tilegroups/layers/TileLayerMisc.kt | 5 +++-- .../tilegroups/layers/TileLayerUnitFlag.kt | 3 ++- .../unciv/ui/components/widgets/UncivSlider.kt | 3 ++- core/src/com/unciv/ui/images/Portrait.kt | 3 ++- .../objectdescriptions/BuildingDescriptions.kt | 2 +- core/src/com/unciv/ui/popups/AskNumberPopup.kt | 7 ++++--- core/src/com/unciv/ui/popups/options/DebugTab.kt | 3 ++- .../screens/cityscreen/CityConstructionsTable.kt | 2 +- .../ui/screens/cityscreen/CityStatsTable.kt | 2 +- .../cityscreen/SpecialistAllocationTable.kt | 3 ++- .../diplomacyscreen/CityStateDiplomacyTable.kt | 3 ++- .../screens/diplomacyscreen/OfferColumnsTable.kt | 2 +- .../mapeditorscreen/tabs/MapEditorGenerateTab.kt | 6 +++--- .../screens/newgamescreen/MapParametersTable.kt | 13 +++++++------ .../ui/screens/newgamescreen/NewGameScreen.kt | 6 +++--- .../screens/newgamescreen/PlayerPickerTable.kt | 2 +- .../GlobalPoliticsOverviewTable.kt | 5 +++-- .../overviewscreen/NotificationsOverviewTable.kt | 8 +++++++- .../overviewscreen/ReligionOverviewTab.kt | 2 +- .../overviewscreen/UnitOverviewTabColumn.kt | 4 ++-- .../ui/screens/pickerscreens/TechPickerScreen.kt | 2 +- .../unciv/ui/screens/victoryscreen/LineChart.kt | 5 +++-- .../ui/screens/victoryscreen/VictoryScreen.kt | 4 ++-- .../victoryscreen/VictoryScreenCivGroup.kt | 2 +- .../ui/screens/worldscreen/WorldMapHolder.kt | 5 +++-- .../screens/worldscreen/bottombar/BattleTable.kt | 10 +++++----- .../worldscreen/bottombar/BattleTableHelpers.kt | 3 ++- .../ui/screens/worldscreen/unit/UnitTable.kt | 16 ++++++++-------- .../unit/actions/UnitActionModifiers.kt | 6 +++++- .../unit/actions/UnitActionsFromUniques.kt | 8 ++++---- 42 files changed, 119 insertions(+), 86 deletions(-) diff --git a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt index c75a550a13..53eda2a574 100644 --- a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt +++ b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt @@ -31,6 +31,7 @@ import com.unciv.logic.files.UncivFiles import com.unciv.logic.multiplayer.storage.FileStorageRateLimitReached import com.unciv.logic.multiplayer.storage.OnlineMultiplayerServer import com.unciv.models.metadata.GameSettings.GameSettingsMultiplayer +import com.unciv.models.translations.tr import java.io.FileNotFoundException import java.io.PrintWriter import java.io.StringWriter @@ -387,10 +388,10 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame private fun updatePersistentNotification(inputData: Data) { val cal = GregorianCalendar.getInstance() - val hour = cal.get(GregorianCalendar.HOUR_OF_DAY).toString() - var minute = cal.get(GregorianCalendar.MINUTE).toString() + val hour = cal.get(GregorianCalendar.HOUR_OF_DAY).tr() + var minute = cal.get(GregorianCalendar.MINUTE).tr() if (minute.length == 1) { - minute = "0$minute" + minute = (0).tr() + minute } val displayTime = "$hour:$minute" diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 3e6d6f86c6..38dcba5c29 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -17,6 +17,7 @@ import com.unciv.models.ruleset.RulesetCache import com.unciv.models.skins.SkinCache import com.unciv.models.tilesets.TileSetCache import com.unciv.models.translations.Translations +import com.unciv.models.translations.tr import com.unciv.ui.audio.MusicController import com.unciv.ui.audio.MusicMood import com.unciv.ui.audio.MusicTrackChooserFlags @@ -500,7 +501,7 @@ open class UncivGame(val isConsoleMode: Boolean = false) : Game(), PlatformSpeci ) : IsPartOfGameInfoSerialization { @Suppress("unused") // used by json serialization constructor() : this("", -1) - fun toNiceString() = "$text (Build $number)" + fun toNiceString() = "$text (Build ${number.tr()})" } } diff --git a/core/src/com/unciv/logic/IdChecker.kt b/core/src/com/unciv/logic/IdChecker.kt index 2b9d85e041..ad5efd69d3 100644 --- a/core/src/com/unciv/logic/IdChecker.kt +++ b/core/src/com/unciv/logic/IdChecker.kt @@ -1,5 +1,6 @@ package com.unciv.logic +import com.unciv.models.translations.tr import java.util.Locale import kotlin.math.abs @@ -39,7 +40,7 @@ object IdChecker { val checkDigit = trimmedPlayerId.substring(trimmedPlayerId.lastIndex, trimmedPlayerId.lastIndex +1) // remember, the format is: P-9e37e983-a676-4ecc-800e-ef8ec721a9b9-5 val shortenedPlayerId = trimmedPlayerId.substring(2, 38) - val calculatedCheckDigit = getCheckDigit(shortenedPlayerId).toString() + val calculatedCheckDigit = getCheckDigit(shortenedPlayerId).tr() require(calculatedCheckDigit == checkDigit) { "Not a valid ID. Checkdigit invalid." } diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index 67c720ef85..1743189148 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -25,6 +25,7 @@ import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.ruleset.unit.UnitType import com.unciv.models.stats.Stats +import com.unciv.models.translations.tr import com.unciv.ui.components.UnitMovementMemoryType import java.text.DecimalFormat import kotlin.math.pow @@ -204,7 +205,7 @@ class MapUnit : IsPartOfGameInfoSerialization { get() = baseUnit.type fun getMovementString(): String = - DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + getMaxMovement() + (DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + getMaxMovement()).tr() fun getTile(): Tile = currentTile diff --git a/core/src/com/unciv/logic/simulation/MutableInt.kt b/core/src/com/unciv/logic/simulation/MutableInt.kt index 66cb23d9f5..b3a993ddc3 100644 --- a/core/src/com/unciv/logic/simulation/MutableInt.kt +++ b/core/src/com/unciv/logic/simulation/MutableInt.kt @@ -1,11 +1,13 @@ package com.unciv.logic.simulation +import com.unciv.models.translations.tr + class MutableInt(var value: Int = 0) { fun inc() { ++value } fun get(): Int { return value } fun set(newValue: Int) { value = newValue } override fun toString(): String { - return value.toString() + return value.tr() } } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index 3289054e10..867a8bf2be 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -31,6 +31,7 @@ import com.unciv.models.translations.fillPlaceholders import com.unciv.models.translations.hasPlaceholderParameters import com.unciv.ui.components.extensions.addToMapOfSets import com.unciv.logic.map.tile.TileNormalizer +import com.unciv.models.translations.tr import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsUpgrade import kotlin.math.roundToInt import kotlin.random.Random @@ -620,7 +621,7 @@ object UniqueTriggerActivation { civInfo.addStats(stats) val filledNotification = if (notification != null && notification.hasPlaceholderParameters()) - notification.fillPlaceholders(statAmount.toString()) + notification.fillPlaceholders(statAmount.tr()) else notification val notificationText = getNotificationText( @@ -646,7 +647,7 @@ object UniqueTriggerActivation { civInfo.addStats(stats) val filledNotification = if (notification != null && notification.hasPlaceholderParameters()) - notification.fillPlaceholders(statAmount.toString()) + notification.fillPlaceholders(statAmount.tr()) else notification val notificationText = getNotificationText( @@ -677,7 +678,7 @@ object UniqueTriggerActivation { civInfo.addStats(stats) val filledNotification = if (notification != null && notification.hasPlaceholderParameters()) - notification.fillPlaceholders(finalStatAmount.toString()) + notification.fillPlaceholders(finalStatAmount.tr()) else notification val notificationText = getNotificationText( @@ -701,7 +702,7 @@ object UniqueTriggerActivation { if (notification != null) { val notificationText = if (notification.hasPlaceholderParameters()) - notification.fillPlaceholders(gainedFaith.toString()) + notification.fillPlaceholders(gainedFaith.tr()) else notification civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.Religion, NotificationIcon.Faith) } @@ -720,7 +721,7 @@ object UniqueTriggerActivation { if (notification != null) { val notificationText = if (notification.hasPlaceholderParameters()) - notification.fillPlaceholders(gainedFaith.toString()) + notification.fillPlaceholders(gainedFaith.tr()) else notification civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.Religion, NotificationIcon.Faith) } diff --git a/core/src/com/unciv/models/stats/Stats.kt b/core/src/com/unciv/models/stats/Stats.kt index 08b141f455..5f704140c6 100644 --- a/core/src/com/unciv/models/stats/Stats.kt +++ b/core/src/com/unciv/models/stats/Stats.kt @@ -161,19 +161,19 @@ open class Stats( */ override fun toString(): String { return this.joinToString { - (if (it.value > 0) "+" else "") + it.value.toInt() + " " + it.key.toString().tr() + (if (it.value > 0) "+" else "") + it.value.toInt().tr() + " " + it.key.toString().tr() } } /** 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() + (if (it.value > 0) "+" else "") + it.value.toInt().tr() + " " + it.key.toString() } // For display in diplomacy window fun toStringWithDecimals(): String { return this.joinToString { - (if (it.value > 0) "+" else "") + it.value.toString().removeSuffix(".0") + " " + it.key.toString().tr() + (if (it.value > 0) "+" else "") + it.value.tr().removeSuffix(".0") + " " + it.key.toString().tr() } } @@ -181,7 +181,7 @@ open class Stats( // delete this and replace above instances with toString() once the text-coloring-affecting-font-icons bug is fixed (e.g., in notification text) fun toStringWithoutIcons(): String { return this.joinToString { - it.value.toInt().toString() + " " + it.key.name.tr().substring(startIndex = 1) + it.value.toInt().tr() + " " + it.key.name.tr().substring(startIndex = 1) } } diff --git a/core/src/com/unciv/ui/components/extensions/FormattingExtensions.kt b/core/src/com/unciv/ui/components/extensions/FormattingExtensions.kt index 68691e89fe..805db40b72 100644 --- a/core/src/com/unciv/ui/components/extensions/FormattingExtensions.kt +++ b/core/src/com/unciv/ui/components/extensions/FormattingExtensions.kt @@ -41,7 +41,7 @@ fun Duration.format(): String { if (firstPartAlreadyAdded) { sb.append(", ") } - sb.append("[$part] $unit") + sb.append("[${part.tr()}] $unit") firstPartAlreadyAdded = true } return sb.toString() diff --git a/core/src/com/unciv/ui/components/extensions/Scene2dExtensions.kt b/core/src/com/unciv/ui/components/extensions/Scene2dExtensions.kt index 30b5002783..4ad273a0a2 100644 --- a/core/src/com/unciv/ui/components/extensions/Scene2dExtensions.kt +++ b/core/src/com/unciv/ui/components/extensions/Scene2dExtensions.kt @@ -290,7 +290,7 @@ fun getCloseButton( /** Translate a [String] and make a [Label] widget from it */ fun String.toLabel() = Label(this.tr(), BaseScreen.skin) /** Make a [Label] widget containing this [Int] as text */ -fun Int.toLabel() = this.toString().toLabel() +fun Int.toLabel() = this.tr().toLabel() /** Translate a [String] and make a [Label] widget from it with a specified font color and size */ fun String.toLabel(fontColor: Color = Color.WHITE, diff --git a/core/src/com/unciv/ui/components/tilegroups/CityButton.kt b/core/src/com/unciv/ui/components/tilegroups/CityButton.kt index e798d9acd6..0e888a0b73 100644 --- a/core/src/com/unciv/ui/components/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/components/tilegroups/CityButton.kt @@ -16,6 +16,7 @@ import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.models.TutorialTrigger import com.unciv.models.ruleset.INonPerpetualConstruction import com.unciv.models.ruleset.PerpetualConstruction +import com.unciv.models.translations.tr import com.unciv.ui.components.extensions.center import com.unciv.ui.components.extensions.centerX import com.unciv.ui.components.extensions.colorFromRGB @@ -154,7 +155,7 @@ class AirUnitTable(city: City, numberOfUnits: Int, size: Float=14f) : BorderedTa aircraftImage.setSize(size, size) add(aircraftImage) - add(numberOfUnits.toString().toLabel(textColor, size.toInt())) + add(numberOfUnits.tr().toLabel(textColor, size.toInt())) } } @@ -251,7 +252,7 @@ private class CityTable(city: City, forPopup: Boolean = false) : BorderedTable( private fun addCityPopNumber(city: City) { val textColor = city.civ.nation.getInnerColor() - val popLabel = city.population.population.toString() + val popLabel = city.population.population.tr() .toLabel(fontColor = textColor, fontSize = 18, alignment = Align.center) add(popLabel).minWidth(26f) } @@ -274,11 +275,11 @@ private class CityTable(city: City, forPopup: Boolean = false) : BorderedTable( val turnLabelText = when { city.isGrowing() -> { val turnsToGrowth = city.population.getNumTurnsToNewPopulation() - if (turnsToGrowth != null && turnsToGrowth < 100) turnsToGrowth.toString() else Fonts.infinity.toString() + if (turnsToGrowth != null && turnsToGrowth < 100) turnsToGrowth.tr() else Fonts.infinity.toString() } city.isStarving() -> { val turnsToStarvation = city.population.getNumTurnsToStarvation() - if (turnsToStarvation != null && turnsToStarvation < 100) turnsToStarvation.toString() else Fonts.infinity.toString() + if (turnsToStarvation != null && turnsToStarvation < 100) turnsToStarvation.tr() else Fonts.infinity.toString() } else -> "-" } @@ -351,7 +352,7 @@ private class CityTable(city: City, forPopup: Boolean = false) : BorderedTable( if (cityCurrentConstruction !is PerpetualConstruction) { val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name) if (turnsToConstruction < 100) - turns = turnsToConstruction.toString() + turns = turnsToConstruction.tr() percentage = cityConstructions.getWorkDone(cityCurrentConstruction.name) / (cityCurrentConstruction as INonPerpetualConstruction).getProductionCost(cityConstructions.city.civ, cityConstructions.city).toFloat() nextTurnPercentage = (cityConstructions.getWorkDone(cityCurrentConstruction.name) + city.cityStats.currentCityStats.production) / diff --git a/core/src/com/unciv/ui/components/tilegroups/CityTileGroup.kt b/core/src/com/unciv/ui/components/tilegroups/CityTileGroup.kt index 6c992f780e..39f46905a4 100644 --- a/core/src/com/unciv/ui/components/tilegroups/CityTileGroup.kt +++ b/core/src/com/unciv/ui/components/tilegroups/CityTileGroup.kt @@ -10,6 +10,7 @@ import com.unciv.logic.civilization.Civilization import com.unciv.logic.map.tile.Tile import com.unciv.models.ruleset.unique.LocalUniqueCache import com.unciv.models.stats.Stat +import com.unciv.models.translations.tr import com.unciv.ui.images.ImageGetter import com.unciv.ui.components.extensions.addToCenter import com.unciv.ui.components.extensions.darken @@ -61,7 +62,7 @@ class CityTileGroup(val city: City, tile: Tile, tileSetStrings: TileSetStrings, if (city.expansion.canBuyTile(tile)) { val price = city.expansion.getGoldCostOfTile(tile) - val label = price.toString().toLabel(fontSize = 9, alignment = Align.center) + val label = price.tr().toLabel(fontSize = 9, alignment = Align.center) val image = ImageGetter.getImage("TileIcons/Buy") icon = image.toGroup(26f).apply { isTransform = false } icon.addToCenter(label) diff --git a/core/src/com/unciv/ui/components/tilegroups/YieldGroup.kt b/core/src/com/unciv/ui/components/tilegroups/YieldGroup.kt index 9b426b925c..aa3ea89815 100644 --- a/core/src/com/unciv/ui/components/tilegroups/YieldGroup.kt +++ b/core/src/com/unciv/ui/components/tilegroups/YieldGroup.kt @@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align import com.unciv.models.stats.Stats +import com.unciv.models.translations.tr import com.unciv.ui.images.ImageGetter import com.unciv.ui.components.extensions.addToCenter import com.unciv.ui.components.extensions.surroundWithCircle @@ -60,7 +61,7 @@ class YieldGroup : HorizontalGroup() { group.addToCenter(largeImage) if (number > 5) { - val text = if (number < 10) number.toString() else "*" + val text = if (number < 10) number.tr() else "*" val label = text.toLabel( fontSize = 8, fontColor = Color.WHITE, diff --git a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt index 09d7a252e0..b0ed59d4be 100644 --- a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt +++ b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt @@ -10,6 +10,7 @@ import com.unciv.logic.civilization.Civilization import com.unciv.logic.map.HexMath import com.unciv.logic.map.tile.Tile import com.unciv.models.ruleset.unique.LocalUniqueCache +import com.unciv.models.translations.tr import com.unciv.ui.components.MapArrowType import com.unciv.ui.components.MiscArrowTypes import com.unciv.ui.components.TintedMapArrow @@ -266,13 +267,13 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si // Add a Label with the total count for this tile if (nations.size > 3) { // Tons of locations for this tile - display number in red, behind the top three - startingLocationIcons.add(nations.size.toString().toLabel(Color.BLACK.cpy().apply { a = 0.7f }, 14).apply { + startingLocationIcons.add(nations.size.tr().toLabel(Color.BLACK.cpy().apply { a = 0.7f }, 14).apply { tileGroup.layerMisc.addActor(this) setOrigin(Align.center) center(tileGroup) moveBy(14.4f, -9f) }) - startingLocationIcons.add(nations.size.toString().toLabel(Color.FIREBRICK, 14).apply { + startingLocationIcons.add(nations.size.tr().toLabel(Color.FIREBRICK, 14).apply { tileGroup.layerMisc.addActor(this) setOrigin(Align.center) center(tileGroup) diff --git a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerUnitFlag.kt b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerUnitFlag.kt index ecb03d5a4f..2a3b50d296 100644 --- a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerUnitFlag.kt +++ b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerUnitFlag.kt @@ -7,6 +7,7 @@ import com.unciv.UncivGame import com.unciv.logic.civilization.Civilization import com.unciv.logic.map.mapunit.MapUnit import com.unciv.models.ruleset.unique.LocalUniqueCache +import com.unciv.models.translations.tr import com.unciv.ui.components.widgets.UnitIconGroup import com.unciv.ui.components.extensions.center import com.unciv.ui.components.extensions.toLabel @@ -97,7 +98,7 @@ class TileLayerUnitFlag(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup val aircraftImage = ImageGetter.getImage("OtherIcons/Aircraft") aircraftImage.color = iconColor table.add(aircraftImage).size(8f) - table.add(unit.getTile().airUnits.size.toString().toLabel(iconColor, 10, alignment = Align.center)) + table.add(unit.getTile().airUnits.size.tr().toLabel(iconColor, 10, alignment = Align.center)) airUnitTable.add(table).expand().center().right() diff --git a/core/src/com/unciv/ui/components/widgets/UncivSlider.kt b/core/src/com/unciv/ui/components/widgets/UncivSlider.kt index a7214679e8..9cc463d92b 100644 --- a/core/src/com/unciv/ui/components/widgets/UncivSlider.kt +++ b/core/src/com/unciv/ui/components/widgets/UncivSlider.kt @@ -19,6 +19,7 @@ import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Timer import com.unciv.Constants import com.unciv.models.UncivSound +import com.unciv.models.translations.tr import com.unciv.ui.audio.SoundPlayer import com.unciv.ui.components.extensions.isShiftKeyPressed import com.unciv.ui.components.extensions.surroundWithCircle @@ -68,7 +69,7 @@ class UncivSlider ( companion object { /** Can be passed directly to the [getTipText] constructor parameter */ fun formatPercent(value: Float): String { - return (value * 100f + 0.5f).toInt().toString() + "%" + return (value * 100f + 0.5f).toInt().tr() + "%" } // constants for geometry tuning const val plusMinusFontSize = Constants.defaultFontSize diff --git a/core/src/com/unciv/ui/images/Portrait.kt b/core/src/com/unciv/ui/images/Portrait.kt index 830a2f58b8..5279e3e8fd 100644 --- a/core/src/com/unciv/ui/images/Portrait.kt +++ b/core/src/com/unciv/ui/images/Portrait.kt @@ -9,6 +9,7 @@ import com.badlogic.gdx.utils.Align import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.unit.Promotion import com.unciv.models.stats.Stats +import com.unciv.models.translations.tr import com.unciv.ui.components.extensions.center import com.unciv.ui.components.extensions.centerX import com.unciv.ui.components.extensions.colorFromRGB @@ -144,7 +145,7 @@ class PortraitResource(name: String, size: Float, amount: Int = 0) : Portrait(Ty init { if (amount > 0) { - val label = amount.toString().toLabel( + val label = amount.tr().toLabel( fontSize = 8, fontColor = Color.WHITE, alignment = Align.center) diff --git a/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt b/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt index c108bda359..de494f6793 100644 --- a/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt +++ b/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt @@ -154,7 +154,7 @@ object BuildingDescriptions { } fun getCivilopediaTextLines(building: Building, ruleset: Ruleset): List = building.run { - fun Float.formatSignedInt() = (if (this > 0f) "+" else "") + this.toInt().toString() + fun Float.formatSignedInt() = (if (this > 0f) "+" else "") + this.toInt().tr() val textList = ArrayList() diff --git a/core/src/com/unciv/ui/popups/AskNumberPopup.kt b/core/src/com/unciv/ui/popups/AskNumberPopup.kt index 31895d452d..3ef132a5d6 100644 --- a/core/src/com/unciv/ui/popups/AskNumberPopup.kt +++ b/core/src/com/unciv/ui/popups/AskNumberPopup.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextField +import com.unciv.models.translations.tr import com.unciv.ui.components.widgets.UncivTextField import com.unciv.ui.components.input.onChange import com.unciv.ui.components.input.onClick @@ -74,10 +75,10 @@ class AskNumberPopup( val int = input.toIntOrNull() ?: return input if (bounds.first > int) { - return bounds.first.toString() + return bounds.first.tr() } if (bounds.last < int) - return bounds.last.toString() + return bounds.last.tr() return input } @@ -96,7 +97,7 @@ class AskNumberPopup( ).apply { onClick { if (isValidInt(nameField.text)) - nameField.text = clampInBounds((nameField.text.toInt() + value).toString()) + nameField.text = clampInBounds((nameField.text.toInt() + value).tr()) } } ).pad(5f) diff --git a/core/src/com/unciv/ui/popups/options/DebugTab.kt b/core/src/com/unciv/ui/popups/options/DebugTab.kt index f769038c03..4346d9bbb0 100644 --- a/core/src/com/unciv/ui/popups/options/DebugTab.kt +++ b/core/src/com/unciv/ui/popups/options/DebugTab.kt @@ -10,6 +10,7 @@ import com.unciv.logic.files.MapSaver import com.unciv.logic.files.UncivFiles import com.unciv.models.ruleset.RulesetCache import com.unciv.models.ruleset.tile.ResourceType +import com.unciv.models.translations.tr import com.unciv.ui.components.widgets.UncivTextField import com.unciv.ui.components.extensions.addSeparator import com.unciv.ui.components.extensions.toCheckBox @@ -31,7 +32,7 @@ fun debugTab( if (GUI.isWorldLoaded()) { val simulateButton = "Simulate until turn:".toTextButton() - val simulateTextField = UncivTextField("Turn", DebugUtils.SIMULATE_UNTIL_TURN.toString()) + val simulateTextField = UncivTextField("Turn", DebugUtils.SIMULATE_UNTIL_TURN.tr()) val invalidInputLabel = "This is not a valid integer!".toLabel().also { it.isVisible = false } simulateButton.onClick { val simulateUntilTurns = simulateTextField.text.toIntOrNull() diff --git a/core/src/com/unciv/ui/screens/cityscreen/CityConstructionsTable.kt b/core/src/com/unciv/ui/screens/cityscreen/CityConstructionsTable.kt index 34a88cc319..de25d26591 100644 --- a/core/src/com/unciv/ui/screens/cityscreen/CityConstructionsTable.kt +++ b/core/src/com/unciv/ui/screens/cityscreen/CityConstructionsTable.kt @@ -434,7 +434,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) { for ((resource, amount) in constructionButtonDTO.resourcesRequired) { val color = if (constructionButtonDTO.rejectionReason?.type == RejectionReasonType.ConsumesResources) Color.RED else Color.WHITE - resourceTable.add(amount.toString().toLabel(fontColor = color)).expandX().left().padLeft(5f) + resourceTable.add(amount.tr().toLabel(fontColor = color)).expandX().left().padLeft(5f) resourceTable.add(ImageGetter.getResourcePortrait(resource, 15f)).padBottom(1f) } } diff --git a/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt index c8d8642503..68ed1140e6 100644 --- a/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt @@ -143,7 +143,7 @@ class CityStatsTable(private val cityScreen: CityScreen) : Table() { private fun addText() { val unassignedPopString = "{Unassigned population}: ".tr() + - city.population.getFreePopulation().toString() + "/" + city.population.population + city.population.getFreePopulation().tr() + "/" + city.population.population.tr() val unassignedPopLabel = unassignedPopString.toLabel() if (cityScreen.canChangeState) unassignedPopLabel.onClick { city.reassignPopulation(); cityScreen.update() } diff --git a/core/src/com/unciv/ui/screens/cityscreen/SpecialistAllocationTable.kt b/core/src/com/unciv/ui/screens/cityscreen/SpecialistAllocationTable.kt index 4c3728c1d1..4551f90471 100644 --- a/core/src/com/unciv/ui/screens/cityscreen/SpecialistAllocationTable.kt +++ b/core/src/com/unciv/ui/screens/cityscreen/SpecialistAllocationTable.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align import com.unciv.Constants +import com.unciv.models.translations.tr import com.unciv.ui.components.SmallButtonStyle import com.unciv.ui.components.UncivTooltip.Companion.addTooltip import com.unciv.ui.components.extensions.addSeparatorVertical @@ -122,7 +123,7 @@ class SpecialistAllocationTable(private val cityScreen: CityScreen) : Table(Base var itemsInRow = 0 fun addWrapping(value: Int, labelColor: Color, icon: Actor) { - specialistStatTable.add(value.toString().toLabel(labelColor)) + specialistStatTable.add(value.tr().toLabel(labelColor)) specialistStatTable.add(icon).size(20f).padRight(10f) itemsInRow++ diff --git a/core/src/com/unciv/ui/screens/diplomacyscreen/CityStateDiplomacyTable.kt b/core/src/com/unciv/ui/screens/diplomacyscreen/CityStateDiplomacyTable.kt index 1cd6050034..ebda3255c0 100644 --- a/core/src/com/unciv/ui/screens/diplomacyscreen/CityStateDiplomacyTable.kt +++ b/core/src/com/unciv/ui/screens/diplomacyscreen/CityStateDiplomacyTable.kt @@ -32,6 +32,7 @@ import com.unciv.ui.components.input.onClick import com.unciv.ui.components.widgets.ColorMarkupLabel import com.unciv.ui.images.ImageGetter import com.unciv.ui.popups.ConfirmPopup +import kotlin.reflect.typeOf class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) { val viewingCiv = diplomacyScreen.viewingCiv @@ -410,7 +411,7 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) { for (item in tributeModifiers) { val color = if (item.value >= 0) Color.GREEN else Color.RED modifierTable.add(item.key.toLabel(color)) - modifierTable.add(item.value.toString().toLabel(color)).row() + modifierTable.add(item.value.tr().toLabel(color)).row() } modifierTable.add("Sum:".toLabel()) modifierTable.add(tributeModifiers.values.sum().toLabel()).row() diff --git a/core/src/com/unciv/ui/screens/diplomacyscreen/OfferColumnsTable.kt b/core/src/com/unciv/ui/screens/diplomacyscreen/OfferColumnsTable.kt index 9e1dcf3709..54a8a0b6e2 100644 --- a/core/src/com/unciv/ui/screens/diplomacyscreen/OfferColumnsTable.kt +++ b/core/src/com/unciv/ui/screens/diplomacyscreen/OfferColumnsTable.kt @@ -120,7 +120,7 @@ class OfferColumnsTable( screen, label = "Enter the amount of gold", icon = ImageGetter.getStatIcon("Gold").surroundWithCircle(80f), - defaultValue = offer.amount.toString(), + defaultValue = offer.amount.tr(), amountButtons = if (offer.type == TradeOfferType.Gold) listOf(50, 500) else listOf(5, 15), diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt index 74bbe24c70..1671a97815 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt @@ -72,9 +72,9 @@ class MapEditorGenerateTab( Concurrency.runOnGLThread { ToastPopup( message, editorScreen, 4000 ) newTab.mapParametersTable.run { mapParameters.mapSize.also { - customMapSizeRadius.text = it.radius.toString() - customMapWidth.text = it.width.toString() - customMapHeight.text = it.height.toString() + customMapSizeRadius.text = it.radius.tr() + customMapWidth.text = it.width.tr() + customMapHeight.text = it.height.tr() } } } return diff --git a/core/src/com/unciv/ui/screens/newgamescreen/MapParametersTable.kt b/core/src/com/unciv/ui/screens/newgamescreen/MapParametersTable.kt index dfe32a40d0..a657c8180c 100644 --- a/core/src/com/unciv/ui/screens/newgamescreen/MapParametersTable.kt +++ b/core/src/com/unciv/ui/screens/newgamescreen/MapParametersTable.kt @@ -13,6 +13,7 @@ import com.unciv.logic.map.mapgenerator.MapResourceSetting import com.unciv.logic.map.MapShape import com.unciv.logic.map.MapSize import com.unciv.logic.map.MapType +import com.unciv.models.translations.tr import com.unciv.ui.components.widgets.UncivTextField import com.unciv.ui.components.extensions.pad import com.unciv.ui.components.extensions.toCheckBox @@ -99,7 +100,7 @@ class MapParametersTable( fun reseed() { mapParameters.reseed() - seedTextField.text = mapParameters.seed.toString() + seedTextField.text = mapParameters.seed.tr() } private fun addMapShapeSelectBox() { @@ -204,7 +205,7 @@ class MapParametersTable( } private fun addHexagonalSizeTable() { - val defaultRadius = mapParameters.mapSize.radius.toString() + val defaultRadius = mapParameters.mapSize.radius.tr() customMapSizeRadius = UncivTextField("Radius", defaultRadius).apply { textFieldFilter = DigitsOnlyFilter() } @@ -218,12 +219,12 @@ class MapParametersTable( } private fun addRectangularSizeTable() { - val defaultWidth = mapParameters.mapSize.width.toString() + val defaultWidth = mapParameters.mapSize.width.tr() customMapWidth = UncivTextField("Width", defaultWidth).apply { textFieldFilter = DigitsOnlyFilter() } - val defaultHeight = mapParameters.mapSize.height.toString() + val defaultHeight = mapParameters.mapSize.height.tr() customMapHeight = UncivTextField("Height", defaultHeight).apply { textFieldFilter = DigitsOnlyFilter() } @@ -360,7 +361,7 @@ class MapParametersTable( private fun addAdvancedControls(table: Table) { table.defaults().pad(5f) - seedTextField = UncivTextField("RNG Seed", mapParameters.seed.toString()) + seedTextField = UncivTextField("RNG Seed", mapParameters.seed.tr()) seedTextField.textFieldFilter = DigitsOnlyFilter() // If the field is empty, fallback seed value to 0 @@ -440,7 +441,7 @@ class MapParametersTable( addTextButton("Reset to defaults", true) { mapParameters.resetAdvancedSettings() - seedTextField.text = mapParameters.seed.toString() + seedTextField.text = mapParameters.seed.tr() for (entry in advancedSliders) entry.key.value = entry.value() } diff --git a/core/src/com/unciv/ui/screens/newgamescreen/NewGameScreen.kt b/core/src/com/unciv/ui/screens/newgamescreen/NewGameScreen.kt index b018878925..d38a8ce1f9 100644 --- a/core/src/com/unciv/ui/screens/newgamescreen/NewGameScreen.kt +++ b/core/src/com/unciv/ui/screens/newgamescreen/NewGameScreen.kt @@ -209,9 +209,9 @@ class NewGameScreen( if (message != null) { ToastPopup( message, UncivGame.Current.screen!!, 4000 ) with (mapOptionsTable.generatedMapOptionsTable) { - customMapSizeRadius.text = mapSize.radius.toString() - customMapWidth.text = mapSize.width.toString() - customMapHeight.text = mapSize.height.toString() + customMapSizeRadius.text = mapSize.radius.tr() + customMapWidth.text = mapSize.width.tr() + customMapHeight.text = mapSize.height.tr() } Gdx.input.inputProcessor = stage return diff --git a/core/src/com/unciv/ui/screens/newgamescreen/PlayerPickerTable.kt b/core/src/com/unciv/ui/screens/newgamescreen/PlayerPickerTable.kt index 3be859590a..ac480f9333 100644 --- a/core/src/com/unciv/ui/screens/newgamescreen/PlayerPickerTable.kt +++ b/core/src/com/unciv/ui/screens/newgamescreen/PlayerPickerTable.kt @@ -126,7 +126,7 @@ class PlayerPickerTable( fun updateRandomNumberLabel() { randomNumberLabel?.run { val playerRange = if (gameParameters.minNumberOfPlayers == gameParameters.maxNumberOfPlayers) { - gameParameters.minNumberOfPlayers.toString() + gameParameters.minNumberOfPlayers.tr() } else { "${gameParameters.minNumberOfPlayers} - ${gameParameters.maxNumberOfPlayers}" } diff --git a/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt b/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt index e0c1e449e9..59b878c657 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt @@ -19,6 +19,7 @@ import com.unciv.logic.map.HexMath import com.unciv.models.ruleset.Policy.PolicyBranchType import com.unciv.models.ruleset.nation.getContrastRatio import com.unciv.models.ruleset.unique.UniqueType +import com.unciv.models.translations.tr import com.unciv.ui.components.UncivTooltip.Companion.addTooltip import com.unciv.ui.components.extensions.addBorder import com.unciv.ui.components.extensions.addSeparator @@ -290,7 +291,7 @@ class GlobalPoliticsOverviewTable( relevantCivsCount = if (hideCivsCount) "?" else gameInfo.civilizations.count { !it.isSpectator() && !it.isBarbarian && (persistableData.includeCityStates || !it.isCityState) - }.toString() + }.tr() undefeatedCivs = sequenceOf(viewingPlayer) + viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates) defeatedCivs = viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates, true) @@ -366,7 +367,7 @@ class GlobalPoliticsOverviewTable( add("Our Civilization:".toLabel()).colspan(columns).left().padLeft(10f).padTop(10f).row() add(getCivMiniTable(viewingPlayer)).left() val scoreText = if (viewingPlayer.isDefeated()) Fonts.death.toString() - else viewingPlayer.calculateTotalScore().toInt().toString() + else viewingPlayer.calculateTotalScore().toInt().tr() add(scoreText.toLabel()).left().row() val turnsTillNextDiplomaticVote = viewingPlayer.getTurnsTillNextDiplomaticVote() ?: return add("Turns until the next\ndiplomacy victory vote: [$turnsTillNextDiplomaticVote]".toLabel()).colspan(columns).row() diff --git a/core/src/com/unciv/ui/screens/overviewscreen/NotificationsOverviewTable.kt b/core/src/com/unciv/ui/screens/overviewscreen/NotificationsOverviewTable.kt index f9eed772a8..1f971caf8b 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/NotificationsOverviewTable.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/NotificationsOverviewTable.kt @@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.logic.civilization.Civilization import com.unciv.logic.civilization.Notification import com.unciv.logic.civilization.NotificationCategory +import com.unciv.models.translations.tr import com.unciv.ui.components.widgets.ColorMarkupLabel import com.unciv.ui.components.widgets.TabbedPager import com.unciv.ui.components.input.onClick @@ -53,7 +54,12 @@ class NotificationsOverviewTable( notificationTable.add(notificationsArrayTable("Current", viewingPlayer.notifications)).row() for (notification in notificationLog.asReversed()) { - notificationTable.add(notificationsArrayTable(notification.turn.toString(), notification.notifications)) + notificationTable.add( + notificationsArrayTable( + notification.turn.tr(), + notification.notifications + ) + ) notificationTable.padTop(20f).row() } } diff --git a/core/src/com/unciv/ui/screens/overviewscreen/ReligionOverviewTab.kt b/core/src/com/unciv/ui/screens/overviewscreen/ReligionOverviewTab.kt index 24dbc47496..2a11e894b8 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/ReligionOverviewTab.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/ReligionOverviewTab.kt @@ -80,7 +80,7 @@ class ReligionOverviewTab( it.defaults().padTop(10f) for ((text, num) in manager.remainingFoundableReligionsBreakdown()) { it.add(text.toLabel()) - it.add(num.toString().toLabel(alignment = Align.right)).right().row() + it.add(num.tr().toLabel(alignment = Align.right)).right().row() } } add(religionCountExpander).colspan(2).growX().row() diff --git a/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTabColumn.kt b/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTabColumn.kt index 5df09ec86a..447b6e7708 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTabColumn.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTabColumn.kt @@ -112,7 +112,7 @@ enum class UnitOverviewTabColumn( Health(isNumeric = true) { override fun getEntryValue(item: MapUnit) = item.health - override fun getEntryString(item: MapUnit) = if (item.health == 100) null else item.health.toString() + override fun getEntryString(item: MapUnit) = if (item.health == 100) null else item.health.tr() override fun getTotalsActor(items: Iterable) = items.count { it.health < 100 }.toCenteredLabel() }, ; @@ -126,7 +126,7 @@ enum class UnitOverviewTabColumn( override val defaultSort get() = SortableGrid.SortDirection.Ascending //endregion - open fun getEntryString(item: MapUnit): String? = getEntryValue(item).takeIf { it > 0 }?.toString() + open fun getEntryString(item: MapUnit): String? = getEntryValue(item).takeIf { it > 0 }?.tr() //region Overridden superclass methods override fun getHeaderActor(iconSize: Float) = (headerLabel ?: name).toLabel() diff --git a/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt index 7e2478abf7..b8883bf5aa 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt @@ -357,7 +357,7 @@ class TechPickerScreen( techTable.stageToLocalCoordinates(techButtonCoords) if (tempTechsToResearch.contains(techName) && tempTechsToResearch.size > 1) { val index = tempTechsToResearch.indexOf(techName) + 1 - val orderIndicator = index.toString().toLabel(fontSize = 18) + val orderIndicator = index.tr().toLabel(fontSize = 18) .apply { setAlignment(Align.center) } .surroundWithCircle(28f, color = skinStrings.skinConfig.baseColor) .surroundWithCircle(30f,false) diff --git a/core/src/com/unciv/ui/screens/victoryscreen/LineChart.kt b/core/src/com/unciv/ui/screens/victoryscreen/LineChart.kt index dd32bbf77e..22f98b30ae 100644 --- a/core/src/com/unciv/ui/screens/victoryscreen/LineChart.kt +++ b/core/src/com/unciv/ui/screens/victoryscreen/LineChart.kt @@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup import com.badlogic.gdx.utils.Align import com.unciv.logic.civilization.Civilization +import com.unciv.models.translations.tr import com.unciv.ui.components.fonts.Fonts import com.unciv.ui.images.ImageGetter import com.unciv.ui.screens.victoryscreen.VictoryScreenCivGroup.DefeatedPlayerStyle @@ -72,9 +73,9 @@ class LineChart( yLabels = generateLabels(newData, true) xLabelsAsLabels = - xLabels.map { Label(it.toString(), Label.LabelStyle(Fonts.font, axisLabelColor)) } + xLabels.map { Label(it.tr(), Label.LabelStyle(Fonts.font, axisLabelColor)) } yLabelsAsLabels = - yLabels.map { Label(it.toString(), Label.LabelStyle(Fonts.font, axisLabelColor)) } + yLabels.map { Label(it.tr(), Label.LabelStyle(Fonts.font, axisLabelColor)) } } fun generateLabels(value: List>, yAxis: Boolean): List { diff --git a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt index f8e2a52907..46f60a59a6 100644 --- a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt +++ b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreen.kt @@ -90,7 +90,7 @@ class VictoryScreen( splitPane.setFirstWidget(tabs) val iconSize = Constants.headingFontSize.toFloat() - for (tab in VictoryTabs.values()) { + for (tab in VictoryTabs.entries) { val tabHidden = tab.isHidden(playerCiv) if (tabHidden && !(tab.allowAsSecret && Gdx.input.areSecretKeysPressed())) continue @@ -129,7 +129,7 @@ class VictoryScreen( align(Align.right) addActor("{Game Speed}: {${gameInfo.gameParameters.speed}}".toLabel()) if ("Time" in gameInfo.gameParameters.victoryTypes) - addActor("{Max Turns}: ${gameInfo.gameParameters.maxTurns}".toLabel()) + addActor("{Max Turns}: ${gameInfo.gameParameters.maxTurns.tr()}".toLabel()) pack() } val difficultyLabel = "{Difficulty}: {${gameInfo.difficulty}}".toLabel() diff --git a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenCivGroup.kt b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenCivGroup.kt index e13db17b40..39e7f9f4ad 100644 --- a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenCivGroup.kt +++ b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenCivGroup.kt @@ -41,7 +41,7 @@ internal class VictoryScreenCivGroup( civEntry.civ, ": ", // Don't show a `0` for defeated civs. - if (civEntry.civ.isDefeated()) "" else civEntry.value.toString(), + if (civEntry.civ.isDefeated()) "" else civEntry.value.tr(), currentPlayer, defeatedPlayerStyle ) diff --git a/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt index a78fa2ff1e..0f9e76fb71 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt @@ -27,6 +27,7 @@ import com.unciv.logic.map.tile.Tile import com.unciv.models.Spy import com.unciv.models.UncivSound import com.unciv.models.UnitActionType +import com.unciv.models.translations.tr import com.unciv.ui.audio.SoundPlayer import com.unciv.ui.components.MapArrowType import com.unciv.ui.components.MiscArrowTypes @@ -563,7 +564,7 @@ class WorldMapHolder( .surroundWithCircle(buttonSize, false, Color.BLACK) if (!isParadrop) { - val numberCircle = dto.unitToTurnsToDestination.values.maxOrNull()!!.toString().toLabel(fontSize = 14) + val numberCircle = dto.unitToTurnsToDestination.values.maxOrNull()!!.tr().toLabel(fontSize = 14) .apply { setAlignment(Align.center) } .surroundWithCircle(smallerCircleSizes - 2, color = BaseScreen.skinStrings.skinConfig.baseColor.darken(0.3f)) .surroundWithCircle(smallerCircleSizes, false) @@ -572,7 +573,7 @@ class WorldMapHolder( val firstUnit = dto.unitToTurnsToDestination.keys.first() val unitIcon = if (dto.unitToTurnsToDestination.size == 1) UnitIconGroup(firstUnit, smallerCircleSizes) - else dto.unitToTurnsToDestination.size.toString().toLabel(fontColor = firstUnit.civ.nation.getInnerColor()).apply { setAlignment(Align.center) } + else dto.unitToTurnsToDestination.size.tr().toLabel(fontColor = firstUnit.civ.nation.getInnerColor()).apply { setAlignment(Align.center) } .surroundWithCircle(smallerCircleSizes).apply { circle.color = firstUnit.civ.nation.getOuterColor() } unitIcon.y = buttonSize - unitIcon.height moveHereButton.addActor(unitIcon) diff --git a/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTable.kt index 823155aaa5..ea5baa1120 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTable.kt @@ -164,8 +164,8 @@ class BattleTable(val worldScreen: WorldScreen) : Table() { if (attacker.isRanged() && defender.isRanged() && !defender.isCity() && !(defender is MapUnitCombatant && defender.unit.isEmbarked())) Fonts.rangedStrength else Fonts.strength // use strength icon if attacker is melee, defender is melee, defender is a city, or defender is embarked - add(attacker.getAttackingStrength().toString() + attackIcon) - add(defender.getDefendingStrength(attacker.isRanged()).toString() + defenceIcon).row() + add(attacker.getAttackingStrength().tr() + attackIcon) + add(defender.getDefendingStrength(attacker.isRanged()).tr() + defenceIcon).row() val attackerModifiers = BattleDamage.getAttackModifiers(attacker, defender, tileToAttackFrom).map { @@ -188,8 +188,8 @@ class BattleTable(val worldScreen: WorldScreen) : Table() { addSeparator() val attackerStrength = BattleDamage.getAttackingStrength(attacker, defender, tileToAttackFrom).roundToInt() val defenderStrength = BattleDamage.getDefendingStrength(attacker, defender, tileToAttackFrom).roundToInt() - add(attackerStrength.toString() + attackIcon) - add(defenderStrength.toString() + attackIcon).row() + add(attackerStrength.tr() + attackIcon) + add(defenderStrength.tr() + attackIcon).row() } // from Battle.addXp(), check for can't gain more XP from Barbarians @@ -378,7 +378,7 @@ class BattleTable(val worldScreen: WorldScreen) : Table() { addSeparator().pad(0f) val attackIcon = Fonts.rangedStrength - add(attacker.getAttackingStrength().toString() + attackIcon) + add(attacker.getAttackingStrength().tr() + attackIcon) add("???$attackIcon").row() val attackerModifiers = diff --git a/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTableHelpers.kt b/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTableHelpers.kt index f32526634a..b248d41682 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTableHelpers.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/bottombar/BattleTableHelpers.kt @@ -18,6 +18,7 @@ import com.unciv.UncivGame import com.unciv.logic.battle.ICombatant import com.unciv.logic.battle.MapUnitCombatant import com.unciv.logic.map.HexMath +import com.unciv.models.translations.tr import com.unciv.ui.components.tilegroups.TileSetStrings import com.unciv.ui.components.widgets.ShadowedLabel import com.unciv.ui.images.ImageGetter @@ -208,7 +209,7 @@ object BattleTableHelpers { private fun createDamageLabel(damage: Int, target: Actor) { if (damage == 0) return - val container = ShadowedLabel((-damage).toString(), damageLabelFontSize, Color.RED) + val container = ShadowedLabel((-damage).tr(), damageLabelFontSize, Color.RED) val targetRight = target.run { localToStageCoordinates(Vector2(width, height * 0.5f)) } container.setPosition(targetRight.x, targetRight.y, Align.center) target.stage.addActor(container) diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/UnitTable.kt index 3c987ae544..75e75cf97c 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/UnitTable.kt @@ -178,23 +178,23 @@ class UnitTable(val worldScreen: WorldScreen) : Table() { if (!unit.isCivilian()) { unitDescriptionTable.add(ImageGetter.getStatIcon("Strength")).size(20f) - unitDescriptionTable.add(unit.baseUnit.strength.toString()).padRight(10f) + unitDescriptionTable.add(unit.baseUnit.strength.tr()).padRight(10f) } if (unit.baseUnit.rangedStrength != 0) { unitDescriptionTable.add(ImageGetter.getStatIcon("RangedStrength")).size(20f) - unitDescriptionTable.add(unit.baseUnit.rangedStrength.toString()).padRight(10f) + unitDescriptionTable.add(unit.baseUnit.rangedStrength.tr()).padRight(10f) } if (unit.baseUnit.isRanged()) { unitDescriptionTable.add(ImageGetter.getStatIcon("Range")).size(20f) - unitDescriptionTable.add(unit.getRange().toString()).padRight(10f) + unitDescriptionTable.add(unit.getRange().tr()).padRight(10f) } val interceptionRange = unit.getInterceptionRange() if (interceptionRange > 0) { unitDescriptionTable.add(ImageGetter.getStatIcon("InterceptRange")).size(20f) - unitDescriptionTable.add(interceptionRange.toString()).padRight(10f) + unitDescriptionTable.add(interceptionRange.tr()).padRight(10f) } if (!unit.isCivilian()) { @@ -204,12 +204,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table() { worldScreen.game.pushScreen(PromotionPickerScreen(unit)) } }) - unitDescriptionTable.add(unit.promotions.XP.toString() + "/" + unit.promotions.xpForNextPromotion()) + unitDescriptionTable.add(unit.promotions.XP.tr() + "/" + unit.promotions.xpForNextPromotion().tr()) } if (unit.baseUnit.religiousStrength > 0) { unitDescriptionTable.add(ImageGetter.getStatIcon("ReligiousStrength")).size(20f) - unitDescriptionTable.add((unit.baseUnit.religiousStrength - unit.religiousStrengthLost).toString()) + unitDescriptionTable.add((unit.baseUnit.religiousStrength - unit.religiousStrengthLost).tr()) } if (unit.promotions.promotions.size != promotionsTable.children.size) // The unit has been promoted! Reload promotions! @@ -241,9 +241,9 @@ class UnitTable(val worldScreen: WorldScreen) : Table() { unitDescriptionTable.clear() unitDescriptionTable.defaults().pad(2f).padRight(5f) unitDescriptionTable.add("Strength".tr()) - unitDescriptionTable.add(CityCombatant(city).getDefendingStrength().toString()).row() + unitDescriptionTable.add(CityCombatant(city).getDefendingStrength().tr()).row() unitDescriptionTable.add("Bombard strength".tr()) - unitDescriptionTable.add(CityCombatant(city).getAttackingStrength().toString()).row() + unitDescriptionTable.add(CityCombatant(city).getAttackingStrength().tr()).row() selectedUnitHasChanged = true } else if (selectedSpy != null) { diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt index f0d98be8db..23b66a1407 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt @@ -173,7 +173,11 @@ object UnitActionModifiers { if (actionUnique.conditionals.any { it.type == UniqueType.UnitActionConsumeUnit } || actionUnique.conditionals.any { it.type == UniqueType.UnitActionAfterWhichConsumed } && usagesLeft(unit, actionUnique) == 1 ) effects += Fonts.death.toString() - else effects += getMovementPointsToUse(unit, actionUnique, defaultAllMovement).toString() + Fonts.movement + else effects += getMovementPointsToUse( + unit, + actionUnique, + defaultAllMovement + ).tr() + Fonts.movement return if (effects.isEmpty()) "" else "(${effects.joinToString { it.tr() }})" diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt index ff9e1d885f..7671b3a371 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt @@ -179,14 +179,14 @@ object UnitActionsFromUniques { UniqueType.OneTimeEnterGoldenAgeTurns -> { unique.placeholderText.fillPlaceholders( unit.civ.goldenAges.calculateGoldenAgeLength( - unique.params[0].toInt()).toString()) + unique.params[0].toInt()).tr()) } UniqueType.OneTimeGainStatSpeed -> { val stat = unique.params[1] val modifier = unit.civ.gameInfo.speed.statCostModifiers[Stat.safeValueOf(stat)] ?: unit.civ.gameInfo.speed.modifier UniqueType.OneTimeGainStat.placeholderText.fillPlaceholders( - (unique.params[0].toInt() * modifier).toInt().toString(), stat + (unique.params[0].toInt() * modifier).toInt().tr(), stat ) } UniqueType.OneTimeGainStatRange -> { @@ -194,8 +194,8 @@ object UnitActionsFromUniques { val modifier = unit.civ.gameInfo.speed.statCostModifiers[Stat.safeValueOf(stat)] ?: unit.civ.gameInfo.speed.modifier unique.placeholderText.fillPlaceholders( - (unique.params[0].toInt() * modifier).toInt().toString(), - (unique.params[1].toInt() * modifier).toInt().toString(), + (unique.params[0].toInt() * modifier).toInt().tr(), + (unique.params[1].toInt() * modifier).toInt().tr(), stat ) }