Android Note: in-depth explanation of defining complex strings from right to left

Source: Internet
Author: User
Tags vcard

The language we use, whether in Chinese or English, is read from Left To Right ), therefore, we are very accustomed To reading from Left To Right ). Once you encounter a Right-To-Left reading, you will be very unaccustomed To it, even more uncomfortable than seeing Mars. It is uncomfortable to look at it, but what is even more frustrating is that we need to define the Arabic language strings for the application, that is, to add the Arabic language support for the application, not only do you need to view a large number of Arabic books, but you also need to process complex strings.
For the Right-To-Left language, the ideal is the following two cases. It does not require special processing, as long as the translation is written into the string resource file:
1. When all are Arabic, no special processing is required. Just translate
2. There are English/numbers on the Left, but Arabic on the Right (that is, there are English/numbers on the Right in Left-To-Right)
3. If all the data is in English or numbers, you do not need To deal with it, so that it retains the features of Left-To-Right.
For example: Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<! -- File values-ar/strings. xml -->
<String name = "import"> too many bytes have been transferred </string>
<String name = "import_vcard"> invalid variable vCard </string>

After running, the result is: zookeeper has been successfully executed.
VCard has been released successfully
However, in some cases, special processing is required:
1. English or numbers in the middle
If not processed, the number will be changed To Right-To-Left, but in fact Left-To-Right is required, for example:Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<! -- File values-ar/strings. xml -->
<String name = "send_msg_to"> too many bytes have been written into % s too many bytes </string>

After it is replaced, it will become: when there are too many attempts, then 68001 when there are too many attempts, and what is needed is: please refer to the following link for more information:
Left-To-Right overrider \ u202D and \ u202C, for example:Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<! -- File values-ar/strings. xml -->
<String name = "send_msg_to"> too many bytes have been uploaded \ u202d % s \ u202c too many bytes </string>

1. There are English or numbers on the Right (Left-To-Right in the leftmost)
2. xliff localized replacement
The solution is to add Right to Left Marker (RLM) before and after English or digitsCopy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<! -- File values-ar/strings. xml -->
<String name = "send_msg_to"> send messages before sending messages </string>
<String name = "send_msg_to"> \ u200fsend has been sent successfully before running \ u200f </string>
<String name = "send_msg_to"> \ u200fsend <xliff: g id = "number"> \ u200f % 1 $ d </xliff: g> commandid too many commandid </string>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.