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?
Related
I have an app which gives a feature to choose the language in which only the reports will be generated. Is there any way in which I can achieve this. I don't want to use the localization feature because it will then translate my whole app.
Sorry If I am not clear enough.
In my app I have a feature through which certain reports (I have used fragments as there are 5+ pages) are generated.
Mainactivity has an option to set the language for reports.
Now when the language is selected only the reports need to be translated to the selected language.
I tried the strings.xml approach but then it translates the entire app which is not what I want.
From what I understand, you want to prevent a string from being translated. Do this, declare the string in the strings.xml file and then set translatable to "false" for that particular string.
I'm working on an app that needs to support a large number of languages. Instead of bundling all languages in the app resources, I want to be able to download the language when the user selects a new language from the settings menu.
The Facebook mobile app does this very well. If you are logged in, go to settings> languages > switch language > pick a different language.
I think Facebook are downloading these language resources, Because if i put my phone into airplane mode , it doesn't work ( prompted with try again, or use english as default).
Since the app resources can't be edited at runtime, i'm guessing Facebook are using a database to download the language , then load the translations from there?!
p.s i'm actually trying to do this in Xamarin...trying to understand the Facebook Android approach so I can implement it myself.
I don't know specifically about Facebook, but I know this technique is in use by some people -- I've seen presentations on similar setups from other companies. There are a couple of obvious benefits:
Reduce overall app size by not bundling 30 languages worth of strings.
The ability to improve localized strings without forcing the user to download an app update.
Better data about what languages your users are using.
When I've seen in presented (again, this was not Facebook specifically), it worked much as you suggested -- user selects the preferred language, app fetches a string bundle from the server, then starts using it. Once the language is set, the app can even periodically refresh the localized string bundle to get updates.
However, there are some downsides to be aware of, especially if the localized strings change over time. It can make support tricky -- if a string has changed, a button (for example) might be called different things depending on exactly when the user was using the app. It also will really put pressure on your i18n strategy and QA to make sure the UI looks decent with strings that might be changing frequently.
If you download localization files you will not be able to use the default localization support within Android.
If you do go ahead with this strategy (downloading of localization files), you will need to create your own class to manage this or alternatively, search for a library which does this for you.
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)
I am trying to make small app for android. My idea for app is that user can change the language whichever they want ...etc french , german,chinese , english etc...
how to force the locale language in my app or how to get access to the language used by user on their device and with respect to that I can change my application language.
THank you,
For this you may need to make use of Localization.
Please go through the following example available at the developer site.
May be this can solve your issue.
http://developer.android.com/resources/tutorials/localization/index.html
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.