How to edit arabic string properly?

余生颓废 提交于 2019-12-19 17:38:23

问题


<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?


回答1:


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.




回答2:


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.)




回答3:


You can try in Activity..

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



回答4:


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.



来源:https://stackoverflow.com/questions/19242279/how-to-edit-arabic-string-properly

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