title: What is purpose of id attribute in Android <xliff:g> placeholder tags in string resources?
body: <p>The Android app developer <a href="https://developer.android.com/distribute/tools/localization-checklist.html" rel="nofollow">localization checklist</a> recommends the use of   placeholder tags for text that shouldn't be translated. That part I understand. </p>
  
  <p>It also recommends to "always add an id attribute that explains what the placeholder is for". That part I don't understand. When I look at examples from the Android open source project I see many cases where such IDs are used, for instance:</p>
  
  <pre><code>&lt;string name="photo_view_count"&gt;&lt;xliff:g id="current_pos"&gt;%d&lt;/xliff:g&gt; of &lt;xliff:g id="count"&gt;%d&lt;/xliff:g&gt;&lt;/string&gt; 
  </code></pre>
  
  <p>(from /frameworks/opt/photoviewer/res/values/strings.xml)</p>
  
  <p>The IDs defined in that string ("current_pos" and "count") are not referenced anywhere in the underlying Java code, however, so what is the purpose? Is it purely a help to translators, supposed to explain what the placeholder value can be?</p>
  
  <p>I could see a purpose in identifying each of the placeholders with an ID if those IDs were in fact referenced in the code, since that would serve the purpose of allowing the translator to switch the order of the placeholders around. But that is not happening. And the IDs in question are even uppercased in the translated versions ("CURRENT_POS" and "COUNT") - a function of the translation tool used in this case, I think.</p>