Home » Android » android – How to edit arabic string properly?

android – How to edit arabic string properly?

Posted by: admin June 15, 2020 Leave a comment

<string name="message">هذا المجلد يحتويى على %1$s ملفات. الرجاء التأكد قبل الحذف. الملفات المحذوفة غير قابلة للإسترجاع.</string>

I wanna put “%1$s” in an arabic string, but as you can see here, word, notepad++, utraedit, all failed to get the right string. how you guys edit arabic string?

How to&Answers:

In android Studio 2, RTL support is not turned on by default,
Configure it Manually:

1. In your Computer, go to the [android-studio2.0]/bins/idea.properties

2. add editor.new.rendering=true to the end of idea.properties

3. restart your android studio.


This is a source of frustration when editing mixed-direction text. What counts is the logical order of the text, not how any of the editors display it. When you finally format the string at run time in the app, the %1$s will be replaced by whatever string you pass to the formatting method. The only thing that matters is how the string will be rendered after the substitution.

The easiest thing to do is to write the message without the %1$s, then position the insertion caret, paste in the format code, and simply ignore how the editors screw up the bidi analysis. (The screw-up is because the editors are using a left-to-right base level. In some editors, you can set the base flow to right-to-left, but then the xml markup ends up being unreadable.)


You can try in Activity..

String formatedString =  String.format("%1$s", getString(R.string.your_string));


When I work with RTL text and I need to put a place holder(%1$s) or LTR words, I just write it in MS Word and copy to the IDE.
It works for me in Eclipse and Android Studio.
All you need to check is that the components that displays that string like TextView has the right gravity.