Use of <xliff:g> tags in android

Source: Internet
Author: User

Look at the source code today found in the resource file/res/values/strings.xml some <string> tags include <xliff:g> tags, such as:

<name= "Running_process_item_user_label"><  ID = "user_name" >%1 $ s</xliff:g></string>

This label has not been used before, and I looked it up on the Internet. The Xliff foreign name is the XML Localization interchange File format, and the Chinese name is the XML localized data Interchange format.

<xliff:g> Label Description:

Property ID can be arbitrarily named

The attribute example represents an example, omitting

%n$ms: The output is a string, n is the number of parameters, setting the value of M can place a space before the output
%N$MD: The output is an integer, n is the number of parameters, setting the value of M can be placed before the output space, or can be set to 0m, before the output of M 0
%N$MF: The output is a floating-point number, n is the number of parameters, setting the value of M can control the scale, such as m=2.2, the output format is 00.00

To illustrate:

<ResourcesXmlns:xliff= "urn:oasis:names:tc:xliff:document:1.2">    <stringname= "Welcome">Welcome<xliff:gID= "Name">%1 $ s</xliff:g>Ranking<xliff:gID= "num">%2$d</xliff:g>    </string></Resources>

Use the <xliff:g> tag to add a namespace to the resources and then use it in the Android program

Public final String getString (int resId, Object ... formatargs)
String s = getString (R.string.welcome, "abc", 123);

Output: Welcome to ABC, ranking 123

Use of <xliff:g> tags in android

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.