Improve documentation around localization / languages

I just converted my ancient plugin from using strings.xml to strings.po, and I got pretty darn confused.

* language_support (wiki) says to put the files at resources/language/resource.language_$code/strings.po, but every addon I’ve looked at in the master repo has resources/language/$language/strings.po
* The syntax of the file seems totally mad and this merits explanation msg*id* = the text, msgctxt (message comment text?) = the id, msgtxt = empty string. What on earth happened?
* Translated examples I’ve seen look something like this:

msgctxt “30000”
msgid “Text in English”
msgstr “Text in die Auslaendische Sprache”

Why do we replicate the English text across every translation in msgid? Is this is supposed to be an id in any meaningful way? If it is, what happens if the word is the same in English but not other languages, e.g. (cricket) bat vs (animal/man) bat?

* Perhaps I’m the only addon who was still using strings.xml but a conversion script would have been useful:

Code:
import datetime
from lxml import etree
import sys

# Arguments are: ISO-639 code, Human readable language name, path to strings.xml, output path
code = sys.argv[1]
language = sys.argv[2]
src = sys.argv[3]
dst = sys.argv[4]

with open(src) as fp:
  tree = etree.parse(fp)

pofile_tmpl = u'''msgid ""
msgstr ""
"Project-Id-Version: plugin.video.ted.talks\\n"
"Report-Msgid-Bugs-To: https://github.com/moreginger/xbmc-plugin.video.ted.talks\\n"
"POT-Creation-Date: {now}+000\\n"
"PO-Revision-Date: {now}+000\\n"
"Last-Translator: Kodi Translation Team\\n"
"Language-Team: {language} (http://www.transifex.com/projects/p/xbmc-addons/language/{code}/)\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Language: {code}\\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\\n"
'''

string_tmpl = u'''
msgctxt "{id}"
msgid "{id}"
msgstr "{txt}"
'''

now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
pofile = pofile_tmpl.format(code=code, language=language, now=now)

for c in tree.xpath('//string'):
    id = c.get('id').strip()[0:]
    txt = c.text.strip()
    pofile += string_tmpl.format(id=id, txt=txt)

with open(dst, 'w') as fp:
    fp.write(pofile.encode("UTF-8"))