Added Civilopedia texts to translation file

This commit is contained in:
Yair Morgenstern 2019-03-04 21:32:18 +02:00
parent 1048489ff2
commit efe677d27c
4 changed files with 44 additions and 28 deletions

View file

@ -7674,4 +7674,19 @@
"Wolfpack III":{
Italian:"Attacco in massa III"
}
}
// Civilopedia texts
"Basics":{}
"Resources":{}
"Terrains":{}
"Tile improvements":{}
"Unique to [civName], replaces [unitName]":{}
"Requires [buildingName] to be built in the city":{}
"Requires [buildingName] to be built in all cities":{}
"Provides a free [buildingName] in the city":{}
"Requires worked [resource] near city":{}
"Required tech: [requiredTech]":{}
"Upgrades to [upgradedUnit]":{}
"Obsolete with [obsoleteTech]":{}
}

View file

@ -61,7 +61,7 @@ class Building : NamedStats(), IConstruction{
infoList += improvedResources.joinToString()+ " {provide} ".tr()+ resourceBonusStats.toString()
}
if(requiredNearbyImprovedResources!=null)
infoList += "requires worked "+requiredNearbyImprovedResources!!.joinToString("/")+" near city"
infoList += ("Requires worked ["+requiredNearbyImprovedResources!!.joinToString("/"){it.tr()}+"] near city").tr()
if(uniques.isNotEmpty()) infoList += uniques.joinToString { it.tr() }
if(cityStrength!=0) infoList+="{City strength} +".tr()+cityStrength
if(cityHealth!=0) infoList+="{City health} +".tr()+cityHealth
@ -72,17 +72,17 @@ class Building : NamedStats(), IConstruction{
fun getDescription(forBuildingPickerScreen: Boolean, adoptedPolicies: HashSet<String>): String {
val stats = getStats(adoptedPolicies)
val stringBuilder = StringBuilder()
if(uniqueTo!=null) stringBuilder.appendln("Unique to $uniqueTo, replaces $replaces")
if(uniqueTo!=null) stringBuilder.appendln("Unique to [$uniqueTo], replaces [$replaces]".tr())
if (!forBuildingPickerScreen) stringBuilder.appendln("{Cost}: $cost".tr())
if (isWonder) stringBuilder.appendln("Wonder".tr())
if (!forBuildingPickerScreen && requiredTech != null)
stringBuilder.appendln("Requires {$requiredTech} to be researched".tr())
stringBuilder.appendln("Required tech: [$requiredTech]".tr())
if (!forBuildingPickerScreen && requiredBuilding != null)
stringBuilder.appendln("Requires a $requiredBuilding to be built in this city")
stringBuilder.appendln("Requires [$requiredBuilding] to be built in the city".tr())
if (!forBuildingPickerScreen && requiredBuildingInAllCities != null)
stringBuilder.appendln("Requires a $requiredBuildingInAllCities to be built in all cities")
stringBuilder.appendln("Requires [$requiredBuildingInAllCities] to be built in all cities".tr())
if (providesFreeBuilding != null)
stringBuilder.appendln("Provides a free $providesFreeBuilding in this city")
stringBuilder.appendln("Provides a free [$providesFreeBuilding] in the city".tr())
if(uniques.isNotEmpty()) stringBuilder.appendln(uniques.asSequence().map { it.tr() }.joinToString("\n"))
if (stats.toString() != "")
stringBuilder.appendln(stats)
@ -95,10 +95,10 @@ class Building : NamedStats(), IConstruction{
}
if (this.greatPersonPoints != null) {
val gpp = this.greatPersonPoints!!
if (gpp.production != 0f) stringBuilder.appendln("+" + gpp.production.toInt() + " Great Engineer points")
if (gpp.gold != 0f) stringBuilder.appendln("+" + gpp.gold.toInt() + " Great Merchant points")
if (gpp.science != 0f) stringBuilder.appendln("+" + gpp.science.toInt() + " Great Scientist points")
if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " Great Artist points")
if (gpp.production != 0f) stringBuilder.appendln("+" + gpp.production.toInt()+" " + "[Great Engineer] points".tr())
if (gpp.gold != 0f) stringBuilder.appendln("+" + gpp.gold.toInt() + " "+"[Great Merchant] points".tr())
if (gpp.science != 0f) stringBuilder.appendln("+" + gpp.science.toInt() + " "+"[Great Scientist] points".tr())
if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr())
}
if (resourceBonusStats != null) {
val resources = GameBasics.TileResources.values.filter { name == it.building }.joinToString { it.name.tr() }
@ -106,7 +106,7 @@ class Building : NamedStats(), IConstruction{
}
if(requiredNearbyImprovedResources!=null)
stringBuilder.appendln("Requires worked "+requiredNearbyImprovedResources!!.joinToString("/")+" near city")
stringBuilder.appendln(("Requires worked ["+requiredNearbyImprovedResources!!.joinToString("/"){it.tr()}+"] near city").tr())
if(cityStrength!=0) stringBuilder.appendln("{City strength} +".tr() + cityStrength)
if(cityHealth!=0) stringBuilder.appendln("{City health} +".tr() + cityHealth)

View file

@ -56,14 +56,14 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
fun getDescription(forPickerScreen:Boolean): String {
val sb = StringBuilder()
if(requiredResource!=null) sb.appendln("Requires {$requiredResource}".tr())
if(requiredResource!=null) sb.appendln("{Requires} {$requiredResource}".tr())
if(!forPickerScreen) {
if(uniqueTo!=null) sb.appendln("Unique to $uniqueTo, replaces $replaces")
if (unbuildable) sb.appendln("Unbuildable".tr())
else sb.appendln("Cost: $cost")
if(requiredTech!=null) sb.appendln("Required tech: {$requiredTech}".tr())
if(upgradesTo!=null) sb.appendln("Upgrades to $upgradesTo")
if(obsoleteTech!=null) sb.appendln("Obsolete with $obsoleteTech")
if(requiredTech!=null) sb.appendln("Required tech: [$requiredTech]".tr())
if(upgradesTo!=null) sb.appendln("Upgrades to [$upgradesTo]".tr())
if(obsoleteTech!=null) sb.appendln("Obsolete with [$obsoleteTech]".tr())
}
if(strength!=0){
sb.append("{Strength} $strength".tr())

View file

@ -9,6 +9,7 @@ import com.unciv.UnCivGame
import com.unciv.models.gamebasics.BasicHelp
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.ICivilopedia
import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel
@ -29,26 +30,26 @@ class CivilopediaScreen : CameraStageBaseScreen() {
val label = "".toLabel()
label.setWrap(true)
val goToGameButton = TextButton("Return \r\nto game", CameraStageBaseScreen.skin)
val goToGameButton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
goToGameButton.onClick {
game.setWorldScreen()
dispose()
}
buttonTable.add(goToGameButton)
val map = LinkedHashMap<String, Collection<ICivilopedia>>()
val categoryToInfos = LinkedHashMap<String, Collection<ICivilopedia>>()
val language = UnCivGame.Current.settings.language.replace(" ","_")
val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp_$language.json").exists())"BasicHelp_$language"
else "BasicHelp"
map["Basics"] = GameBasics.getFromJson(kotlin.Array<BasicHelp>::class.java, basicHelpFileName).toList()
map["Buildings"] = GameBasics.Buildings.values
map["Resources"] = GameBasics.TileResources.values
map["Terrains"] = GameBasics.Terrains.values
map["Tile Improvements"] = GameBasics.TileImprovements.values
map["Units"] = GameBasics.Units.values
map["Technologies"] = GameBasics.Technologies.values
categoryToInfos["Basics"] = GameBasics.getFromJson(kotlin.Array<BasicHelp>::class.java, basicHelpFileName).toList()
categoryToInfos["Buildings"] = GameBasics.Buildings.values
categoryToInfos["Resources"] = GameBasics.TileResources.values
categoryToInfos["Terrains"] = GameBasics.Terrains.values
categoryToInfos["Tile Improvements"] = GameBasics.TileImprovements.values
categoryToInfos["Units"] = GameBasics.Units.values
categoryToInfos["Technologies"] = GameBasics.Technologies.values
val nameList = List<ICivilopedia>(CameraStageBaseScreen.skin)
@ -62,14 +63,14 @@ class CivilopediaScreen : CameraStageBaseScreen() {
val buttons = ArrayList<Button>()
var first = true
for (str in map.keys) {
val button = TextButton(str, CameraStageBaseScreen.skin)
for (str in categoryToInfos.keys) {
val button = TextButton(str.tr(), CameraStageBaseScreen.skin)
button.style = TextButton.TextButtonStyle(button.style)
button.style.checkedFontColor = Color.BLACK
buttons.add(button)
val buttonClicked = {
val newArray = Array<ICivilopedia>()
for (civilopediaEntry in map[str]!!.sortedBy { it.toString() }) // Alphabetical order
for (civilopediaEntry in categoryToInfos[str]!!.sortedBy { it.toString() }) // Alphabetical order
newArray.add(civilopediaEntry)
nameList.setItems(newArray)
nameList.selected = nameList.items.get(0)