From b6262f58658394b88828d1f44c2c056040f35b91 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Thu, 24 Mar 2011 21:21:12 +0000 Subject: [PATCH] 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 --- lib/layouttranslations | 53 ++++++++++------------- po/lyx_pot.py | 95 ++++++++++++++++++++++++++++++++---------- 2 files changed, 96 insertions(+), 52 deletions(-) diff --git a/lib/layouttranslations b/lib/layouttranslations index d7f5599cf4..eabfeced00 100644 --- a/lib/layouttranslations +++ b/lib/layouttranslations @@ -1,6 +1,6 @@ # This file has been automatically generated by po/lyx_pot.py. -# PLEASE DO NOT MODIFY ANYTHING HERE! If you want to regenerate this file -# from the translations, run `make ../lib/layouttranslations' in po. +# PLEASE MODIFY ONLY THE LAGUAGES HAVING NO .po FILE! If you want to regenerate +# this file from the translations, run `make ../lib/layouttranslations' in po. Translation ar "Algorithm" "الخوارزم" @@ -474,45 +474,38 @@ Translation hu End Translation ia - "Acknowledgement" "Riconoscimento" - "Algorithm" "Algoritmo" - "Assumption" "Assunzione" - "Axiom" "Assioma" + "Acknowledgement" "Recognoscentia" + "Algorithm" "Algorithmo" + "Axiom" "Axioma" "Case" "Caso" "Chart" "Diagramma" - "Claim" "Asserzione" - "Conclusion" "Conclusione" - "Condition" "Condizione" - "Conjecture" "Congettura" + "Claim" "Assertion" + "Conjecture" "Conjectura" "Corollary" "Corollario" "Criterion" "Criterio" - "Definition" "Definizione" - "Example" "Esempio" - "Exercise" "Esercizio" - "Fact" "Fatto" + "Example" "Exemplo" + "Exercise" "Exercitio" + "Fact" "Facto" "Figure" "Figura" - "Graph" "Grafico" - "List of Algorithms" "Elenco degli algoritmi|a" - "List of Charts" "Elenco dei diagrammi" - "List of Figures" "Elenco delle figure" - "List of Graphs" "Elenco dei grafici" - "List of Schemes" "Elenco degli schemi" - "List of Tableaux" "Elenco dei tableau" - "List of Tables" "Elenco delle tabelle" + "Graph" "Graphico" + "List of Algorithms" "Lista del algorithmos" + "List of Charts" "Lista de diagrammas" + "List of Figures" "Lista de figuras" + "List of Graphs" "Lista de graphicos" + "List of Schemes" "Lista de schemas" + "List of Tableaux" "Lista de tableau" + "List of Tables" "Lista de tabellas" "MarginFigure" "Figura a margine" "MarginTable" "Tabella a margine" - "Notation" "Notazione" "Note" "Nota" - "Plate" "Foglio" + "Plate" "Folio" "Problem" "Problema" - "Proof" "Dimostrazione" - "Proposition" "Proposizione" - "Question" "Questione" - "Remark" "Osservazione" + "Proof" "Demonstration" + "Remark" "Observation" "Scheme" "Schema" - "Summary" "Sommario" + "Summary" "Summario" "Table" "Tabella" - "Theorem" "Teorema" + "Theorem" "Theorema" End Translation id diff --git a/po/lyx_pot.py b/po/lyx_pot.py index 3ac835d409..bf700e1e98 100755 --- a/po/lyx_pot.py +++ b/po/lyx_pot.py @@ -78,7 +78,6 @@ def ui_l10n(input_files, output, base): def layouts_l10n(input_files, output, base, layouttranslations): '''Generate pot file from lib/layouts/*.{layout,inc,module}''' - out = open(output, 'w') Style = re.compile(r'^Style\s+(.*)', re.IGNORECASE) # include ???LabelString???, but exclude comment lines 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') End = re.compile(r'\s*End') Comment = re.compile(r'\s*#') + Translation = re.compile(r'\s*Translation\s+(.*)\s*$') + KeyValPair = re.compile(r'\s*"(.*)"\s+"(.*)"') + oldlanguages = [] languages = [] keyset = set() + oldtrans = dict() if layouttranslations: linguas_file = os.path.join(base, 'po/LINGUAS') for line in open(linguas_file).readlines(): if Comment.search(line) == None: languages.extend(line.split()) - # walon is not a known document language - # FIXME: Do not hardcode, read from lib/languages! - if 'wa' in languages: - languages.remove('wa') + # 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 + # FIXME: Do not hardcode, read from lib/languages! + if 'wa' in languages: + languages.remove('wa') + + out = open(output, 'w') for src in input_files: readingDescription = False readingI18nPreamble = False @@ -253,29 +294,39 @@ def layouts_l10n(input_files, output, base, layouttranslations): keys.sort() 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 -# from the translations, run `make ../lib/layouttranslations' in po.''' +# PLEASE MODIFY ONLY THE LAGUAGES HAVING NO .po FILE! If you want to regenerate +# this file from the translations, run `make ../lib/layouttranslations' in po.''' for lang in languages: print >> out, '\nTranslation %s' % lang - poname = os.path.join(base, 'po/' + lang + '.po') - po = polib.pofile(poname) - # Iterate through po entries and not keys for speed reasons. - # FIXME: The code is still too slow - trans = dict() - for entry in po: - if not entry.translated(): - continue - if entry.msgid in keys: - key = entry.msgid.replace('\\', '\\\\').replace('"', '\\"') - val = entry.msgstr.replace('\\', '\\\\').replace('"', '\\"') - # some translators keep untranslated entries - if val != key: - trans[key] = val + if lang in oldtrans.keys(): + trans = oldtrans[lang] + else: + trans = dict() + if not lang in oldlanguages: + poname = os.path.join(base, 'po/' + lang + '.po') + po = polib.pofile(poname) + # Iterate through po entries and not keys for speed reasons. + # FIXME: The code is still too slow + for entry in po: + if not entry.translated(): + continue + if entry.msgid in keys: + key = entry.msgid + val = entry.msgstr + # some translators keep untranslated entries + if val != key: + trans[key] = val for key in keys: if key in trans.keys(): - val = trans[key] + val = trans[key].replace('\\', '\\\\').replace('"', '\\"') + key = key.replace('\\', '\\\\').replace('"', '\\"') print >> out, '\t"%s" "%s"' % \ (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' out.close() -- 2.39.5