From 755c3ac806ddd5922d19acda7e15e09bed1873f7 Mon Sep 17 00:00:00 2001 From: chrislo27 Date: Sun, 30 Jun 2019 10:40:24 -0700 Subject: [PATCH] Implement language refactorer --- .../chrislo27/rhre3/sfxdb/SFXDatabase.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/src/main/kotlin/io/github/chrislo27/rhre3/sfxdb/SFXDatabase.kt b/core/src/main/kotlin/io/github/chrislo27/rhre3/sfxdb/SFXDatabase.kt index 9e88b81f6..66b8d53b3 100644 --- a/core/src/main/kotlin/io/github/chrislo27/rhre3/sfxdb/SFXDatabase.kt +++ b/core/src/main/kotlin/io/github/chrislo27/rhre3/sfxdb/SFXDatabase.kt @@ -305,6 +305,30 @@ object SFXDatabase : Disposable { // Load favourites, recents, etc GameMetadata.initialize() + // language refactorer +// val outputFolder: File = RHRE3.RHRE3_FOLDER.child("out/").file() +// outputFolder.deleteRecursively() +// outputFolder.mkdir() +// // Detect all games with language suffixes +// gameList.sortedBy { it.id }.filter { !it.isCustom }.forEach { game -> +// for (lang in Language.VALUES) { +// if (game.id.endsWith(lang.code.capitalize())) { +// val gameFolder = outputFolder.resolve("${game.id}/") +// gameFolder.mkdir() +// gameFolder.resolve("data.json").apply { +// createNewFile() +// writeText(SFX_FOLDER.child("${game.id}/").file().resolve("data.json").readText().lines().toMutableList().also { +// it.add(4, """ "language": "${lang.code}",""") +// val nameIndex = it.indexOfFirst { it.trim().startsWith("\"name\"") } +// it[nameIndex] = it[nameIndex].replace(" (${lang.langName})", "") +// }.joinToString(separator="\n")) +// } +// Toolboks.LOGGER.debug("Wrote ${game.id} with correct language out") +// break +// } +// } +// } + if (RHRE3.verifySfxDb) { Toolboks.LOGGER.info("Checking SFX database for errors") val nanoStart = System.nanoTime()