Should now be able to read mod translations on Android - #2228
This commit is contained in:
parent
8ebbd881d0
commit
52612f4f32
3 changed files with 6 additions and 6 deletions
|
@ -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 = ""
|
||||
|
|
|
@ -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<String, String> {
|
||||
fun read(file: FileHandle): LinkedHashMap<String, String> {
|
||||
val translations = LinkedHashMap<String, String>()
|
||||
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
|
||||
|
|
|
@ -39,7 +39,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||
val languageTranslations:HashMap<String,String>
|
||||
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<String, TranslationEntry>(){
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue