Android Gradle:如何从APK中排除现有翻译/语言环境?

时间:2019-03-14 14:34:35

标签: android gradle locale translation

我的Android应用目前contains 18 translations for 170 different strings的范围是6/170翻译到170/170翻译。

对于非英语应用程序的用户,如果实际上只有3%的字符串被真正翻译了,那么说该应用程序支持xx语言是没有意义的。

我的问题:是否可以告诉android-studio或gradle我不希望语​​言xx包含在最终apk中,而又不删除sourcetree中现有的翻译?

我想排除翻译率低于65%的语言

另请参见

1 个答案:

答案 0 :(得分:0)

我找到了一种方法来明确指出要支持的语言环境,因此我必须列出我认为足够完整的语言

// this does not include de=german so german is excluded from apk
android {
    defaultConfig {
        resConfigs "ar","es","fr","hi","in","it","ja","nl","pl","ro","ru","tr","uk","zz","pt-rBR","zh-rCN","zh-rTW"
    }

很遗憾,How to exclude certain files from Android Studio gradle builds?的答案无效:

// no error but german resources are not excluded :-(
android {
    sourceSets.main.res.filter.exclude '**/res/values-de/**'
}