Localization testing on Android - Change Application or System locale - android

I'm finally trying out some localization stuff on our application, and I've seem some posts regarding changing the application locale, and changing the System locale.
I've wondered if within the scope of our application, does it matters if I change the System locale or the application locale?

As far as I could notice, changing the application or the system Locale is not different with a side note that one would have to refresh the views.
I've wrote a post about my experience with Multi-Languages... leave your comments at the bottom.

Related

Android studio and localizing apps

I'm currently working on an app, which will be used (hopefully) by various tourist to my city. as such, i would like to complement as many languages as i can, and i have the appropriate translators to do so. I've read and started to implement the various different resources in the res folder, i already have some translated, i have a folder for each language as described in the guide from google.
How do I make the app initiate as non-English language in my phone while testing? for example Spanish. every time i run it, it's always English, and i would like to see that the app also works in the other languages, but i can't find anywhere how to initiate it.
I realize I might be simply overlooking something basic.
Thanks.
The language of the app is based on the system language. You need to change the language in Settings -> Language & input.
Change phone language from Settings->Language & input
If you use a physico-chimiques devices you have to change the languages of your device
If you use a emulator I think you can set the language on the creation.
If your tester have a android with spanish language, the app will be automatically on spanish. (if you create a filé string.xml in a values-es folder)

Change language of SwitchPreference

I have an Android app which is only available in English. Accordingly, all of the UI that's under my control appears in English only, regardless of what language the user has set their device to. The issue is with SwitchPreferences on my app's Settings screen; the "on"/"off" labels on the switches themselves are getting localized, presenting the user with a mixed-language UI.
See screenshot at https://drive.google.com/file/d/0B5ry4aCYVaqoUkFlZW9XT2VLVFE/view?usp=sharing
Is there any way to override the system localization of this element?
Notes:
I'm not that bothered about this myself, but the app is being rejected by Samsung's app store certification team on this basis. So I do need to fix it if possible.
Please don't respond by saying "localize your app so that there's not a mix". Apart from other localization issues (which are out of scope here), it just isn't possible for me to localize to all the langauges that the Android OS supports.
Thanks for the suggestions, Mark, but it turns out there's an easier way. I just added the following attributes to the SwitchPreference elements in the XML which defines my settings screen:
android:switchTextOff="OFF"
android:switchTextOn="ON"
Voila, the switch labels are un-localized. RTFM FTW! :^)

How to refresh all UIs on locale update for an Android app without restarting the app?

I need my app to have all UIs refreshed to use the new locale that the user just switches to without the need of restarting the app, is there a way to do it?
When I tested my app, for example, I was using English and now I change to use French, some UIs did get updated to display in French while some remains in English. Is there anything I could have been missing?
Thanks!
If locale is changed via device settings, then default behavior for activities is they are recreated/restarted by the system automatically, giving them a chance to use proper string resources (if an app has different string resouces for different locales, of course).
This is called Сonfiguration changes. Other types of config change would be device rotation, font size change, etc. But programmers can override the default behavior iether stating in AndroidManifest.xml what confic changes to bypass OR overriding Activity.onConfigurationChanged().
So, make sure (1) you have a dedicated string resources for each supported by your app locale and (2) you don't prevent the default on config change behaviour for this type of config change.

Android Forced Localization and App Icon/Label?

I have an unusual problem. I need to force-localize an app -- i.e., force it to load in a specific language, regardless of the phone's language setting.
What our client wants basically is to create language-specific builds of our app. We have all of the resources defined for different languages, and can therefore build an app that will automatically localize based on the phone's settings. But he also wants separate builds for specific languages. Before you say it: yes, I know that this is fighting against Android's Localization system. Yes, we did explain that and try to talk him out of it. But this is what he wants, so it's what we have to do.
I have found some good tutorials on doing this using Locale.setDefault() and the android:configChanges="locale" tag in the Manifest, and that seems to work just fine for setting the language inside Activities. But it has one shortcoming: it doesn't effect the app icon or the app label (i.e., what shows in the launcher), because those are retrieved from the Manifest at compile time.
So I'm trying to find the easiest way to handle this. I know if all else fails, I can write a Bash script that will just move the localized versions of those resources into the default directory before compiling. And if it comes to that, that's what I'll do. But I want to see first if there is a more elegant way that I'm overlooking.
Anyone have any suggestions?

Launch app with specific locale

Changing the locale for a device is done in the settings, and can't be done by an app AFAIK.
I know how to force my own app to a specific locale, described e.g. here:
http://www.tutorialforandroid.com/2009/01/force-localize-application-on-android.html
So now to my question. Can I force, programatically, the local of an activity that isn't mine?
I can imagine 2 ways this could be possible:
Specifying the locale in an Intent used to start the activity.
Access and manipulate the configuration of running activities (in the same way as I can modify my own activities' configurations).
Any thoughts? Is it possible? Is it reasonable?
I guess 2. would be more direct, but require some kind of permission (e.g. the modified atcitiy must allow it in the manifest file). But I'd settle for 1. or similar.
What I want is to be able to see certain apps in a different language, but rather not change the system locale. E.g. the Android Market, that only displays comments in one language. Can't think of other things right now.
Can't find much written on Locale in the documentation, what is and isn't possible. But hoping some undocumented feature might enable this :)
You can't unless the activity you are calling accepts a special locale parameter.
So, you can implement this with two of your own apps, or with the app of your friend, but there's no general way of doing this.
The only way I can imagine is to programatically change the locale of the whole device.
But I think you can only open up the preference screen and need the user to choose the correct locale before starting the app.

Categories

Resources