From 52612f4f3292e9b8e3c4334d5566ed32578a596d Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 25 Mar 2020 11:41:32 +0200 Subject: [PATCH] Should now be able to read mod translations on Android - #2228 --- core/src/com/unciv/models/metadata/GameSettings.kt | 1 - .../com/unciv/models/translations/TranslationFileReader.kt | 7 ++++--- core/src/com/unciv/models/translations/Translations.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt index e9b6f194..b8528b3a 100644 --- a/core/src/com/unciv/models/metadata/GameSettings.kt +++ b/core/src/com/unciv/models/metadata/GameSettings.kt @@ -24,7 +24,6 @@ class GameSettings { var showMinimap: Boolean = true var showPixelUnits: Boolean = false var showPixelImprovements: Boolean = true - var showPixelResources: Boolean = true var nuclearWeaponEnabled = true var continuousRendering = false var userId = "" diff --git a/core/src/com/unciv/models/translations/TranslationFileReader.kt b/core/src/com/unciv/models/translations/TranslationFileReader.kt index b9234e6b..c3960bfa 100644 --- a/core/src/com/unciv/models/translations/TranslationFileReader.kt +++ b/core/src/com/unciv/models/translations/TranslationFileReader.kt @@ -1,7 +1,9 @@ package com.unciv.models.translations import com.badlogic.gdx.Gdx +import com.badlogic.gdx.files.FileHandle import java.nio.charset.Charset +import java.util.logging.FileHandler import kotlin.collections.set object TranslationFileReader { @@ -9,10 +11,9 @@ object TranslationFileReader { const val percentagesFileLocation = "jsons/translations/completionPercentages.properties" val charset: String = Charset.forName("UTF-8").name() - fun read(translationFile: String): LinkedHashMap { + fun read(file: FileHandle): LinkedHashMap { val translations = LinkedHashMap() - val text = Gdx.files.internal(translationFile) - text.reader(charset).forEachLine { line -> + file.reader(charset).forEachLine { line -> if(!line.contains(" = ")) return@forEachLine val splitLine = line.split(" = ") if(splitLine[1]!="") { // the value is empty, this means this wasn't translated yet diff --git a/core/src/com/unciv/models/translations/Translations.kt b/core/src/com/unciv/models/translations/Translations.kt index 2ca04474..6c3014a2 100644 --- a/core/src/com/unciv/models/translations/Translations.kt +++ b/core/src/com/unciv/models/translations/Translations.kt @@ -39,7 +39,7 @@ class Translations : LinkedHashMap(){ val languageTranslations:HashMap try { // On some devices we get a weird UnsupportedEncodingException // which is super odd because everyone should support UTF-8 - languageTranslations = TranslationFileReader.read(translationFileName) + languageTranslations = TranslationFileReader.read(Gdx.files.internal(translationFileName)) }catch (ex:Exception){ return } @@ -48,7 +48,7 @@ class Translations : LinkedHashMap(){ for(modFolder in Gdx.files.local("mods").list()) { val modTranslationFile = modFolder.child(translationFileName) if (modTranslationFile.exists()) - languageTranslations.putAll(TranslationFileReader.read(modTranslationFile.path())) + languageTranslations.putAll(TranslationFileReader.read(modTranslationFile)) } for (translation in languageTranslations) {