Detect errors in language name translations

This commit is contained in:
Kovid Goyal 2013-05-06 09:25:15 +05:30
parent 740dea6671
commit af5de01227
16 changed files with 55 additions and 29 deletions

View File

@ -2024,7 +2024,7 @@ msgstr "Àzeri meridional"
#. name for aze
msgid "Azerbaijani"
msgstr "Serbi"
msgstr ""
#. name for azg
msgid "Amuzgo; San Pedro Amuzgos"
@ -21816,7 +21816,7 @@ msgstr "Ramoaaina"
#. name for raj
msgid "Rajasthani"
msgstr "Marwari"
msgstr ""
#. name for rak
msgid "Tulu-Bohuai"

View File

@ -13762,7 +13762,7 @@ msgstr ""
#. name for lav
msgid "Latvian"
msgstr "litevština"
msgstr ""
#. name for law
msgid "Lauje"

View File

@ -1429,7 +1429,7 @@ msgstr ""
#. name for arg
msgid "Aragonese"
msgstr "Færøsk"
msgstr ""
#. name for arh
msgid "Arhuaco"

View File

@ -319,7 +319,7 @@ msgstr "Adangme"
#. name for adb
msgid "Adabe"
msgstr "Adangme"
msgstr "Adabe"
#. name for add
msgid "Dzodinka"
@ -367,7 +367,7 @@ msgstr "Adap"
#. name for adq
msgid "Adangbe"
msgstr "Adangme"
msgstr "Adangbe"
#. name for adr
msgid "Adonara"

View File

@ -2022,7 +2022,7 @@ msgstr ""
#. name for aze
msgid "Azerbaijani"
msgstr "Turkiera"
msgstr ""
#. name for azg
msgid "Amuzgo; San Pedro Amuzgos"
@ -13126,7 +13126,7 @@ msgstr ""
#. name for kur
msgid "Kurdish"
msgstr "Turkiera"
msgstr ""
#. name for kus
msgid "Kusaal"
@ -16190,7 +16190,7 @@ msgstr ""
#. name for mlt
msgid "Maltese"
msgstr "Koreera"
msgstr ""
#. name for mlu
msgid "To'abaita"

View File

@ -13764,7 +13764,7 @@ msgstr "Laba"
#. name for lav
msgid "Latvian"
msgstr "Lituano"
msgstr ""
#. name for law
msgid "Lauje"
@ -22212,7 +22212,7 @@ msgstr "Roglai do norte"
#. name for roh
msgid "Romansh"
msgstr "Romanés"
msgstr ""
#. name for rol
msgid "Romblomanon"

View File

@ -20538,7 +20538,7 @@ msgstr ""
#. name for peo
msgid "Persian; Old (ca. 600-400 B.C.)"
msgstr "perzsa"
msgstr ""
#. name for pep
msgid "Kunja"

View File

@ -15049,7 +15049,7 @@ msgstr "Magahi"
#. name for mah
msgid "Marshallese"
msgstr "Maltneska"
msgstr ""
#. name for mai
msgid "Maithili"

View File

@ -3742,7 +3742,7 @@ msgstr ""
#. name for bre
msgid "Breton"
msgstr "프랑스어"
msgstr ""
#. name for brf
msgid "Bera"

View File

@ -6804,7 +6804,7 @@ msgstr "डोगोन; तेबुल उरे"
#. name for dua
msgid "Duala"
msgstr "ड्युला"
msgstr ""
#. name for dub
msgid "Dubli"

View File

@ -27790,7 +27790,7 @@ msgstr ""
#. name for wln
msgid "Walloon"
msgstr "Vietnamesisk"
msgstr ""
#. name for wlo
msgid "Wolio"

View File

@ -9862,7 +9862,7 @@ msgstr "Hya"
#. name for hye
msgid "Armenian"
msgstr "Albanés"
msgstr ""
#. name for iai
msgid "Iaai"
@ -13762,7 +13762,7 @@ msgstr "Laba"
#. name for lav
msgid "Latvian"
msgstr "Lituanian"
msgstr ""
#. name for law
msgid "Lauje"

View File

@ -2089,7 +2089,7 @@ msgstr "Башкирский"
#. name for bal
msgid "Baluchi"
msgstr "Балийский"
msgstr ""
#. name for bam
msgid "Bambara"

View File

@ -13763,7 +13763,7 @@ msgstr ""
#. name for lav
msgid "Latvian"
msgstr "Lotyšský"
msgstr ""
#. name for law
msgid "Lauje"

View File

@ -1016,7 +1016,7 @@ msgstr ""
#. name for amh
msgid "Amharic"
msgstr "阿拉伯语"
msgstr ""
#. name for ami
msgid "Amis"

View File

@ -18,7 +18,7 @@ def qt_sources():
'src/gui/widgets/qdialogbuttonbox.cpp',
]))
class POT(Command): # {{{
class POT(Command): # {{{
description = 'Update the .pot translation template'
PATH = os.path.join(Command.SRC, __appname__, 'translations')
@ -63,7 +63,6 @@ class POT(Command): # {{{
return '\n'.join(ans)
def run(self, opts):
pot_header = textwrap.dedent('''\
# Translation template file..
@ -117,11 +116,10 @@ class POT(Command): # {{{
f.write(src)
self.info('Translations template:', os.path.abspath(pot))
return pot
# }}}
class Translations(POT): # {{{
class Translations(POT): # {{{
description='''Compile the translations'''
DEST = os.path.join(os.path.dirname(POT.SRC), 'resources', 'localization',
'locales')
@ -134,6 +132,7 @@ class Translations(POT): # {{{
return locale, os.path.join(self.DEST, locale, 'messages.mo')
def run(self, opts):
self.iso639_errors = []
for f in self.po_files():
locale, dest = self.mo_file(f)
base = os.path.dirname(dest)
@ -146,18 +145,46 @@ class Translations(POT): # {{{
'%s.po'%iscpo)
if os.path.exists(iso639):
self.check_iso639(iso639)
dest = self.j(self.d(dest), 'iso639.mo')
if self.newer(dest, iso639):
self.info('\tCopying ISO 639 translations')
self.info('\tCopying ISO 639 translations for %s' % iscpo)
subprocess.check_call(['msgfmt', '-o', dest, iso639])
elif locale not in ('en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc',
'ltg', 'nds', 'te', 'yi', 'fo', 'sq', 'ast', 'ml', 'ku',
'fr_CA', 'him', 'jv', 'ka', 'fur', 'ber'):
self.warn('No ISO 639 translations for locale:', locale)
if self.iso639_errors:
for err in self.iso639_errors:
print (err)
raise SystemExit(1)
self.write_stats()
self.freeze_locales()
def check_iso639(self, path):
from calibre.utils.localization import langnames_to_langcodes
with open(path, 'rb') as f:
raw = f.read()
rmap = {}
msgid = None
for match in re.finditer(r'^(msgid|msgstr)\s+"(.*?)"', raw, re.M):
if match.group(1) == 'msgid':
msgid = match.group(2)
else:
msgstr = match.group(2)
if not msgstr:
continue
omsgid = rmap.get(msgstr, None)
if omsgid is not None:
cm = langnames_to_langcodes([omsgid, msgid])
if cm[msgid] and cm[omsgid] and cm[msgid] != cm[omsgid]:
self.iso639_errors.append('In file %s the name %s is used as translation for both %s and %s' % (
os.path.basename(path), msgstr, msgid, rmap[msgstr]))
# raise SystemExit(1)
rmap[msgstr] = msgid
def freeze_locales(self):
zf = self.DEST + '.zip'
from calibre import CurrentDir
@ -191,7 +218,6 @@ class Translations(POT): # {{{
locale = self.mo_file(f)[0]
stats[locale] = min(1.0, float(trans)/total)
import cPickle
cPickle.dump(stats, open(dest, 'wb'), -1)
@ -211,7 +237,7 @@ class Translations(POT): # {{{
# }}}
class GetTranslations(Translations): # {{{
class GetTranslations(Translations): # {{{
description = 'Get updated translations from Launchpad'
BRANCH = 'lp:~kovid/calibre/translations'
@ -286,7 +312,7 @@ class GetTranslations(Translations): # {{{
# }}}
class ISO639(Command): # {{{
class ISO639(Command): # {{{
description = 'Compile translations for ISO 639 codes'
DEST = os.path.join(os.path.dirname(POT.SRC), 'resources', 'localization',