forked from libre-tube/LibreTube
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
43 lines (38 loc) · 1.56 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
43 lines (38 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
plugins {
alias(libs.plugins.androidTest) apply false
alias(libs.plugins.baselineprofile) apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidx.navigation.safeargs) apply false
alias(libs.plugins.kotlin.serialization) apply false
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
// this builds the list of languages to use for Android versions below 13
tasks.register("buildLanguages") {
val projectDirectory = layout.projectDirectory
// reference: https://docs.gradle.org/current/userguide/working_with_files.html
val resPath = projectDirectory.file("app/src/main/res")
val locales = resPath.asFile.listFiles()
.filter {
it.nameWithoutExtension.startsWith("values-") && File(
it,
"strings.xml"
).exists()
}
.map {
it.nameWithoutExtension.removePrefix("values-")
} + "en" // en is the default locale, its values file has no -en suffix
val localesConfig =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<resources>\n" +
"<string-array name=\"languageCodes\">\n" +
locales.joinToString("\n") { " <item>$it</item>" } + "\n" +
"</string-array>\n" +
"</resources>"
val outputFile = projectDirectory.file("app/src/main/res/values/languages.xml").asFile
if (!outputFile.exists()) outputFile.createNewFile()
outputFile.bufferedWriter().use {
it.write(localesConfig)
}
}