Add or Remove multiple language support in Android - android

Suppose app provides multi-language support for example English and French.
And it has 2 different folders for string.xml as per standard android guidelines to support different language.
res/values/strings.xml
res/values-fr/strings.xml
Can I exclude any specific XML (for example in this case, values-fr) folder from App build? Meaning when an APK of this app is generated, it should not contain support for values-fr. Also, later, if I need to add the same, where to make the change to include values-fr?
What build properties app needs to configure to support this "dynamic" add/remove of multi-language support?

Related

Pre-built localization strings for multiple languages

It is a tedious task to localize app's for multiple languages, and very often the same work is done over and over again:
For example, phrases like "OK", "Cancel" are in almost every android app.
Localization of mobile apps - Any resources available for the basics?
This question is 3 years old, I wonder if anything changed since then.
Are there any comprehensive libraries/collections which take care of this? So that I only have to translate the actually app-specific strings?
I would suggest using the Google Translator Toolkit. It supports the various localization files. It also has support for iOS and Android localization files.
Example: For Android you can upload your strings.xml you can select to which files you want to get it translated. It is automatically translated by Google Translate. It uses different colors to display how sure Google Translate is about the translation, and gives feedback about things that needs to be changed in the translations.
You can also use a translation memory. This is a database with saved translations. You can create a personal Translation memory. This contains all the translations you made. You can also use the global TM.
The global TM saves and stores translations from Translator Toolkit users everywhere. Please note that the global TM is available for anyone to see and use.
You read more about it on the support page
It has an editor build in which allows you to change the automatically translated words/sentences. You can export the translations as strings.xml again, so you can use them straightaway in your Android project.
A disadvantage: I don't think it is possible to switch between localization formats, so you have to translate all sentences for both the iOS and Android version.
You can read more about it on the support page

Add a new language in android without republishing the app

I know how develop a multilingual app in Android.
The following link explains how to do so.
http://developer.android.com/guide/topics/resources/localization.html
Assume that I release to the market my app in 3 different languages developed with the best practices described in the link above in mind.
If I want to add a new language I have to republish a new version. Is there a good way to avoid republishing the app if I add more languages?
It is important that the application detects the correct language according to the language of the smartphone.
If you are using the standard localization framework then the answer is no, because all the localization files are looked up in the res folder at runtime. And to update the res folder, you need to update the apk.
The only possible way to do what you want is by coding your own localization framework, which, intuitively, should not be too hard. (Your have a function that searches for a string in a file, and the file is determined by the language). The bad thing is that you would need to set all the strings on your user interface objects programmatically.

Overriding languages in library project

I have a library project that defines the basic structure of an app. I then have several apps based on this library project. To put things in perspective, the library project has about 300 classes (activities, services, data model representation, etc.) Individual apps have about 2-3 classes each, essentially the main activity plus a bit of code customising whatever the library project creates.
The library project contains string resources in several languages (English, Russian, and French at present, but will be extended as translations are ready). The actual apps based on this library project may not require all of these translations. So, is there any way to disable specific languages in the library project from the main app project?
To give a simple example, the library project has English as the main language and also contains resources for Russian and French. The application must always be presented in English (client's requirement). Naturally, I define the application specific resources in English only, but whenever strings from the library project are used, they do come in Russian or French when the device locale is set to one of them. I need to somehow, from the main app, indicate that I only want to use English resources, regardless of the device locale. Is there a way to do this? If yes, how?

Localization for Android Library application

I am developing the library application, which is reused in many android applications. Now, I need to add the localization capability to my android library application.
http://developer.android.com/guide/topics/resources/localization.html
In the above link, localization deals with the resources. If I am using the resources in the library project tends to have the same resources in the referenced android application also. Is there any other way to achieve the localization in android library project.?
Yes you can add localization into your library project like a Standart Android project:
values-en,values-ru,values-uk and etc.
Yes you just need to provide alternative sources as mentioned in Providing alternative resources
So say for string file you can provider string files for different languages and device will choose which file to use according to device configuration.

Same project but customised and installable alongside each other?

I have a small Android project that I use as a core project. From this core project I want to be able to do customisations.
So I have the app in a framework format using standard icons, buttons etc... I want to be able to create different versions with different icons and buttons.
This I know how to do. (I will have two separate apk files, both with the same code but with different resources)
However I want to be able to install the core project and a customisation on the same device at the same time. Currently one will overwrite the other.
I have tried to change the package in the manifest but this in turn means I would have to also change all the imports for R.java in my Java files, this is something I want to avoid.
Is it possible to change just something in xml that will allow me to have two projects using the same Java files but with different resources?
You should use Android Libraries.
Put all your application code into one Android Library and then create two Android Applications which have custom icons and different package names. The resources defined in final Android Applications will override all already existing resources in Android Library.
One drawback: you'll need to have to almost identical copies of AndroidManifest.xml files in your Android Application (but they still should have different package names).
For more info:
Android's documentation: Settings up Android Library project
My post: Android Application, Android Libraries and Jar Libraries. This one describes how Android Libraries work.
You should create a library project that contains all of your source code, and create a project for each of your installable packages that references the library project. You can then define/override any resource definitions in the installable projects

Categories

Resources