From 32190b6cacee819036245b2a39d1068a0b0c10ac Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 29 Aug 2022 13:54:02 -0400 Subject: [PATCH] Fix choosing regionalized locales --- buildSrc/src/main/kotlin/LocalesConfigPlugin.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt b/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt index 8a51e32a69..b1e53fde90 100644 --- a/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt +++ b/buildSrc/src/main/kotlin/LocalesConfigPlugin.kt @@ -6,7 +6,7 @@ import org.gradle.kotlin.dsl.TaskContainerScope fun TaskContainerScope.registerLocalesConfigTask(project: Project): TaskProvider { return with(project) { register("generateLocalesConfig") { - val emptyResourcesElement = "\\s*<\\/resources>|".toRegex() + val emptyResourcesElement = "\\s*|".toRegex() val valuesPrefix = "values-?".toRegex() val languages = fileTree("$projectDir/src/main/res/") @@ -16,14 +16,16 @@ fun TaskContainerScope.registerLocalesConfigTask(project: Project): TaskProvider .filterNot { it.readText().contains(emptyResourcesElement) } + .map { it.parentFile.name } + .sorted() .joinToString(separator = "\n") { - val language = it.parentFile.name + val language = it .replace(valuesPrefix, "") + .replace("-r", "-") .takeIf(String::isNotBlank) ?: "en" " " } - val content = """