Set translated languages in application - android

The default language of my app is English and I translated it into German. But now if I want to export it as an signed application in Eclipse there comes many errors that all string are not translated in other languages like es, fr , it and so on.
How can I export my app as signed application with only two languages and ignore all other languages?

You don't need to translate your app if you don't want to. Just check that all strings are defined in the base values/ folder. Then you can create more values-XX/ folders with their own strings.xml with all of the strings (or just a fraction of them). Android will take the default string if it doesn't find the localised version of the string.
If you are not localising to other languages, make sure that their values folder are not defined. For example, if you are not localising to Spanish, make sure that you don't have the values-es/ folder in your res/ folder.
EDIT: Same topic solved: Lint: How to ignore "<key> is not translated in <language>" errors?

Related

Android app language localization

I have developed an app. Now I want to support other regional languages in it. But now the app is almost ready, changing each java file to set the texts in the textview for the corresponding language is a big pain. Is there any other simple way to do that? Like making a different string.xml file and doing some stuff, then all the views will get changed???
Create alternative resources
A large part of localizing an app is providing alternative text for different languages. In some cases you also provide alternative graphics, sounds, layouts, and other locale-specific resources.
An app can specify many res// directories, each with different qualifiers. To create an alternative resource for a different locale, you use a qualifier that specifies a language or a language-region combination. (The name of a resource directory must conform to the naming scheme described in Providing Alternative Resources, or else your app cannot compile.)
Example:
Suppose that your app's default language is English. Suppose also that you want to localize all the text in your app to French, and most of the text in your app (everything except the app's title) to Japanese. In this case, you could create three alternative strings.xml files, each stored in a locale-specific resource directory:
res/values/strings.xml Contains English text for all the strings
that the app uses, including text for a string named title.
res/values-fr/strings.xml Contain French text for all the strings,
including title.
res/values-ja/strings.xml Contain Japanese text for
all the strings except title.
If your Java-based code refers to R.string.title, here is what happens at runtime:
If the device is set to any language other than French, Android loads title from the res/values/strings.xml file.
If the device is set to French, Android loads title from the res/values-fr/strings.xml file.
Notice that if the device is set to Japanese, Android looks for title in the res/values-ja/strings.xml file. But because no such string is included in that file, Android falls back to the default, and loads title in English from the res/values/strings.xml file.
If you properly used resource references (like R.string.hello) You can create another language configuration and it should be properly loaded. If you "hard coded" strings within JAVA code with literals like "hello world" You have quite a bit of refactoring to do.

Android Localization structure of values folder

I`m still learning android development and come with one app which I want to localize to multiple languages.
But please help me a little bit with values folder structure. I have main values folder and in it I have analytics.xml, strings.xml,styles.xml,mraid_attr.xml and colors.xml.
When I make new folder for localization, eg: values-fr I must put all of these files in it or just string.xml where I have translated strings?
You can just put your translated strings in your localization folder, but Lint will warn you about non-translated strings.
So if you have configuration strings (i.e no translation needed), create a separate XMl (like config.xml) and let only your translated strings on your localization folders.

android localization resource chooser

I have an android application on eclipse it's text-views and the buttons' texts on Arabic language , I want to localize my application to both Arabic and English users .
Firstly under res folder I have created another folder and named it values-en .
I let the original folder values as is it and later I will use it for Arabic .
My first question it is necessary to create another folder (values-ar) for Arabic localization issues.
Or original values folder is just enough?.
Secondly
On values-en folder I created strings.xml file and added the following statement to it
COMTAS
I set the text of one of the textviews from resource chooser so choose application-title .
after that the textview's text converted to #string/application-title.
the project gives me the following message
NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.
Can someone explains to me how to make localization in simple steps.
And how I can retrieve textviews' texts either in english or arabic (reading from values folder)?
First: Leaving a strings.xml in the "values" folder will cause this language to be "default" (or rather "fallback") language.
Second: The text is read automatically from the strings.xml placed in the values-folder matching your System Locale (the locale you get when you call Locale.getDefault()), e.g. if system locale is set to english, the values are taken from values-en folder. Therefore it would be wise to place the arabic values in a values-ar folder.
I can't say anything related to your compile errors as you didn't post the code causing the error.
It's always good to follow the documentation. Here is the link for Localizing with Resources.
Create a values-ar folder for the arabic language, and let the default language as english. Why?
Whenever the application runs in a locale for which you have not provided locale-specific text, Android will load the default strings from res/values/strings.xml.
So if your application is running on a device set to Spanish language, it would still load arabic language (if it's set as default).
English is a most talked language, which would be better to let english by default, ant let the arabic language in values-ar(in my humble opinion).
Hope this helps you.

export android application for one locale

I have to maintain an application which has strings, images, videos in different language it makes a heavy apk and I would like to know if I could tell the exporter to only package only resource applying to one specific locale ?
imagine I have the files
res/values/strings.xml
res/values-en/strings.xml
res/values-it/strings.xml
res/values-fr/strings.xml
And I want to generate and apk with only italian only
res/values/strings.xml
res/values-it/strings.xml
(and maybe force generated app to use italian as locale)
Actually I have 2 projects for 2 locales us / it, everthing is dupplicated, so everytime I have to edit a java or xml file I have to edit it twice.
Now I am required to create a 3rd apps for french and I don't want to copy paste to a new app and to maintain 3 times the same files ! (and more in the future)
I wanted to merge everything into a single apk and then export for one locale because the client require 1 apk per country
I don't know how I could refactor the apps to simplify my works my idea is to export for one locale
thanks for help
I think you could do this with Android Studio and Gradle but it would take some possibly complicated (for a Gradle beginner) setting up of the Source Sets folders.
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Product-flavors

How to show Locale List based on the Resource availability

I am developing an application that fetches all the system available locales and show in a listview to be selected by user to change the application language(just like android's language change option).
But I have a few res/values folder in my application resources like values (default), values-bn, values-zh, values-ar. SO I want these 4 languages to be shown in the list. How can I do this? I need to do this programmatically.
Suppose, I have 4 folders values, values-bn, values-en, values-zh
Then I only show,
Bengali
English
Chinese
OK, so what you want to do is have four languages: English, Bengali, Chinese, and Arabic, have I got that right? (Your question is internally inconsistent so it's hard to tell).
And you want to have a set of fallback values for when a string is missing in one of those four languages. The fallback values are in English, although the system won't know or care about that.
So what you want to do is put the strings for the four languages in the values-en, values-bn, values-zh, and values-ar directories and the fallback strings in the values directory.
In fact, since your fallback strings are in English, you could just put them in the values directory and have an empty resources file in the values-en directory. English would still show up in the list.
But why not just put the English versions of the strings in the values-en directory?

Categories

Resources