Android Multi language Application - android

Please See this Image
An android application with 2 languages ENGLISH and ARABIC, there is also a registration activity which includes Password and Email . So when application is in Arabic Language I want to keep password and Email in English language.
Is there any solution for it?
I Just want to make EMAIL and PAssword in ENGLISH if locale is Arabic .

This concept is called Localization. To provide localization support in app, you need to create different values folders in res directory.
What you need to do is, create folder structures with having strings.xml file in each folder.
values
strings.xml
values-ar
strings.xml
In each strings.xml file, declare a string with same key name but put values in languages accordingly.

I hope you have created separate string.xml file for Arabic and English
under valuse-ar create string.xml file add add this lines
<string name="email">EMAIL</string>
<string name="password">PASSWORD</string>
UPDATE
in your layout.xml
<Editext
........
.......
android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890"
......
/>
this will allow only numbers and english
letters

Finally found the solution here:
Multilingual Android app: Display English keyboard in Email & Password fields
just add android:imeOptions="flagForceAscii"

try this tutorial
Android Building Multi-Language Supported App
http://www.androidhive.info/2014/07/android-building-multi-language-supported-app/

You can use translatable property in strings.xml
<string name="email" translatable="false">Email</string>

Related

Why my android studio doesn't support typing tamil language?

I am new to android studio. I am trying to create an application with localisation(Tamil). When I paste my Tamil language into android editor the font is not appearing as it should. Here is the Screen shot of my android studio
Already surfed lot here. There is no answer for this issue. It would be great if anyone help on this.
When i tried to generate that same condition I came to know that you haven't added that string named "app" in your default locale i.e. in strings.xml and you are directly trying to add a translation for it.
When u hover to that error it states:
app is transalted here but not found in default locale.
First add(create) that string in your strings.xml file and then try to add it in your strings.xml (tamil) file.
Follow these steps:
First go to your project's res folder --> then open values folder --> then open "strings.xml" file and remove all text inside it and paste the text shown below:
<resources>
<string name="app_name">My Application</string>
<string name="tamil_app_name">ஆங்கில தட்டச்சு வழியாக நம் மொழி</string>
</resources>
Because you have to create a Tamil language string file to set your language. please do the following steps-:
1) Firstly declare all the strings in main strings.xml
2) Then create the string file according to your language choice, Example strings.xml(ta)
3) (ta) is the language code accordingly.
4) The Strings that you have in your main string file convert them into particular language which you want then paste it into the new created String file.

What should be the name for values folder for developer english in android

What i want is the name of value folder which consists of String.xml , In that XML i have written key-key pairing i.e "NAME"
"EMPLOYEE_ID". If i use any language key word say en,fi, that will not a good practice. So what should be the name of value folder for above string.xml.
Thank you.
Bydefault for english language it will pickup from values folder and for supporting languages you can refer this link
You should save this xml in the values folder only. Android is not bothered about what the keys are being mapped to; it just makes sure it returns the right value respecting the overrides if any for a particular device's Locale settings.
So, whether the key maps to a value or to some value's key itself, has no bearing on the values folder it should go in; but it should preferably be stored in a different xml file, say, string_keys.xml or something.
values/strings.xml
<string name="employee_name">Name</string>
values/strings_keys.xml
<string name="employee_name_key">employee_name</string>

Change the language of the app according to the default language of the device

I want to change the language of a my application according to the default language of the device in which the app is installed.
For example: if the default language of the device is French, the user will use the app in French.
I've tried to search for a solution, but probably I don't understand how to do that. Anyone can help me? Every help will be gretly appreciated.
To add support for more languages, create additional values directories inside res/ that include a hyphen and the ISO country code at the end of the directory name. For example, values-es/ is the directory containing simple resourcess for the Locales with the language code "es". Android loads the appropriate resources according to the locale settings of the device at run time.
Create the resource subdirectories and string resource files. For example:
MyProject/
res/
values/
strings.xml
values-es/
strings.xml
values-fr/
strings.xml
Where fr = french
And in /values-fr/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">Mon Application</string>
<string name="hello_world">Bonjour le monde !</string>
</resources>
Source = Multi language
use qualifiers on your strings i believe fr is for france. So if you have a resource folder called values-fr, then anyone with french on their phone will get the french string file located in that folder and everyone else will get the string file in the values folder (without the -fr qualififer)
You can use qualifiers in all kind of resources of your app. You can for example, have a different layout depending on user language (it's useful on japanese or arabic language).
http://developer.android.com/guide/topics/resources/localization.html

Android application name error

I tried to build an android application, when I use non-english langues like persian as name of application it causes this error AndroidManifest.xml file missing and no manifest builds but when I use english it works successful, why?
at the top of every XML file in Android you'll see
<?xml version="1.0" encoding="utf-8"?>
So first I ask you: is persian included in utf-8 encoding?
I had a quick look on this link http://www.utf8-chartable.de/ and it seems to be me that's a no but I'm no language expert and that table might show persian as one of it related or base languages (like portuguese uses latin set)
If persian is not available in the utf-8 your best option to try to get this name in the app name is to create a strings_per.xml (inside the /values/ folder) and in there you put a different encoding and the string you need for the app name.
note that I tried to isolate the problematic variable in its own file because I'm not sure it would be a good idea to mix it with the rest of the manifest.
Farsi IS included in UTF8.
You need to add a string in strings.xml in /res/values.
Then define a farsi name there.
Your string.xml will look like this:
<string name="app_name">اسم اپ</string>
<string name="title_tab1">تماس با ما</string>
<string name="action_settings">Settings</string>
And you will reference it in you manifest.xml like this:
android:label="#string/app_name"
But remember: Farsi characters are not perfectly shown in android 2.2 and 2.3.
The characters are displayed separately. For later androids this is not an issue.

Different language on textview in Android

how can i write different language (Bangla) on textview or edittext in Android and for this What version of API i have to need
If you use strings.xml to add a level of indirection for string values, then you can easily localize your strings as in:
android:text="#string/main_text_view_hello"
So I have a strings.xml in folders:
res/values
res/values-en-rCa
res/values-en-rGB
Any time I want to change a value for Canada or United Kingdom, I just add it to the appropriate folder. All other values are obtained by default from res/values.
You can set text with TextView.setText(String-ID) . String-IDs are managed in strings.xml files which are under res/values folder. If you want another language for example german you need another strings.xml file with the same String-IDs in res/values-de. In android layout files you can reference such string ids with #string/stringid.

Categories

Resources