From fc9a7d08ca2bf51a71b33da0de3ec9f3b29fe339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Mon, 12 Mar 2012 10:21:30 +0000 Subject: [PATCH] 5621: test for retrieving translated strings (extract glade, xml headers) svn: r19047 --- babel.cfg | 8 ++-- setup.cfg | 12 +++--- setup.py | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 117 insertions(+), 14 deletions(-) diff --git a/babel.cfg b/babel.cfg index f8a98d8c6..9ea68e064 100644 --- a/babel.cfg +++ b/babel.cfg @@ -1,8 +1,8 @@ [python: src/**.py] encoding = utf-8 -#[glade: src/**.glade] -#encoding = utf-8 +[glade: src/**.h] +encoding = utf-8 #extractor = babelglade.extractor #[xml: data/**.desktop] @@ -11,8 +11,8 @@ encoding = utf-8 #[xml: data/**.keys] #encoding = utf-8 -#[xml: data/**.xml] -#encoding = utf-8 +[xml: **.xml.h] +encoding = utf-8 #[xml: src/**.xml] #encoding = utf-8 diff --git a/setup.cfg b/setup.cfg index 7e468b029..9d3e01d2b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,15 +23,15 @@ doc_files = README INSTALL COPYING NEWS FAQ TODO #install-script = [extract_messages] -keywords = _, N_, gettext, ngettext, sgettext -mapping_file = babel.cfg -width = 80 -output_file = po/messages.pot -input-dirs = . +#keywords = _, N_, gettext, ngettext, sgettext +#mapping_file = babel.cfg +#width = 80 +#output_file = po/messages.pot +#input-dirs = . [update_catalog] output_dir = po -input_file = po/messages.pot +input_file = po/.pot [compile_catalog] #domain = gramps diff --git a/setup.py b/setup.py index 4e938909b..44703ffc1 100644 --- a/setup.py +++ b/setup.py @@ -236,7 +236,82 @@ def os_files(): ('share/doc/gramps', ['TODO']) ] return files - + +def glade(): + + #POTFILE.in + files = [ + 'src/plugins/docgen/gtkprint.glade', + 'src/glade/editperson.glade', + 'src/glade/grampletpane.glade', + 'src/glade/baseselector.glade', + 'src/glade/reorder.glade', + 'src/glade/tipofday.glade', + 'src/glade/displaystate.glade', + 'src/glade/addmedia.glade', + 'src/glade/questiondialog.glade', + 'src/glade/configure.glade', + 'src/glade/dateedit.glade', + 'src/glade/editsource.glade', + 'src/glade/styleeditor.glade', + 'src/glade/dbman.glade', + 'src/glade/editcitation.glade', + 'src/glade/editurl.glade', + 'src/glade/editrepository.glade', + 'src/glade/editreporef.glade', + 'src/glade/editpersonref.glade', + 'src/glade/editlocation.glade', + 'src/glade/editlink.glade', + 'src/glade/editfamily.glade', + 'src/glade/editchildref.glade', + 'src/glade/editattribute.glade', + 'src/glade/editaddress.glade', + 'src/glade/editmedia.glade', + 'src/glade/editmediaref.glade', + 'src/glade/editeventref.glade', + 'src/glade/editldsord.glade', + 'src/glade/editnote.glade', + 'src/glade/editplace.glade', + 'src/glade/editsourceref.glade', + 'src/glade/editname.glade', + 'src/glade/editevent.glade', + 'src/glade/mergecitation.glade', + 'src/glade/mergedata.glade', + 'src/glade/mergeevent.glade', + 'src/glade/mergefamily.glade', + 'src/glade/mergemedia.glade', + 'src/glade/mergenote.glade', + 'src/glade/mergeperson.glade', + 'src/glade/mergeplace.glade', + 'src/glade/mergerepository.glade', + 'src/glade/mergesource.glade', + 'src/glade/plugins.glade', + 'src/glade/rule.glade', + 'src/glade/scratchpad.glade', + 'src/glade/papermenu.glade', + 'src/glade/updateaddons.glade', + 'src/plugins/tool/notrelated.glade', + 'src/plugins/bookreport.glade', + 'src/plugins/tool/changenames.glade', + 'src/plugins/tool/changetypes.glade', + 'src/plugins/tool/desbrowser.glade', + 'src/plugins/tool/eval.glade', + 'src/plugins/tool/eventcmp.glade', + 'src/plugins/tool/leak.glade', + 'src/plugins/tool/finddupes.glade', + 'src/plugins/tool/mergecitations.glade', + 'src/plugins/tool/ownereditor.glade', + 'src/plugins/tool/patchnames.glade', + 'src/plugins/tool/phpgedview.glade', + 'src/plugins/tool/relcalc.glade', + 'src/plugins/tool/soundgen.glade', + 'src/plugins/tool/removeunused.glade', + 'src/plugins/tool/verify.glade', + 'src/plugins/import/importgedcom.glade' + ] + + return files + class CompileCatalog(): ''' @@ -248,11 +323,39 @@ class CompileCatalog(): def initialize_options(self): pass - def run (self): + def run(self): pass - def finalize_options (self): + def finalize_options(self): pass + +class ExtractMessages(Command): + ''' + Mixture between babel class and custom extraction + ''' + + user_options = [('fake', None, 'Override')] + + def initialize_options(self): + for f in glade(): + os.system('''intltool-extract --type=gettext/glade %s''' % f) + os.system('''intltool-extract --type=gettext/xml src/data/tips.xml.in''') + os.system('''intltool-extract --type=gettext/xml data/gramps.xml.in''') + #os.system('''intltool-extract --type=gettext/text data/gramps.desktop.in''') + #os.system('''intltool-extract --type=gettext/text data/gramps.keys.in''') + + def run(self): + + #babel.extract_messages + pass + + def finalize_options(self): + os.system('''xgettext -j --keyword=N_ --from-code=UTF-8''' + ''' -o "po/gramps.pot" ''' + '''src/*/*.glade.h''') + os.system('''xgettext -j --keyword=_ --keyword=N_''' + ''' -o "po/gramps.pot" ''' + '''*/*/*.xml.h''') def trans_files(): ''' @@ -444,6 +547,6 @@ result = setup( 'install_data': InstallData, 'uninstall': Uninstall, 'compile_catalog': babel.compile_catalog, - 'extract_messages': babel.extract_messages, + 'extract_messages': ExtractMessages, 'update_catalog': babel.update_catalog}, )