More Numbers Translations Coverage (#11943)

* `setText()` coverage

* fix suggestions

* fix victory status > our status issues

* `toString()` coverage

* fix build issues

* Update MultiplayerTurnCheckWorker.kt
This commit is contained in:
Md. Touhidur Rahman 2024-07-14 12:22:38 +06:00 committed by GitHub
parent 2ffcc48bbf
commit a2574c2831
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
42 changed files with 119 additions and 86 deletions

View File

@ -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"

View File

@ -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()})"
}
}

View File

@ -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."
}

View File

@ -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

View File

@ -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()
}
}

View File

@ -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)
}

View File

@ -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)
}
}

View File

@ -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()

View File

@ -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,

View File

@ -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) /

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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)

View File

@ -154,7 +154,7 @@ object BuildingDescriptions {
}
fun getCivilopediaTextLines(building: Building, ruleset: Ruleset): List<FormattedLine> = 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<FormattedLine>()

View File

@ -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)

View File

@ -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()

View File

@ -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)
}
}

View File

@ -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() }

View File

@ -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++

View File

@ -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()

View File

@ -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),

View File

@ -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

View File

@ -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()
}

View File

@ -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

View File

@ -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}"
}

View File

@ -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()

View File

@ -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()
}
}

View File

@ -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()

View File

@ -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<MapUnit>) = 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()

View File

@ -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)

View File

@ -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<DataPoint<Int>>, yAxis: Boolean): List<Int> {

View File

@ -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()

View File

@ -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
)

View File

@ -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)

View File

@ -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 =

View File

@ -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)

View File

@ -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) {

View File

@ -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() }})"

View File

@ -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
)
}