What is the best way to provide the ability to switch between hebrew/english layouts in Android applications?
Is it commonly done - or usually just providing hebrew or english applications.
I know there is abikty to use localiztions - but is there Hebrew support for this?
Also my application should be for iPhone as well and I want to keep it the same.
How should do it in the code? Where to place the layouts?
Yoav
For orientation (right-to-left) you need: android.text.Layout.Direction
A hebrew TrueTypefont can then be called from a resource in your app by including TextView.
Instead of pushing 2 layout files you could use a class for hebrew and another for english...
or you could push the text to string values file for highest cleanliness
If it is a block of text that could be called from resource txt file (practical for prayers)
It all depends on how much text you have.
Related
My application needs to support languages that are read from right to left and vice verca.
Right now it supports only right to left, and all I need to do is change a bunch of layouts.
The approach I want to take is to have layouts in two different folders (i.e layout and layout-de), because doing it programatically, for every layout, is a nightmare.
However, Google state here http://developer.android.com/guide/topics/resources/localization.html#strategies
"you can create an alternative layout for that language (for example res/layout-de/main.xml). However, doing this can make your application harder to maintain"
My question is, which way is better, programmatically or separate layout folders
I want to stress, since this topic has been discussed in other threads:
I am NOT talking about strings. ONLY layouts
My only concern is the language orientation(left to right and right to left), when it comes to the layout.
Thank you very much in advance
Since Android 4.2 there is native RTL support. Most attributes that used "left" or "right" in their names now have equivalents that use "start" and "end" (e.g. android:paddingStart="..." or android:gravity="end").
Read about it here: http://android-developers.blogspot.com/2013/03/native-rtl-support-in-android-42.html
I'm designing an Android app that is to support 10 different languages/localities using Android Studio. The problem is that if I perfect the layout file for English it won't look right for other languages. For instance, some of the text might be truncated/cut off in another language because it is too long for the TextView, even if it is fine in English.
Is it possible to have language-based differences in font sizes in the layout (xml) file?
You should be able to create a layout-es folder to override the layout for the Spanish language etc. I have used it myself for drawables so I can't see why it wouldn't work for layouts too.
#darnmason's solution is correct -- locale-aware layout files do work, and to make it work, just duplicate the resource file in a layout folder with -xx, where xx is the language code. See the "639‑1" heading in this table for the language code.
So, for \res\layout\MainScreen.xml in French, the new file becomes \res\layout-fr\MainScreen.xml.
Despite Android Studio complaining that string resources should be localized into a (separate) resource file, it sometimes makes sense to use a duplicated locale-specific layout file; one such example is in the case referred to by the OP.
In general, try to do localization of text in a strings resource file. Sometimes, however, the translated text in one language would make the UI ugly in another language (compare length of "Nom d'utilisateur" with "用戶名", and the field sizes that result). In such cases, duplicate the layout file, as described above, as more than just the text (dimensions, perhaps fonts) is being localized.
The downside of using an additional layout file per language is that each time something changes (e.g. adding a button), multiple layout files need to be updated with all changes, rather than just adding the control to one layout file, and adding all translations to a separate strings resources file.
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
I am working on an application that will work on Android WebView. I enabled the selection and copy for this view. In some devices that support Arabic, When I paste the copied text from WebView in any EditText view, It shows me the reserve text. but In some cases it shows me the correct form.
Could any one please help me to show in correct form in all devices ? :-/
I have red all threads that depend on supporting Arabic and Farsi Text, but I can not reach my purpose.
Thanks in advance :)
You can pass your copied text to FarsiLibrary. It will analyses your text letters and justify them according to their possible 4 states (Initial, Middle, End, Isolated) :
Initial like 'ن' in 'نازک'
Middle like 'ن' in 'هنر'
End like 'ن' in 'وطن'
Isolated like 'ن' in 'ایران'
Android has Added support for RTL in Native widgets(i.e TextView , EditText) . so if u run the app onward 4.2 u will get RTL feature automatically ,
http://android-developers.blogspot.com.es/2013/03/native-rtl-support-in-android-42.html
You can create different versions of the layouts for different API versions.
As you can read here: http://developer.android.com/guide/topics/resources/providing-resources.html you can have say the normal folder (/res/layout/) with the layout for old devices and then another one for the ones that support it: /res/layout-11/
The layout inside layout-v11 will only be applied on devices with android 3.0 and over.
I am working on a android app which uses 29 different languages. I have created the layout according to english language in my resources folder but when the laguage changes the text views n text size changes and overlaps. Is there any way to keep the layouts constant for all laguages so that alignment of textviews and texts remain same?
yes very easy. you create for each language a values folder like values-de or values-en
in each folder you can create strings.xml
<string name="no_items">there are no items</string>
this is for the english one. create it for each language.
If you read the developer documents (here: http://developer.android.com/guide/topics/resources/localization.html#strategies), there is a good description of your problem and some ways to go about solving it. See the section "Design a flexible layout"
You can:
a) Provide different layouts per language with different layout files per language (although this can add a large amount of overhead for you to maintain your app)
or
b) Make a more flexible layout, so when long strings are passed in due to the language, everything adjusts by itself. Then you don't need to worry about which language the user is running in (or can create a lot less layouts specific to the language if some still don't look right).
you can extend TextView to adjust text size automatically to fit in.. an example of custom TextView is given in this answer https://stackoverflow.com/a/3378422/886001