From 3d13680602eb164628e902b2bf74f302cfd5e5b1 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Tue, 20 Jul 2021 16:07:15 +0200 Subject: [PATCH] Update translationFileWriter to include missing strings (#4578) * Update translationFileWriter to include strings from new json files * Fix promotions with multiple uniques not getting translated * Add missing translatable strings (thanks to DuffLagerleff for finding these) --- .../jsons/translations/template.properties | 16 +++++++++++----- .../com/unciv/models/ruleset/unit/Promotion.kt | 2 +- .../models/translations/TranslationFileWriter.kt | 8 ++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 7286c40978..59d317dd0e 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -566,12 +566,13 @@ No = Acquire = Under construction = -Gold = -Science = -Happiness = -Production = -Culture = Food = +Production = +Gold = +Happiness = +Culture = +Science = +Faith = Crop Yield = Territory = @@ -739,6 +740,7 @@ Luxury resource = Strategic resource = Fresh water = non-fresh water = +Natural Wonder = # improvementFilters @@ -938,6 +940,10 @@ All policies adopted = Choose an Icon and name for your Religion = Choose a [$beliefType] belief! = Found [religionName] = +Choose a pantheon = +Found Religion = +Found Pantheon = +Follow [belief] = # Terrains diff --git a/core/src/com/unciv/models/ruleset/unit/Promotion.kt b/core/src/com/unciv/models/ruleset/unit/Promotion.kt index f6c4a58fcc..629611b91e 100644 --- a/core/src/com/unciv/models/ruleset/unit/Promotion.kt +++ b/core/src/com/unciv/models/ruleset/unit/Promotion.kt @@ -11,7 +11,7 @@ class Promotion : INamed{ var effect = "" var unitTypes = listOf() // The json parser wouldn't agree to deserialize this as a list of UnitTypes. =( - var uniques = listOf() + var uniques = ArrayList() val uniqueObjects: List by lazy { uniques.map { Unique(it) } + Unique(effect) } fun getDescription(promotionsForUnitType: Collection, forCivilopedia:Boolean=false, ruleSet:Ruleset? = null):String { diff --git a/core/src/com/unciv/models/translations/TranslationFileWriter.kt b/core/src/com/unciv/models/translations/TranslationFileWriter.kt index ba96ef4683..bda0a63707 100644 --- a/core/src/com/unciv/models/translations/TranslationFileWriter.kt +++ b/core/src/com/unciv/models/translations/TranslationFileWriter.kt @@ -222,6 +222,7 @@ object TranslationFileWriter { || parameter == "non-fresh water" || parameter == "Open Terrain" || parameter == "Rough Terrain" + || parameter == "Natural Wonder" -> "tileFilter" RulesetCache.getBaseRuleset().units.containsKey(parameter) -> "unit" RulesetCache.getBaseRuleset().tileImprovements.containsKey(parameter) @@ -280,6 +281,10 @@ object TranslationFileWriter { } fun serializeElement(element: Any) { + if (element is String) { + submitString(element) + return + } val allFields = (element.javaClass.declaredFields + element.javaClass.fields + element.javaClass.superclass.declaredFields) // This is so the main PolicyBranch, which inherits from Policy, will recognize its Uniques and have them translated .filter { @@ -333,11 +338,14 @@ object TranslationFileWriter { private fun getJavaClassByName(name: String): Class { return when (name) { + "Beliefs" -> emptyArray().javaClass "Buildings" -> emptyArray().javaClass "Difficulties" -> emptyArray().javaClass + "Eras" -> emptyArray().javaClass "Nations" -> emptyArray().javaClass "Policies" -> emptyArray().javaClass "Quests" -> emptyArray().javaClass + "Religions" -> emptyArray().javaClass "Specialists" -> emptyArray().javaClass "Techs" -> emptyArray().javaClass "Terrains" -> emptyArray().javaClass