Android strings.xml resource - arabic language and dynamic formatted strings

烈酒焚心 提交于 2020-01-02 02:19:06

问题


Hello I have a question about arabic formatting how should I properly format this strings, it seems i can't manage this:

تحميل %1$s…

تم تحميل الكلمات. %1$d/%2$d!

This is in sublime text 2 - but i think that there is Left-to-Right order

EDITED: In Eclipse this copied from Sublime Text gets messed up a little. I hire some person to translate from english to arabic strings.xml. He used Word editor but things get messed up when coping to eclipse and I suggested to changed it in Sublime Text, that I think will support it correctly like in Eclipse and is lighter editor. I see that in Sublime Text seems to be in Left-To-Right order which is also wrong. * When I run app with this messed up special characters it seems to run correctly. Bu I have doubt whether some interpunction words hasn't also messed up and for example: Item 5/10 has been downloaded. will be Item has been downloaded. 5/10 or something like this.* Need a preferred way to get someone english written strings.xml, get this translated, and then copied into /values-ar and working correctly?


回答1:


Try adding a RIGHT-TO-LEFT MARK character (\u200F) at the start of your text.

similar type answered here




回答2:


That is a sublime issue with Right-to-Left languages as listed here. You dont have to worry too much about it because it does not affect the results, your app will show it perfectly.




回答3:


"To solve this problem, use the unicodeWrap() method, found in the BidiFormatter class, on every piece of text that you insert into a localized message."

Quoted from here https://developer.android.com/training/basics/supporting-devices/languages.html#FormatText




回答4:


You have to use Arabic Font like:

Typeface face = Typeface.createFromAsset(this.getAssets(), "fonts/arabic_letters.TTF");
yourTextView = (TextView) findViewById(R.id.yourTextVIew);
yourTextView.setTypeface(face, Typeface.BOLD);


来源:https://stackoverflow.com/questions/29071623/android-strings-xml-resource-arabic-language-and-dynamic-formatted-strings

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