1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2025-09-09 18:29:47 +02:00

Make use of opoc/LanguagePreference (fixes #169)

This commit is contained in:
Gregor Santner 2017-09-15 19:56:10 +02:00
parent 4ba1b8671d
commit 184de1931e
No known key found for this signature in database
GPG key ID: 7E83A7834AECB009
3 changed files with 38 additions and 17 deletions

View file

@ -32,6 +32,7 @@ android {
buildConfigField "boolean", "IS_TEST_BUILD", "false"
buildConfigField "boolean", "IS_GPLAY_BUILD", "false"
buildConfigField("String[]", "APPLICATION_LANGUAGES", '{' + getUsedAndroidLanguages().collect {"\"${it}\""}.join(",") + '}')
vectorDrawables.useSupportLibrary = true
}
@ -92,6 +93,23 @@ dependencies {
annotationProcessor "com.jakewharton:butterknife-compiler:${version_lib.butterknife}"
}
@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection"])
static String[] getUsedAndroidLanguages() {
Set<String> langs = new HashSet<>()
new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
final foldername = it.name
if (foldername.startsWith('values-') && !it.canonicalPath.contains("build" + File.separator + "intermediates")) {
new File(it.toString()).eachFileRecurse(groovy.io.FileType.FILES) {
if (it.name.toLowerCase().endsWith(".xml") && it.getCanonicalFile().getText('UTF-8').contains("<string")) {
langs.add(foldername.replace("values-", ""))
}
}
}
}
return langs.toArray(new String[langs.size()])
}
// #####################
// Groovy Coding Area
// #####################