Avoid Android Lint complains about not-translated string

后端 未结 11 1650
轻奢々
轻奢々 2020-12-02 13:06

is it possible to specify that the strings in a file within the value-* directories are purposely not translated into other languages? I have a bunch of strings

11条回答
  •  Happy的楠姐
    2020-12-02 13:16

    Another way to do that is add your string to gradle file, using resValue or buildConfigField. Something like that:

    buildTypes {
        debug {
            buildConfigField "string", "app_name1", "App Name"
            resValue "string", "app_name2", "App Name"
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "string", "app_name1", "App Name"
            resValue "string", "app_name2", "App Name"
        }
    }
    

    Usages:

    // buildConfigField
    BuildConfig.APP_NAME1
    
    // resValue
    getString(R.string.app_name2)
    

提交回复
热议问题