[rkward-cvs] [rkward] /: As an afterthought: Make it easy to manage translations directly in the plugin's directory (for external plugins)
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Nov 24 19:28:22 UTC 2014
Git commit 346c4ad2c6b63765989ef6e6ae1e45391aa0fbb1 by Thomas Friedrichsmeier.
Committed on 24/11/2014 at 19:26.
Pushed by tfry into branch 'master'.
As an afterthought: Make it easy to manage translations directly in the plugin's directory (for external plugins)
M +2 -0 .gitignore
M +17 -8 scripts/update_plugin_messages.py
http://commits.kde.org/rkward/346c4ad2c6b63765989ef6e6ae1e45391aa0fbb1
diff --git a/.gitignore b/.gitignore
index da07d4b..9dfb210 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
# These often present in developer's system
.kdev4/
build/
+# Locally extracted / installed plugin messages
+rkward/plugins/po/
# Generated from cmake
rkward/resource.ver
rkward/version.h
diff --git a/scripts/update_plugin_messages.py b/scripts/update_plugin_messages.py
index 11bbd5f..d408477 100755
--- a/scripts/update_plugin_messages.py
+++ b/scripts/update_plugin_messages.py
@@ -438,7 +438,12 @@ def initialize_pot_file (po_id, po_loc):
initialized_pot_files.append (current_po_id)
po_file_install_locations[current_po_id] = po_loc
mode = 'w'
- outfile = codecs.open (os.path.join (outdir, po_id + '.pot.cpp'), mode, 'utf-8')
+ p_outdir = outdir
+ if (p_outdir == ""):
+ p_outdir = po_file_install_locations[po_id]
+ if (not os.path.exists (p_outdir)):
+ os.makedirs (p_outdir, 0755)
+ outfile = codecs.open (os.path.join (p_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
@@ -462,9 +467,12 @@ while i < len (toplevel_sources):
#######
# Run xgettext on all generated .pot.cpp files, and - unless --extract-only - merge, compile, install
for po_id in initialized_pot_files:
- potcppfile = os.path.join (outdir, po_id + ".pot.cpp")
+ p_outdir = outdir
+ if (p_outdir == ""):
+ p_outdir = po_file_install_locations[po_id]
+ potcppfile = os.path.join (p_outdir, po_id + ".pot.cpp")
templatename = "rkward__" + po_id
- finalpotfile = os.path.join (outdir, templatename + ".pot")
+ finalpotfile = os.path.join (p_outdir, templatename + ".pot")
# NOTE: using --no-location, as that just adds meaningless references to the temporary .pot.cpp-file.
res = subprocess.call (XGETTEXT_CALL.split () + ["--no-location", "-o", finalpotfile, potcppfile])
if (res):
@@ -473,9 +481,9 @@ for po_id in initialized_pot_files:
if (not do_merge_install):
continue
# merge existing translations
- transfiles = os.listdir (os.path.join (outdir))
+ transfiles = os.listdir (os.path.join (p_outdir))
for trans in transfiles:
- abstrans = os.path.join (outdir, trans)
+ abstrans = os.path.join (p_outdir, trans)
# is it really a translation file?
if (trans.startswith (templatename + ".") and trans.endswith (".po") and ((len (templatename) + 6) >= len (trans) <= (len (templatename) + 7))):
lang = trans.split ('.')[-2]
@@ -485,8 +493,9 @@ for po_id in initialized_pot_files:
else:
os.remove (abstrans)
os.rename (abstrans + ".new", abstrans)
- outdir = os.path.join (po_file_install_locations[po_id], lang, "MESSAGES")
- os.makedirs (outdir, 0755)
- res = subprocess.call (MSGFMT.split () + [abstrans, "-o", os.path.join (outdir, templatename + ".mo")])
+ m_outdir = os.path.join (po_file_install_locations[po_id], lang, "MESSAGES")
+ if (not os.path.exists (m_outdir)):
+ os.makedirs (m_outdir, 0755)
+ res = subprocess.call (MSGFMT.split () + [abstrans, "-o", os.path.join (m_outdir, templatename + ".mo")])
if (res):
sys.stderr.write ("calling msgfmt on " + abstrans + " failed with exit code " + str (res))
More information about the rkward-tracker
mailing list