Android notes: Drill down to define complex strings for Right-to-left languages _android

Source: Internet
Author: User
The language we use, both Chinese and English, is read from left to right (Left-to-right), so we are very accustomed to reading from left to right (Left-to-right). Once you have encountered a Right-to-left read (Right-to-left), you will be very unaccustomed, even worse than to see the Martian text. Look at the light is uncomfortable, but more people crash is, but also for the application to define the Arabic language string, that is, for the application to add Arabic language support, not only to see a large number of Arabic, but also to deal with a number of complex strings.
For the Right-to-left language, the ideal is the following two kinds of case, it does not require special processing, as long as the translation of the translation into a string of resource files can:
1. When the Arabic, no special treatment, translation can be
2. The left side has English/digital, but the right side is Arabic (that is, in the Left-to-right language right there is English/digital)
3. If all is English or number, also do not need to deal with, let it retain left-to-right characteristic
For example:
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<!--file Values-ar/strings.xml-->
<string name= "Import" >استورد</string>
<string name= "Import_vcard" >استوردvCard</string>

After the run the result is: استورد
vcardاستورد
In some cases, however, special treatment is required:
1. In the middle there are English or digital
If you do not do the processing, the numbers will be turned into right-to-left, but in fact they need to be left-to-right, such as:
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<!--file Values-ar/strings.xml-->
<string name= "Send_msg_to" >استورد%sتور</string>

When you replace it, it becomes: استورد68001استورد, and what you need is: استورد10086استورد, here you need to add the English or the digital ends
Left-to-right Overrider \u202d and \u202c, such as:
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<!--file Values-ar/strings.xml-->
<string name= "Send_msg_to" >استورد\u202d%s\u202cتور</string>

1. The right has English or numbers (Left-to-right on the left)
2. Case of Xliff localized replacement
The solution is to add right to left Marker (RLM) before and after 中文版 or digits
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<!--file Values-ar/strings.xml-->
<string name= "Send_msg_to" >sendاستورد</string>
<string name= "Send_msg_to" >\u200fsendاستورد\u200f</string>
<string name= "send_msg_to" >\u200fsend <xliff:g id= "number" >\u200f%1$d</xliff:g>استورد</ String>

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.