From 290efb0283145d81290972991047064c1d905c9c Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 24 Mar 2023 22:58:29 -0400 Subject: [PATCH] Fix Spanish (Latin America) being missing from in-app language selection --- buildSrc/src/main/kotlin/LocalesConfigPlugin.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt b/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt index b1e53fde90..2c352f1319 100644 --- a/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt +++ b/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt @@ -3,25 +3,22 @@ import org.gradle.api.Task import org.gradle.api.tasks.TaskProvider import org.gradle.kotlin.dsl.TaskContainerScope +private val emptyResourcesElement = "\\s*|".toRegex() +private val valuesPrefix = "values(-(b\\+)?)?".toRegex() + fun TaskContainerScope.registerLocalesConfigTask(project: Project): TaskProvider { return with(project) { register("generateLocalesConfig") { - val emptyResourcesElement = "\\s*|".toRegex() - val valuesPrefix = "values-?".toRegex() - val languages = fileTree("$projectDir/src/main/res/") - .matching { - include("**/strings.xml") - } - .filterNot { - it.readText().contains(emptyResourcesElement) - } + .matching { include("**/strings.xml") } + .filterNot { it.readText().contains(emptyResourcesElement) } .map { it.parentFile.name } .sorted() .joinToString(separator = "\n") { val language = it .replace(valuesPrefix, "") .replace("-r", "-") + .replace("+", "-") .takeIf(String::isNotBlank) ?: "en" " " }