Is there any way to disable localization in an Android application? It must use only English strings. We have library projects with French localized strings. Some apps that use these libraries must be in English only, some not.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
2019 – Gradle-based approach
As pointed out by Nidhin in their answer, this is easier and less error prone now than it was in 2012. In the
defaultConfigsection of theandroidsection of yourbuild.gradlefile, you can setresConfigsto the single language you support. For example:This isn’t just for disabling localization—
resConfigssimply tells the build system which resources to keep. It can be set to a single language, or ideally to many, and it can be used to filter resources by something other than language, like screen density, as well. As such, saying “only include the English resources” effectively forces the app to always be in that language.The programmatic way of loading the resources for a specific language is still sometimes useful, so my 2012 answer is still provided:
2012 – Programmatic approach
Doing the following before calling
setContentView()or anything else that loads locale-specific resources should ensure that you always load only the English strings.