Strange behavior in android resources - strings.xml - android

I have two projects
Project1 contains a strings file with entry (values, values-ar) for Arabic and English accordingly.
Project2 which include Project1 and must override the entry of strings file with Arabic text in both (values, values-ar)
When I put its value in arabic it doesn't show my text, but when I add English text it works
I have tried it many times and I don't know what the problem is, can anyone help please.

Android chooses the right string file according to device's language.
Placing the Arabic Strings on files at rec/values-ar/ folder and setting device's language to "ar" will work.

If project 2 is exclusively Arabic remove the values-ar and place all your Arabic text within the values folder.
Ensure that every string value in Project1's values is placed within Project2's values file in Arabic to override all English values.

Related

Greek language is not used in Android

I want to support the greek language.
I translated my string.xml into the greek language.
Then I put the greek string.xml it into a folder called: res/values-gr besides the normal res/values.
So my folder looks like this: res/values-gr/string.xml
Then I set my phone language to greek.
However, the app still displays english only.
Has anybody an idea what I am doing wrong?
In your case you need to create a folder:
values-el for the Greek translation, or
values-el-rGR for the country-specific Greek translation.

How to provide Arabic Language support in Android Application

I have made an application in android but now I have to provide arabic language support. I have checked many of answers in stackoverflow but from any answer I didn't get correct answer.
To provide localization support for different languages, we need to add the language specific resources into separate folder. For eg:Inorder to provide layouts for Arabic language
we need to create a separate folder under res folder i.e.,res/layout-ar like this.
In order to access the current language via code we can get the current language by calling
Locale.getDefault().getDisplayLanguage();
for more information look into following links:
for localization :http://developer.android.com/guide/topics/resources/localization.html
for RTL layout mirroring (Arabic like languages):http://android-developers.blogspot.de/2013/03/native-rtl-support-in-android-42.html
Also you may need to use 'onConfigChange' to your 'AndroidManifest' file with option 'locale'
I am just a beginner but I have looked this question up and came up with this:
http://marketplace.eclipse.org/content/android-string-localization#.VG5A_PmUeSp
Eclipse provides string localization. However, when it translated the strings to Arabic, I had to double check the translation because Arabic has Feminism in Grammar and also some plural forms aren't that correct.
In AndroidManifest.xml:
SupportRtL
this will enable alignments of images and text to right in Arabic and left in English
Create two string resource layouts (one English, one Arabic)
string Resource
Add the same string with the same name in the two layouts but change the value of the arabic string in the (ar\strings.xml)
Same goes to each drawable item
(Also for reference I'll add how you can create a resource that ar or RL)
creating arabic resourse
Also either in the base activity to set the base local language
app = (MyApplication)getApplicationContext();
lang = Actions.setLocal(this);using the function:
function

Android - How to work with 2 'values' folders for strings in 2 languages?

I plan on making my app bilingual, English and German.
I have two folder within /values for both, and now all of a sudden none of my strings can be found, giving me the following error for all my strings
"Error: No resource found that matches the given name (at 'text' with value '#string/stringname')
How can I tell it to look in my new folders where all the strings are?
you don't need 2 folders inside values. In values you keep your strings.xml file (from here it will take the strings for english) and you create another folder, inside res/ called values-de where you will create a copy of the strings.xml file and just translate the content. The android system will choose the right content, depending on the language used on the phone.

Android: Regarding using different strings based on user choice

You can use strings in this way: " R.string.*" or in xml: "android:text=#strings/*" - right?
They all take their values out of a fixed file named strings where you put them all in right?
Let's say I have an app where there is the possibility to change language. Is there a way in which I can change that string file? Let's say have a strings file for English and strings for French or anything.. so i can still use the R.string.* and #string/* but I will get different values depends on the user choice?
The Developer's Guide on Localization covers this.
In short use the same string names, but have different locale folders, like:
res/values/strings.xml for the default language
res/values-fr/strings.xml for French
res/values-ja/strings.xml for Japanese
The OS will load the appropriate language for R.string.hello for you.

android layout according to language selected

I would like to know if there is any good idea how to switch layouts according to application language selected - e.g. switch between left-to-right layout and right-to-left layout. Have different images or written text and ofcourse the position.
I thought doing it using a private member in the application that indicates the current language selected. According to this parameter I can choose the related XML and text etc.
Actualy I might create some LayoutFactory class, although I don't really think it is required.
But will have to create the realted layout XMLs.
Is there any option to put subdirectories under he layout?
Or should I name the files like en_.xml and he_.xml etc?
For values and drawable you can add folders like values-fr for French or values-ja for Japanese. The -fr indicates that if your phone is set to French localization the app will use any folder that has the -fr added to its name. I'm guessing this goes for the layout folder aswell.
You can read about Localization here .

Categories

Resources