XML : How to use Android xliff:g

Can someone please explain the xliff:g for strings/localization.

I am on my 5th day of learning beginners android programming and I was able to get my strings to work in English and I got some practice strings to work when I set system to Spanish. I also understand that xliff:g is not supposed to translate anything inside the <> things, but I'm just confused how exactly I'd use this in code.

An example I have in my case is the practice spanish translations that I have has:

  <string name="order_quantity">Cantidad: <xliff:g id="quantity" example="2">%d/xliff:g</string>    

I am now trying to get localized strings with xliff:g to work. What is ID here, what does it do, and what does it call? Also what is the %d and what does it do? What is the point of example/what does that do. I'm assuming it's there more than just to look pretty :p (is it just essentially a note?) Also how would I call that into code if at all?

Why can't/shouldn't someone just do the following code to insert the following xml:

  <string name="quant">Quantity: </string>    

into java like so:

  getString(R.string.quant) + quantity    

so that way it concactenates the quantity variable into the getString?

No comments:

Post a Comment