I’m working on an update to Idea Growr that gives users the option to set the language of the app. At first just the option to either ‘use device language’ or ‘English’.
How language works in Android
If you develop an Android app you use folders like values-fr for all your French texts, and values-pt for Portuguese, etc. When a user opens the app, Android looks at the language that is set at the device level and it will pick that same language for your app.
You might think it would be easy to give users control over the language in the app, since the folder structure is already there. But it’s harder than you would expect:
- You can change something that is called ‘locale’. But that sort of tricks Android into thinking that there is a different device language. This makes it rather hard to later on enable the radio button for ‘use the device language’. In the comments of this Stack Overflow question you see a whole range of options. Taking fully different approaches.
- But these and other solutions you find online might be from 2012, and since then new Android versions make that those solutions no longer (fully) work.
- Then when you think you get it to work, strange things happen, like action bar titles that won’t change immediately but sometimes later on. Again a Stack Overflow question shows I’m not the only one with this problem.
So now I’m at the point that I try all sort of different things people are saying in the comments of Stack Overflow questions. I have the feeling that many developers would say that this is part of the process of software development, but what I find troubling about this is that I’m not learning anything.
I want to become a better developer, but at the moment I think that I actually could not have known how to do this with a better process or general software development skills. It’s just that Android assumes that users want apps to have the same language as their device. While I’m not holding my breath, I added a request for the Android team for an easy way to let users select the language of their apps.