diff --git a/core/src/com/unciv/models/ruleset/UniqueType.kt b/core/src/com/unciv/models/ruleset/UniqueType.kt index 9eddeecade..cb77d69c2a 100644 --- a/core/src/com/unciv/models/ruleset/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/UniqueType.kt @@ -18,7 +18,7 @@ enum class UniqueType(val text:String, val replacedBy: UniqueType? = null) { /** For uniques that have "special" parameters that can accept multiple types, we can override them manually * For 95% of cases, auto-matching is fine. */ - private val parameterTypeMap = ArrayList>() + val parameterTypeMap = ArrayList>() init { for (placeholder in text.getPlaceholderParameters()) { diff --git a/core/src/com/unciv/models/translations/TranslationFileWriter.kt b/core/src/com/unciv/models/translations/TranslationFileWriter.kt index df79242818..bac7574066 100644 --- a/core/src/com/unciv/models/translations/TranslationFileWriter.kt +++ b/core/src/com/unciv/models/translations/TranslationFileWriter.kt @@ -244,16 +244,19 @@ object TranslationFileWriter { generatedStrings[filename] = mutableSetOf() val resultStrings = generatedStrings[filename]!! - fun submitString(item: Any) { - val string = item.toString() - - val parameters = string.getPlaceholderParameters() + fun submitString(string: String) { + val unique = Unique(string) var stringToTranslate = string val existingParameterNames = HashSet() - if (parameters.any()) { - for (parameter in parameters) { + if (unique.params.isNotEmpty()) { + for ((index,parameter) in unique.params.withIndex()) { var parameterName = when { + unique.type != null -> { + val possibleParameterTypes = unique.type.parameterTypeMap[index] + // for multiple types. will look like "[unitName/buildingName]" + possibleParameterTypes.joinToString("/") { it.parameterName } + } parameter.toFloatOrNull() != null -> "amount" Stat.values().any { it.name == parameter } -> "stat" parameter in tileFilterMap -> "tileFilter" @@ -320,7 +323,7 @@ object TranslationFileWriter { is kotlin.collections.List<*> -> for (item in fieldValue) if (item is String) submitString(item) else serializeElement(item!!) - else -> submitString(fieldValue) + else -> submitString(fieldValue.toString()) } } }