Merge branch '1160-language-setting' into 'master'

Add language setting

Closes #1160 and #1222

See merge request akwizgran/briar!679
This commit is contained in:
akwizgran
2018-06-08 11:20:39 +00:00
13 changed files with 308 additions and 19 deletions

View File

@@ -285,3 +285,46 @@ android {
warning 'ExtraTranslation'
}
}
task verifyTranslations {
doLast {
def file = "briar-android/src/main/res/values/arrays.xml"
def arrays = new XmlParser().parse(file)
def lc = arrays.children().find { it.@name == "pref_language_values" }
def translations = []
lc.children().each { value -> translations.add(value.text()) }
def folders = ["default", "en-US"]
new File("briar-android/src/main/res").eachDir { dir ->
if (dir.name.startsWith("values-") && !dir.name.endsWith("night")) {
folders.add(dir.name.substring(7).replace("-r", "-"))
}
}
folders.each { n ->
if (!translations.remove(n) && n != 'iw') {
throw new GradleException("Translation " + n + " is missing in $file")
}
}
if (translations.size() != 0)
throw new GradleException("Translations\n" + translations.join("\n")
+ "\nhave no matching value folder")
// Some devices use iw instead of he for hebrew
def hebrew_legacy = new File("briar-android/src/main/res/values-iw")
def hebrew = new File("briar-android/src/main/res/values-he")
// Copy values-he to values-iw
if (hebrew.exists()) {
hebrew_legacy.mkdir()
copy {
from 'src/main/res/values-he'
into 'src/main/res/values-iw'
}
}
}
}
project.afterEvaluate {
preBuild.dependsOn.add(verifyTranslations)
}