mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-23 04:52:33 +01:00
Optimize generateLocales task
This commit is contained in:
@@ -13,13 +13,27 @@ fun TaskContainerScope.registerLocalizationTask(project: Project) {
|
|||||||
?.map { it.replace("-r", "-") }
|
?.map { it.replace("-r", "-") }
|
||||||
?.sorted()
|
?.sorted()
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
|
|
||||||
|
val langFile = file("src/commonMain/resources/MR/files/languages.json")
|
||||||
|
if (langFile.exists()) {
|
||||||
|
val currentLangs = langFile.reader().use {
|
||||||
|
Gson().fromJson(it, JsonObject::class.java)
|
||||||
|
.getAsJsonArray("langs")
|
||||||
|
.mapNotNull { it.asString }
|
||||||
|
.toSet()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLangs == langs.toSet()) return@doFirst
|
||||||
|
}
|
||||||
|
|
||||||
val json = JsonObject().apply {
|
val json = JsonObject().apply {
|
||||||
val array = JsonArray().apply {
|
val array = JsonArray().apply {
|
||||||
langs.forEach(::add)
|
langs.forEach(::add)
|
||||||
}
|
}
|
||||||
add("langs", array)
|
add("langs", array)
|
||||||
}
|
}
|
||||||
file("src/commonMain/resources/MR/files/languages.json").writer().use {
|
|
||||||
|
langFile.writer().use {
|
||||||
Gson().toJson(json, it)
|
Gson().toJson(json, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user