[rkward-cvs] SF.net SVN: rkward-code:[4950] trunk/rkward
tfry at users.sf.net
tfry at users.sf.net
Fri Oct 24 21:00:26 UTC 2014
Revision: 4950
http://sourceforge.net/p/rkward/code/4950
Author: tfry
Date: 2014-10-24 21:00:24 +0000 (Fri, 24 Oct 2014)
Log Message:
-----------
Integrate plugin message extraction into Messages.sh (for testing purposes, extract only one pluginmap, for now)
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/po/Messages.sh
trunk/rkward/po/rkward.pot
trunk/rkward/scripts/extract_plugin_messages.py
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2014-10-24 18:04:35 UTC (rev 4949)
+++ trunk/rkward/ChangeLog 2014-10-24 21:00:24 UTC (rev 4950)
@@ -5,6 +5,7 @@
- Is it a problem to sync KDE_LANG and LANGUAGE? Should that also be set for the backend?
- Message extraction: Should we do this in R, using XiMpLe? That might allow us to give better context / comments
- Don't forget to write documentation
+ - What should be the policy regarding installing translations (80% criterion)
--- Version 0.6.2 - Oct-20-2014
- In data editor, indicate NAs, explicitly
Modified: trunk/rkward/po/Messages.sh
===================================================================
--- trunk/rkward/po/Messages.sh 2014-10-24 18:04:35 UTC (rev 4949)
+++ trunk/rkward/po/Messages.sh 2014-10-24 21:00:24 UTC (rev 4950)
@@ -58,3 +58,9 @@
rm infiles.list
rm rc.cpp
echo "Done"
+
+echo "Extracting messages from plugins"
+cd ${BASEDIR}
+# For testing purposes, extract analysis.pluginmap, only
+python ../scripts/extract_plugin_messages.py --outdir=../po/plugins/ plugins/analysis.pluginmap
+echo "Done"
Modified: trunk/rkward/po/rkward.pot
===================================================================
--- trunk/rkward/po/rkward.pot 2014-10-24 18:04:35 UTC (rev 4949)
+++ trunk/rkward/po/rkward.pot 2014-10-24 21:00:24 UTC (rev 4950)
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://p.sf.net/rkward/bugs\n"
-"POT-Creation-Date: 2014-10-24 11:47+0200\n"
+"POT-Creation-Date: 2014-10-24 22:58+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
Modified: trunk/rkward/scripts/extract_plugin_messages.py
===================================================================
--- trunk/rkward/scripts/extract_plugin_messages.py 2014-10-24 18:04:35 UTC (rev 4949)
+++ trunk/rkward/scripts/extract_plugin_messages.py 2014-10-24 21:00:24 UTC (rev 4950)
@@ -9,16 +9,33 @@
from xml.dom import minidom
import copy
+def usage ():
+ print ("Usage: " + sys.argv[0] + " [--default_po=PO_ID] [--outdir=DIR] files")
+ exit (1)
+
# list of tag-names the content of which to extract in full (including, possibly, HTML-tags, within)
text_containers = ['section', 'text', 'related', 'title', 'summary', 'usage', 'technical', 'setting']
+# initialize globals, and parse args
+infile = {"infile": "", "file_prefix": "", "caption": ""}
+default_po = ""
outfile = ""
+outdir = ""
initialized_pot_files = []
current_po_id = ""
-toplevel_sources = list (sys.argv[1:])
+toplevel_sources = []
+for arg in (list (sys.argv[1:])):
+ if (arg.startswith ("--default_po=")):
+ default_po = arg.split ("=", 1)[1]
+ elif (arg.startswith ("--outdir=")):
+ outdir = arg.split ("=", 1)[1]
+ elif (arg.startswith ("--")):
+ usage ()
+ else:
+ toplevel_sources.append (arg)
+if (len (toplevel_sources) < 1):
+ usage ()
-infile = {"infile": "", "file_prefix": "", "caption": ""}
-
tag_stack = []
def backtrace ():
ret = infile["infile"]
@@ -142,25 +159,29 @@
else:
initialized_pot_files.append (current_po_id)
mode = 'w'
- outfile = codecs.open (po_id + '.pot.cpp', mode, 'utf-8')
+ outfile = codecs.open (os.path.join (outdir, po_id + '.pot.cpp'), mode, 'utf-8')
#######
# Loop over toplevel_sources (specified on command line, or those that want to be split into separate po) and extract messages
# NOTE: toplevel_sources may grow, dynamically, but only at the end.
i = 0
-print toplevel_sources
while i < len (toplevel_sources):
xmldoc = minidom.parse (toplevel_sources[i])
- if (not xmldoc.documentElement.hasAttribute ("po_id")):
- sys.stderr.write ("No po_id attribute on file " + toplevel_sources[i])
+ po_id = xmldoc.documentElement.getAttribute ("po_id")
+ if (po_id == ""):
+ po_id = default_po
+ if (po_id == ""):
+ sys.stderr.write ("No po_id attribute on file " + toplevel_sources[i] + " and no default specified\n")
continue
- initialize_pot_file (xmldoc.documentElement.getAttribute ("po_id"))
+ initialize_pot_file (po_id)
handleSubFile (toplevel_sources[i]) # Some duplication of parsing, instead of duplication of code
i += 1
#######
# Run xgettext on all generated .pot.cpp files
for potcpp in initialized_pot_files:
+ potcppfile = os.path.join (outdir, potcpp + ".pot.cpp")
os.system ("xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 " +
"-kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 " +
- "--msgid-bugs-address=" + BUGADDR + " -o " + potcpp + ".pot " + potcpp + ".pot.cpp")
+ "--msgid-bugs-address=" + BUGADDR + " -o " + os.path.join (outdir, "rkward__" + potcpp + ".pot ") + potcppfile)
+ os.remove (potcppfile)
More information about the rkward-tracker
mailing list