I have a normal Textview which contains both Arabic and English texts.
Below is the original text
"unit_label_text": "محتوى 0.4kg (€ 10.00 / 1Kg)",
When I try to paste it inside of xml it's like the below and the mobile app itself showing the same.
Note: When the device language is English it's working fine. But if I changed the device language to Arabic. It's not working,
When you use the Arabic language the app automatically uses the RTL format so you can consider disabling the RTL (Right to Left) format for your app.
In your manifest file and inside the application tag add these two lines.
<manifest>
<application
.
.
.
android:supportsRtl="false"
tools:replace="android:supportsRtl"
>
</application>
Or else try removing this code from your XML
android:layoutDirection="rtl"
Related
I am trying to localize my app in arabic by using **
android:supportsRtl:false
** in my manifest file.It actually works for all the strings declared in the xml layout i.e **
android:text="#string/done_btn"
**and all the arabic localized strings are written ltr(left to Right) but those strings which are written programmatically using resources strings i.e
getString(R.id.name)
are localized but it is using it's default written type i.e rtl(Right to left) instead of ltr(left to Right) thereby destroying the layout and design of the page.
N.B:1> i already tried setting android:layoutDirection="ltr" or android:textDirection="ltr" to the textview with localized string or the container layout which it holds.
Any help would be highly appreciated.
I'm new to android and i want to translate an app. to arabic and force RTL direction.
If anyone can help please.
Thank you
If you want to support Arabic for your app, follow the below steps :
1) Create resource file (res/values-ar/strings.xml) and put your content.
2) Mostly supportsRTl set as true. Check once in Manifest file.
Example:Creating Arabic resource file
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
3) Test it in your device by doing below settings changes :
Select locale(Arabic) in language option
"Force RTL layout direction" in Developer option.
Note : Developer option will be enabled once you select build number 7 times. (inside Settings/ About Phone)
You can find simple example in below link:
https://www.tutorialspoint.com/android/android_localization.htm
I have app in android studio and When i install APK and Language is English,
it show language of app like i want, but when phone language is different like Persian, it show other language in app and i don't want it...
how i can force app to use same English even language of phone changed?
my application is in Android studio and just one line have problem, mean there is a line words in application, and when i change language phone, it change to a different language same i don't want.
this is my main.xml (same line code
<TextView
android:id="#+id/diffText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dhuhar After one hour 10 min"
android:textColor="#ffffff"
android:textSize="16dip"
android:textStyle="bold"></TextView>
</LinearLayout>
And this one is not available in my string.xml, it mean it not translated, correct?
and cause "one hour 10min" is not stable, there is easy way i force it to use for all language same use for english?
I set below code in oncreate and solved
Locale.setDefault(Locale.ENGLISH);
If you want only english for all languages, dont set different language xml.. Just provide only default strings.xml.. app will show what ever text in strings.xml.
If you don't define your string in other language files (only write <string name="yourstring" translatable="false">Your english string</string>) then you will get your expected behavior.
That is because it takes the strings from values/ if they are not available in the specific folder for the current language (e.g. values-de/)
I have an app that supports Hebrew and declares in the manifest its support for RTL locales. However, there are other RTL locales that I do not support and would like my Views not to be mirrored when these locales are set. For example, I don't want my app's Views to be swapped from right to left when in the Arabic locale, since I don't support Arabic and therefore text will show in English.
I guess the best way is to make android:supportsRtl value to be selected according to the language. To do that see below:
AndroidManifest.xml
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:supportsRtl="#string/is_hebrew" >...</application>
Then in values/strings.xml add:
<string name="is_hebrew">false</string>
And with values-he/strings.xml add:
<string name="is_hebrew">true</string>
You can choose to turn mirroring on or off at runtime. See https://stackoverflow.com/a/17683045/192373. This is limited to 4.2 or higher, and only in onCreate() of your activity.
I used Arabic text so,
I want to write text from right to left so how i can write right to left text in android ?
Regards,
Girish
Try with Bidi
Declare in your app manifest that your app supports RTL mirroring: 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.
Native RTL support in Android 4.2
It looks like this is only possible starting with jelly bean
use this
android:textDirection="rtl"
android:gravity="right"