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?
Related
i developed an app that contains a lot of activities and different application within the same app and they are all interconnected by sending different intents within it to function the whole app, however they still do different things and i can elimante one without hurting the other and causing the whole app to crash. so if i want i can divide them to be stand alone apps.
My question is this:
Can i have one app that download the basic activities and if a person want a specific activity they can download it (Eg: you download a game and that game includes a different set of levels that can be downloaded by pressing a button hence downloads that particular set of levels.)?
Forgive me if I misunderstood you, but are you talking about creating one big app that consists of many smaller apps, but rather than being all bundled in the beginning, a user can download each one as a module?
If it's this, it's not impossible, but not possible in the sense that I think you're hoping for.
Your one big app will still need all the necessary code and xml files because these need to exist when compiling. But what you can do, which is similar to what games do is to offer downloadable content that isn't code. Essentially, these are resources such as media files, text, or other data of the like.
Those data can be downloaded separately without affecting your app and it helps reduce the size of your app. However, the actual functionality of each individual app will still need to be within your app, but hidden until it's downloaded.
Typically, it's more common to just bundle it all together such as a Measurements app, or to have them as individual standalone apps such as Google Docs, Sheets, and Slides.
You're basically describing how a browser/website works.
If you really wanted to wrap this up as a mobile app, you could use webviews.
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?
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 have a business requirement, and after lot of googling came to a point that android (as compared to iPhone) would be the platform to go for
I have a requirement wherein lets say an App 'X' that comes built-in with OS (firmware) needs to be replaced with some App 'Y'.
Of course, i understand that there would be something that i would need to change at firmware level (correct me), and of course i have no idea how to do that
So, is such a kind of thing even possible ?
Any links where i could look for more.
Yogurt
As long as your app provides the same functionality and it reacts on all intents, you could just delete the native apk from system/app and put your own apk there.
We had a very similar project in the past. The solution was to install our app in addition to the "native" one and to catch and process all input (notifications, broadcasts, etc) in our application. It also might be possible to prevent native application from reacting to those inputs.
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.