Practical Android skills: define complex strings for the right-to-left Language

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 they are all Arabic, no special processing is required.
  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 they are all English or numbers, they do not need to be processed, so that they retain the features of left-to-right.

For example:

<?xml version="1.0" encoding="utf-8"?>    <!-- file values-ar/strings.xml -->    <string name="import">استورد</string>    <string name="import_vcard">استورد 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:

<?xml version="1.0" encoding="utf-8"?>    <!-- file values-ar/strings.xml -->    <string name="send_msg_to">استورد%sتور</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:

<?xml version="1.0" encoding="utf-8"?>    <!-- file values-ar/strings.xml -->    <string name="send_msg_to">استورد\u202d%s\u202cتور</string>
  1. There are English or numbers on the right (left-to-right on the left)
  2. When xliff is replaced locally

The solution is to add right to left marker (rlm) before and after English or digits

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