New languages (#318)
* Added Hindi language support * Added Simplified Chinese support and implemented search in language selection dialog * Added support for Italian, Polish, Vietnamese, and Brazilian Portuguese languages * Added Belarusian language support and fixed activity recreation on locale change
This commit is contained in:
parent
056485a140
commit
70c272baa7
26 changed files with 7931 additions and 301 deletions
|
|
@ -1,7 +1,9 @@
|
|||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
import java.util.Properties
|
||||
import java.io.StringReader
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import org.xml.sax.InputSource
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
|
|
@ -20,12 +22,15 @@ if (localPropertiesFile.exists()) {
|
|||
}
|
||||
|
||||
fun configuredAppLocaleTags(): Set<String> {
|
||||
val localesConfig = file("src/main/res/xml/locales_config.xml")
|
||||
val localesConfigXml = providers
|
||||
.fileContents(layout.projectDirectory.file("src/main/res/xml/locales_config.xml"))
|
||||
.asText
|
||||
.get()
|
||||
val androidNamespace = "http://schemas.android.com/apk/res/android"
|
||||
val document = DocumentBuilderFactory.newInstance()
|
||||
.apply { isNamespaceAware = true }
|
||||
.newDocumentBuilder()
|
||||
.parse(localesConfig)
|
||||
.parse(InputSource(StringReader(localesConfigXml)))
|
||||
val localeNodes = document.getElementsByTagName("locale")
|
||||
|
||||
return buildSet {
|
||||
|
|
@ -56,6 +61,7 @@ android {
|
|||
versionName = "1.0.47"
|
||||
|
||||
resourceConfigurations += configuredAppLocaleTags()
|
||||
.map { it.toAndroidResourceConfiguration() }
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
externalNativeBuild {
|
||||
|
|
@ -174,6 +180,15 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
fun String.toAndroidResourceConfiguration(): String {
|
||||
val languageTagParts = split("-")
|
||||
return if (languageTagParts.size == 2 && languageTagParts[1].length == 2) {
|
||||
"${languageTagParts[0]}-r${languageTagParts[1].uppercase()}"
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
kover {
|
||||
reports {
|
||||
filters {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue