Android localization arabic language

ぐ巨炮叔叔 提交于 2020-01-13 07:01:40

问题


There is localization available in android for various language strings. I need to localize layouts for arabic language. Example: In English my layout is: Name (TextField): Name(EditText) But for arabic it will be: Name (EditText): Name(TextField) Is there a way for this in android, or do I have to make a different layout to localize Arabic language.


回答1:


Seems you are looking for this recently added to Android: http://android-developers.blogspot.de/2013/03/native-rtl-support-in-android-42.html

Probably earlier versions of Android you need to implement some logic here on you're own. See here the next link for suggestions: http://developer.android.com/guide/topics/resources/localization.html

This way you can probably have a arabic specific layout, explained in section "Design a flexible layout". And see the following website for the localization code: http://colincooper.net/blog/2011/02/17/android-supported-language-and-locales/




回答2:


To take advantage of RTL layout mirroring, simply make the following changes to your app:

Declare in your app manifest that your app supports RTL mirroring. Specifically, add android:supportsRtl="true" to the element in your manifest file.

Change all of your app's "left/right" layout properties to new "start/end" equivalents. If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”. For example, android:paddingLeft should become android:paddingStart. If you want your app to work with versions earlier than Android 4.2 (the app's targetSdkVersion or minSdkVersion is 16 or less), then you should add “start” and end” in addition to “left” and “right”. For example, you’d use both android:paddingLeft and android:paddingStart. For more precise control over your app UI in both LTR and RTL mode, Android 4.2 includes the following new APIs to help manage View components:

android:layoutDirection — attribute for setting the direction of a component's layout. android:textDirection — attribute for setting the direction of a component's text. android:textAlignment — attribute for setting the alignment of a component's text. getLayoutDirectionFromLocale() — method for getting the Locale-specified direction You can even create custom versions of layout, drawables, and other resources for display when a right-to-left script is in use. Simply use the resource qualifier "ldrtl" to tag your resources, meaning “layout direction right-to-left”. To debug and optimize custom right-to-left layouts, HierarchyViewer now lets you see start/end properties, layout direction, text direction, and text alignment for all the Views in the hierarchy.



来源:https://stackoverflow.com/questions/15289474/android-localization-arabic-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!