1) Keep manual translations in lib/layouttranslations

2) Fix ia translations (for some reason it was a copy of it)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38031 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-03-24 21:21:12 +00:00
parent 276596105f
commit b6262f5865
2 changed files with 96 additions and 52 deletions

View File

@ -1,6 +1,6 @@
# This file has been automatically generated by po/lyx_pot.py. # This file has been automatically generated by po/lyx_pot.py.
# PLEASE DO NOT MODIFY ANYTHING HERE! If you want to regenerate this file # PLEASE MODIFY ONLY THE LAGUAGES HAVING NO .po FILE! If you want to regenerate
# from the translations, run `make ../lib/layouttranslations' in po. # this file from the translations, run `make ../lib/layouttranslations' in po.
Translation ar Translation ar
"Algorithm" "الخوارزم" "Algorithm" "الخوارزم"
@ -474,45 +474,38 @@ Translation hu
End End
Translation ia Translation ia
"Acknowledgement" "Riconoscimento" "Acknowledgement" "Recognoscentia"
"Algorithm" "Algoritmo" "Algorithm" "Algorithmo"
"Assumption" "Assunzione" "Axiom" "Axioma"
"Axiom" "Assioma"
"Case" "Caso" "Case" "Caso"
"Chart" "Diagramma" "Chart" "Diagramma"
"Claim" "Asserzione" "Claim" "Assertion"
"Conclusion" "Conclusione" "Conjecture" "Conjectura"
"Condition" "Condizione"
"Conjecture" "Congettura"
"Corollary" "Corollario" "Corollary" "Corollario"
"Criterion" "Criterio" "Criterion" "Criterio"
"Definition" "Definizione" "Example" "Exemplo"
"Example" "Esempio" "Exercise" "Exercitio"
"Exercise" "Esercizio" "Fact" "Facto"
"Fact" "Fatto"
"Figure" "Figura" "Figure" "Figura"
"Graph" "Grafico" "Graph" "Graphico"
"List of Algorithms" "Elenco degli algoritmi|a" "List of Algorithms" "Lista del algorithmos"
"List of Charts" "Elenco dei diagrammi" "List of Charts" "Lista de diagrammas"
"List of Figures" "Elenco delle figure" "List of Figures" "Lista de figuras"
"List of Graphs" "Elenco dei grafici" "List of Graphs" "Lista de graphicos"
"List of Schemes" "Elenco degli schemi" "List of Schemes" "Lista de schemas"
"List of Tableaux" "Elenco dei tableau" "List of Tableaux" "Lista de tableau"
"List of Tables" "Elenco delle tabelle" "List of Tables" "Lista de tabellas"
"MarginFigure" "Figura a margine" "MarginFigure" "Figura a margine"
"MarginTable" "Tabella a margine" "MarginTable" "Tabella a margine"
"Notation" "Notazione"
"Note" "Nota" "Note" "Nota"
"Plate" "Foglio" "Plate" "Folio"
"Problem" "Problema" "Problem" "Problema"
"Proof" "Dimostrazione" "Proof" "Demonstration"
"Proposition" "Proposizione" "Remark" "Observation"
"Question" "Questione"
"Remark" "Osservazione"
"Scheme" "Schema" "Scheme" "Schema"
"Summary" "Sommario" "Summary" "Summario"
"Table" "Tabella" "Table" "Tabella"
"Theorem" "Teorema" "Theorem" "Theorema"
End End
Translation id Translation id

View File

@ -78,7 +78,6 @@ def ui_l10n(input_files, output, base):
def layouts_l10n(input_files, output, base, layouttranslations): def layouts_l10n(input_files, output, base, layouttranslations):
'''Generate pot file from lib/layouts/*.{layout,inc,module}''' '''Generate pot file from lib/layouts/*.{layout,inc,module}'''
out = open(output, 'w')
Style = re.compile(r'^Style\s+(.*)', re.IGNORECASE) Style = re.compile(r'^Style\s+(.*)', re.IGNORECASE)
# include ???LabelString???, but exclude comment lines # include ???LabelString???, but exclude comment lines
LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)') LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)')
@ -100,19 +99,61 @@ def layouts_l10n(input_files, output, base, layouttranslations):
Float = re.compile(r'\s*Float') Float = re.compile(r'\s*Float')
End = re.compile(r'\s*End') End = re.compile(r'\s*End')
Comment = re.compile(r'\s*#') Comment = re.compile(r'\s*#')
Translation = re.compile(r'\s*Translation\s+(.*)\s*$')
KeyValPair = re.compile(r'\s*"(.*)"\s+"(.*)"')
oldlanguages = []
languages = [] languages = []
keyset = set() keyset = set()
oldtrans = dict()
if layouttranslations: if layouttranslations:
linguas_file = os.path.join(base, 'po/LINGUAS') linguas_file = os.path.join(base, 'po/LINGUAS')
for line in open(linguas_file).readlines(): for line in open(linguas_file).readlines():
if Comment.search(line) == None: if Comment.search(line) == None:
languages.extend(line.split()) languages.extend(line.split())
# read old translations if available
try:
input = open(output)
lang = ''
for line in input.readlines():
res = Comment.search(line)
if res:
continue
if line.strip() == '':
continue
res = Translation.search(line)
if res:
lang = res.group(1)
if lang not in languages:
oldlanguages.append(lang)
languages.append(lang)
oldtrans[lang] = dict()
continue
res = End.search(line)
if res:
lang = ''
continue
res = KeyValPair.search(line)
if res and lang != '':
key = res.group(1).decode('utf-8')
val = res.group(2).decode('utf-8')
key = key.replace('\\"', '"').replace('\\\\', '\\')
val = val.replace('\\"', '"').replace('\\\\', '\\')
oldtrans[lang][key] = val
keyset.add(key)
continue
print "Error: Unable to handle line:"
print line
except IOError:
pass
# walon is not a known document language # walon is not a known document language
# FIXME: Do not hardcode, read from lib/languages! # FIXME: Do not hardcode, read from lib/languages!
if 'wa' in languages: if 'wa' in languages:
languages.remove('wa') languages.remove('wa')
out = open(output, 'w')
for src in input_files: for src in input_files:
readingDescription = False readingDescription = False
readingI18nPreamble = False readingI18nPreamble = False
@ -253,29 +294,39 @@ def layouts_l10n(input_files, output, base, layouttranslations):
keys.sort() keys.sort()
print >> out, '''# This file has been automatically generated by po/lyx_pot.py. print >> out, '''# This file has been automatically generated by po/lyx_pot.py.
# PLEASE DO NOT MODIFY ANYTHING HERE! If you want to regenerate this file # PLEASE MODIFY ONLY THE LAGUAGES HAVING NO .po FILE! If you want to regenerate
# from the translations, run `make ../lib/layouttranslations' in po.''' # this file from the translations, run `make ../lib/layouttranslations' in po.'''
for lang in languages: for lang in languages:
print >> out, '\nTranslation %s' % lang print >> out, '\nTranslation %s' % lang
if lang in oldtrans.keys():
trans = oldtrans[lang]
else:
trans = dict()
if not lang in oldlanguages:
poname = os.path.join(base, 'po/' + lang + '.po') poname = os.path.join(base, 'po/' + lang + '.po')
po = polib.pofile(poname) po = polib.pofile(poname)
# Iterate through po entries and not keys for speed reasons. # Iterate through po entries and not keys for speed reasons.
# FIXME: The code is still too slow # FIXME: The code is still too slow
trans = dict()
for entry in po: for entry in po:
if not entry.translated(): if not entry.translated():
continue continue
if entry.msgid in keys: if entry.msgid in keys:
key = entry.msgid.replace('\\', '\\\\').replace('"', '\\"') key = entry.msgid
val = entry.msgstr.replace('\\', '\\\\').replace('"', '\\"') val = entry.msgstr
# some translators keep untranslated entries # some translators keep untranslated entries
if val != key: if val != key:
trans[key] = val trans[key] = val
for key in keys: for key in keys:
if key in trans.keys(): if key in trans.keys():
val = trans[key] val = trans[key].replace('\\', '\\\\').replace('"', '\\"')
key = key.replace('\\', '\\\\').replace('"', '\\"')
print >> out, '\t"%s" "%s"' % \ print >> out, '\t"%s" "%s"' % \
(key.encode('utf-8'), val.encode('utf-8')) (key.encode('utf-8'), val.encode('utf-8'))
# to print untranslated entries, uncomment the following lines
#else:
# key = key.replace('\\', '\\\\').replace('"', '\\"')
# print >> out, '\t"%s" "%s"' % \
# (key.encode('utf-8'), key.encode('utf-8'))
print >> out, 'End' print >> out, 'End'
out.close() out.close()