Overriding languages in library project - android

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?

Related

How Localazy and Phrase Android SDk updating stings declaired in strings.xml over the air

I am working on an application where it is required that I have to change.update string resources declared in my String.xml file over the air without uploading a new version on stores. (From server)
Currently, it is already implemented by Localazy and Phrase Android SDK.
The client wants to update anything declared in the String.xml and for every local.
I have to do it for multiple languages. I have already implemented localization. But the app still requires dynamic changes in the String resources,
As the author of this technology at Localazy, I can explain it pretty well.
How do we change strings.xml on the fly? We don't.
Our Gradle plugin adds a library to your app, performs bytecode analysis, and routes all the relevant method calls through our library. The library itself acts as a proxy, updates its internal strings database from our servers, and serves updated strings whenever possible. It also calculates anonymous stats about string usage, etc., to optimize the translation process on the Localazy site.
All of this happens during the build time without ever touching your source code and resources. It's completely transparent.
While it sounds like a simple task, it's much more complicated as it's impossible to route all method calls easily. E.g., LayoutInflater uses a different method for obtaining strings, and the same applies to Preferences, Menus, etc.
We also download and merge your strings.xml with the latest translations available on Localazy as the standard system method is always a reasonable fallback. We must correctly handle edge cases such as language aliases (iw vs. he), RTL languages, etc.
One of the biggest challenges was correctly supporting build types, product flavors, libraries, and dynamic app modules. It's not just about serving strings from the internal database but selecting the right one. E.g., a string with the same key from a library has lower priority than the app's one. The situation is different for dynamic app modules.
We've designed Localazy to handle all of these situations from the ground - the library, how we store strings on our servers, etc.
It's not a simple task to do this correctly, so better use the existing solution if possible.
Feel free to ask me if you need further help.

Disabling certain language translations on build

I have a project that depends on another library I made. Both have crowdsourced translations, which I update periodically. In most cases, I will only add translations per project when they are complete. However, it may be that one project has translations that another language does not. In this case, I'd like to strip that translation in the production app. Is there any way of doing that?

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 or Remove multiple language support in 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?

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.

Categories

Resources