mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 02:34:39 +00:00
refactor: Modularize the project (#97)
* refactor: Modularize the project * chore: Move okhttp stuff back to androidMain OkHttp decided to cancel multiplatform plan on 5.0 REF: https://square.github.io/okhttp/changelogs/changelog/#version-500-alpha13 * feat: Start using moko for i18n * fix: Solve some errors * chore: Remove manga from domain module We'll do this later * fix: Duplicate error * fix: Conflict function name error * fix: Target SManga * fix: Breaking changes after the split * fix: Not enough heap memory * chore: Update proguard rules Sorta similar to upstream * refactor: Fix namespace
This commit is contained in:
parent
7e7a37bc53
commit
24ce2683d4
109 changed files with 1146 additions and 308 deletions
41
buildSrc/src/main/kotlin/LocalesConfigPlugin.kt
Normal file
41
buildSrc/src/main/kotlin/LocalesConfigPlugin.kt
Normal file
|
@ -0,0 +1,41 @@
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.kotlin.dsl.TaskContainerScope
|
||||
|
||||
fun TaskContainerScope.registerLocalesConfigTask(project: Project): TaskProvider<Task> {
|
||||
return with(project) {
|
||||
register("generateLocalesConfig") {
|
||||
val emptyResourcesElement = "<resources>\\s*</resources>|<resources/>".toRegex()
|
||||
val valuesPrefix = "values-?".toRegex()
|
||||
|
||||
val languages = fileTree("$projectDir/src/main/res/")
|
||||
.matching {
|
||||
include("**/strings.xml")
|
||||
}
|
||||
.filterNot {
|
||||
it.readText().contains(emptyResourcesElement)
|
||||
}
|
||||
.map { it.parentFile.name }
|
||||
.sorted()
|
||||
.joinToString(separator = "\n") {
|
||||
val language = it
|
||||
.replace(valuesPrefix, "")
|
||||
.replace("-r", "-")
|
||||
.takeIf(String::isNotBlank) ?: "en"
|
||||
" <locale android:name=\"$language\"/>"
|
||||
}
|
||||
|
||||
val content = """
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
$languages
|
||||
</locale-config>
|
||||
""".trimIndent()
|
||||
|
||||
val localeFile = file("$projectDir/src/main/res/xml/locales_config.xml")
|
||||
localeFile.parentFile.mkdirs()
|
||||
localeFile.writeText(content)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue