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"
" "
}