mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Never forget to add a language again, auto generation of the language list
This commit is contained in:
@@ -11,7 +11,7 @@ plugins {
|
|||||||
kotlin("jvm") version "1.5.21"
|
kotlin("jvm") version "1.5.21"
|
||||||
kotlin("kapt") version "1.5.21"
|
kotlin("kapt") version "1.5.21"
|
||||||
kotlin("plugin.serialization") version "1.5.21"
|
kotlin("plugin.serialization") version "1.5.21"
|
||||||
id("org.jetbrains.compose") version "1.0.0-alpha4-build310"
|
id("org.jetbrains.compose") version "1.0.0-alpha4-build315"
|
||||||
id("com.github.gmazzo.buildconfig") version "3.0.2"
|
id("com.github.gmazzo.buildconfig") version "3.0.2"
|
||||||
id("org.jmailen.kotlinter") version "3.5.0"
|
id("org.jmailen.kotlinter") version "3.5.0"
|
||||||
id("com.github.ben-manes.versions") version "0.39.0"
|
id("com.github.ben-manes.versions") version "0.39.0"
|
||||||
@@ -135,6 +135,22 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerTachideskTasks(project)
|
registerTachideskTasks(project)
|
||||||
|
|
||||||
|
task("generateResourceConstants") {
|
||||||
|
val buildResources = buildConfig.forClass(project.group.toString(), "BuildResources")
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
val langs = listOf("en") + sourceSets["main"].resources
|
||||||
|
.filter { it.name == "strings.xml" }
|
||||||
|
.drop(1)
|
||||||
|
.map { it.absolutePath.substringAfter("values-").substringBefore(File.separatorChar) }
|
||||||
|
buildResources.buildConfigField("Array<String>", "LANGUAGES", langs.joinToString(prefix = "arrayOf(", postfix = ")") { it.wrap() })
|
||||||
|
}
|
||||||
|
|
||||||
|
generateBuildConfig {
|
||||||
|
dependsOn(this@task)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import ca.gosyer.BuildResources
|
||||||
import ca.gosyer.data.ui.UiPreferences
|
import ca.gosyer.data.ui.UiPreferences
|
||||||
import ca.gosyer.data.ui.model.StartScreen
|
import ca.gosyer.data.ui.model.StartScreen
|
||||||
import ca.gosyer.ui.base.components.Toolbar
|
import ca.gosyer.ui.base.components.Toolbar
|
||||||
@@ -47,17 +48,13 @@ class SettingsGeneralViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun getLanguageChoices(): Map<String, String> = mapOf(
|
fun getLanguageChoices(): Map<String, String> = (
|
||||||
"" to stringResource("language_system_default", currentLocale.getDisplayName(currentLocale))
|
mapOf(
|
||||||
) + listOf(
|
"" to stringResource("language_system_default", currentLocale.getDisplayName(currentLocale))
|
||||||
"en",
|
) + BuildResources.LANGUAGES
|
||||||
"en-CA",
|
.associateWith { Locale.forLanguageTag(it).getDisplayName(currentLocale) }
|
||||||
"fa",
|
)
|
||||||
"hi",
|
.toSortedMap(compareBy { it.lowercase() })
|
||||||
"pt-BR",
|
|
||||||
"sv",
|
|
||||||
"tam"
|
|
||||||
).associateWith { Locale.forLanguageTag(it).getDisplayName(currentLocale) }
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun getDateChoices(): Map<String, String> {
|
fun getDateChoices(): Map<String, String> {
|
||||||
|
|||||||
Reference in New Issue
Block a user