Change language of SwitchPreference - android

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! :^)

Related

Android change keyboard language programmatically

I'm building a single purpose app for one and only one device model. Therefore I allow switching languages within the app as I do not want the user to open the settings.
I was successful in changing the Locale.
I was unsuccessful switching the language input (understand switching the keyboard from thai to english and english to thai).
Note: It comes from factory with English and Thai language inputs already installed and available.
Note 2 : I've seen a load of solution on google but I find none of them precise enough to know if it's doable and how to perform this. I mention this because I'd like to avoid one more copy paste of this solution for eg : Change Keyboard Input Language Programmatically. It might be a good solution, but I just don't get it.

Android: Change Languages (string.xml) programmatically

In our Android app, we have an option for the user to change the language, which means he can select whether he want to use English or Sinhala. The default is always in English. We have one string.xml for English and another for Sinhala.
I was referring Android documents about "localization" but that is not exactly what I am looking for, I can't ask the user to change his phone settings. I also noticed programmatic localization which is discussed in here but most users do not recommend it due to loads of errors (anyway these posts are pretty old)
So, what's the best way of changing the String?XML file, with the preferred language of a user? It seems not easy on Android.
Or, is this is simply not a good idea?

Android automatic keyboard language depending on the person you are writing to

I often find myself writing to different people in different languages. Every time I have to switch to the correct language to avoid false auto-correction.
The language only depends on the person I am talking to, that is I will always talk in italian to a, b and c; in english to l and m; in french with x.
Is there a keyboard that keeps track of that, or a way to have it automatically configured when switching contacts?
No
And here is why: the User can set the keyboard in the settings for the phone. Also called input method editor (IME) by google.
As you can see in this developers guide, you can create your own IME.
But the problem is, you need to get the Contact data from the App that you are running (What's App, Telegram, Slack, etc), and unless they support that, what I very much doubt, you will not pull this off.
Maybe, quite hackish.
What might work is that the moment you open your custom IME, it takes a screenshot (not sure it could do that). Use that screenshot to parse out the Contact name. Try to match that with the Accounts on the phone. And use that to set the keyboard... But that is not a Keyboard I would like to have on my phone if it wasn't developed my me!

how to permanently override android soft keys behaviour and display through

I am relatively new to android and want to create an application that permanently overrides androids basic softkey behaviour and view (for devices with soft keys).
Some functionalities I want to implement are changing the size of the softkeys window at the bottom, change its images, and possibly change its functionality.
For example, the user can set the size to of the softkey to be "large", "medium" or "small". And I can change the functionality of the back button to open say a particular application instead of going "back".
I'm basically looking for a high level answer as to how to do this, a basic direction of what I should read/study in order to be able to accomplish this. I realise this may require root access.
Please note that I want this behaviour to change not only in my application but I want the effect to exist on all applications. If this requires the application to be running atleast at the backend, that is fine.
After doing some decent amount of search, it seems I will have to make changes in the systemUI.apk, or possibly get its source code and modify it. Is this correct?
Thanks in advance.
I don't think even root is going to be enough for the type of changes you are describing. You're going to need to edit the Android source code and build your own system image.
Well you can't override system resources because they are part of the system image.
What you are looking for is called Home Application which can be developed like any other android app no need for root , you can find an example for it in your sdk samples.
Home Sample Application.
your app would be responsible to have UI components to send the user to all of the phone functionalities which includes:
Place for wegits
Place for apps listing (menue)
Access telephony functionality (call, phone history ...)
Access settings.

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