[rkward-cvs] [rkward] /: Also make relevant fields of the <about>-section translatable.
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Sun Nov 23 18:07:16 UTC 2014
Git commit bb19dd0839a1e2c4f8730f8d2bf03c0768dfcb2d by Thomas Friedrichsmeier.
Committed on 23/11/2014 at 18:06.
Pushed by tfry into branch 'master'.
Also make relevant fields of the <about>-section translatable.
M +1 -0 ChangeLog
M +5 -5 rkward/plugin/rkcomponentmeta.cpp
M +20 -7 scripts/extract_plugin_messages.py
http://commits.kde.org/rkward/bb19dd0839a1e2c4f8730f8d2bf03c0768dfcb2d
diff --git a/ChangeLog b/ChangeLog
index b039618..21692f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Restructure layout of CSV-import dialog
- Allow to open (any number of) R script files and rkward://-urls from the command line
- Add command line option --reuse for reusing an existing instance of RKWard
- Be slightly(!) smarter about when to ask for saving workspace on workspace load (e.g. not directly after workspace has been saved)
diff --git a/rkward/plugin/rkcomponentmeta.cpp b/rkward/plugin/rkcomponentmeta.cpp
index 8b7f89f..de1b83e 100644
--- a/rkward/plugin/rkcomponentmeta.cpp
+++ b/rkward/plugin/rkcomponentmeta.cpp
@@ -35,22 +35,22 @@ RKComponentAboutData::RKComponentAboutData (const QDomElement& e, XMLHelper &xml
RK_TRACE (PLUGIN);
if (e.isNull ()) return;
- name = xml.getStringAttribute (e, "name", QString (), DL_INFO);
+ name = xml.i18nStringAttribute (e, "name", QString (), DL_INFO);
version = xml.getStringAttribute (e, "version", QString (), DL_INFO);
releasedate = xml.getStringAttribute (e, "releasedate", QString (), DL_INFO);
- shortinfo = xml.getStringAttribute (e, "shortinfo", QString (), DL_INFO);
+ shortinfo = xml.i18nStringAttribute (e, "shortinfo", QString (), DL_INFO);
copyright = xml.getStringAttribute (e, "copyright", QString (), DL_INFO);
license = xml.getStringAttribute (e, "license", QString (), DL_INFO);
url = xml.getStringAttribute (e, "url", QString (), DL_INFO);
- category = xml.getStringAttribute (e, "category", i18n ("Unspecified"), DL_INFO);
+ category = xml.i18nStringAttribute (e, "category", i18n ("Unspecified"), DL_INFO);
XMLChildList aes = xml.getChildElements (e, "author", DL_INFO);
for (int i = 0; i < aes.size (); ++i) {
QDomElement ae = aes[i];
RKComponentAuthor author;
- author.name = xml.getStringAttribute (ae, "name", QString (), DL_INFO);
+ author.name = xml.i18nStringAttribute (ae, "name", QString (), DL_INFO);
if (author.name.isEmpty ()) {
- author.name = xml.getStringAttribute (ae, "given", QString (), DL_WARNING) + " " + xml.getStringAttribute (ae, "family", QString (), DL_WARNING);
+ author.name = xml.i18nStringAttribute (ae, "given", QString (), DL_WARNING) + " " + xml.i18nStringAttribute (ae, "family", QString (), DL_WARNING);
}
if (author.name.isEmpty ()) xml.displayError (&ae, "No author name specified", DL_WARNING);
diff --git a/scripts/extract_plugin_messages.py b/scripts/extract_plugin_messages.py
index f0e2eb1..c94dcb7 100755
--- a/scripts/extract_plugin_messages.py
+++ b/scripts/extract_plugin_messages.py
@@ -10,6 +10,12 @@ from xml.dom import minidom
import HTMLParser
import copy
+attributes_to_extract_for_tag={
+ '*': { "attributes" : ['label', 'title', 'shorttitle'], "context": ''},
+ 'about': { "attributes" : ['name', 'shortinfo', 'category'], "context": ''},
+ 'author': { "attributes" : ['name', 'given', 'family'], "context": 'Author name'}
+}
+
def usage ():
print ("Usage: " + sys.argv[0] + " [--default_po=PO_ID] [--outdir=DIR] files")
exit (1)
@@ -51,10 +57,10 @@ def parseFile (filename):
# Where available, include the labels of parent elements. Particularly helpful for radio-options
def getElementShort (element, dot_attribute=""):
ret = "<" + element.tagName
- for attr in ["label", "title"]:
- if (attr == dot_attribute):
- ret += " " + attr + "=\"...\""
- else:
+ if (dot_attribute != ""):
+ ret += " " + dot_attribute + "=\"...\""
+ else:
+ for attr in ["label", "title"]:
if (element.hasAttribute (attr)):
ret += " " + attr + "=" + quote (element.getAttribute (attr))
return ret + ">"
@@ -124,14 +130,21 @@ def getI18nComment (node, attribute=""):
# Main workhorse: Look at given node and recurse into children
def handleNode (node):
if (node.nodeType == node.ELEMENT_NODE):
- for attr in ["label", "title", "shorttitle"]:
+ attributes = attributes_to_extract_for_tag['*']['attributes']
+ context = attributes_to_extract_for_tag['*']['context']
+ if (node.tagName in attributes_to_extract_for_tag):
+ attributes = attributes + attributes_to_extract_for_tag[node.tagName]['attributes']
+ context = attributes_to_extract_for_tag[node.tagName]['context']
+ for attr in attributes:
if (node.hasAttribute (attr)):
attrv = node.getAttribute (attr)
if (attrv == ""):
continue
outfile.write (getI18nComment (node, attr))
if (node.hasAttribute ("i18n_context")):
- outfile.write ("i18nc (" + quote (node.getAttribute ("i18n_context")) + ", " + quote (attrv) + ");\n")
+ context = node.getAttribute ("i18n_context")
+ if (context != ''):
+ outfile.write ("i18nc (" + quote (context) + ", " + quote (attrv) + ");\n")
else:
outfile.write ("i18n (" + quote (attrv) + ");\n")
if (node.hasAttribute ("file")):
@@ -413,7 +426,7 @@ for potcpp in initialized_pot_files:
# NOTE: using --no-location, as that just adds meaningless references to the temporary .pot.cpp-file.
res = subprocess.call (["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", "--no-location", "--msgid-bugs-address=" + BUGADDR, "-o", "finalpotfile", potcppfile])
+ "-kki18ncp:1c,2,3", "--no-location", "--msgid-bugs-address=" + BUGADDR, "-o", finalpotfile, potcppfile])
if (res):
sys.stderr.write ("calling xgettext failed with exit code " + res)
os.remove (potcppfile)
More information about the rkward-tracker
mailing list