[rkward-cvs] SF.net SVN: rkward-code:[4959] trunk/rkward

tfry at users.sf.net tfry at users.sf.net
Sun Oct 26 18:35:43 UTC 2014


Revision: 4959
          http://sourceforge.net/p/rkward/code/4959
Author:   tfry
Date:     2014-10-26 18:35:42 +0000 (Sun, 26 Oct 2014)
Log Message:
-----------
Start adjusting the code to actually look up translations, where appropriate

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
    trunk/rkward/rkward/plugin/rkcheckbox.cpp
    trunk/rkward/rkward/plugin/rkcomponentmap.cpp
    trunk/rkward/rkward/plugin/rkdropdown.cpp
    trunk/rkward/rkward/plugin/rkformula.cpp
    trunk/rkward/rkward/plugin/rkinput.cpp
    trunk/rkward/rkward/plugin/rkmatrixinput.cpp
    trunk/rkward/rkward/plugin/rkoptionset.cpp
    trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
    trunk/rkward/rkward/plugin/rkpluginframe.cpp
    trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp
    trunk/rkward/rkward/plugin/rkpluginspinbox.cpp
    trunk/rkward/rkward/plugin/rkpreviewbox.cpp
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugin/rktabpage.cpp
    trunk/rkward/rkward/plugin/rkvalueselector.cpp
    trunk/rkward/rkward/plugin/rkvarslot.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/scripts/extract_plugin_messages.py

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/ChangeLog	2014-10-26 18:35:42 UTC (rev 4959)
@@ -7,6 +7,12 @@
     - Don't forget to write documentation
     - What should be the policy regarding installing translations (80% criterion)
     - Where should the extraction script look for i18n comments (before element, within element)?
+    - discuss i18n_context vs. comments
+    - Important pitfalls: String comparison with checkbox / radio labels! (Definitely wrong in some plugins)
+   - i18n calls
+    - wcgrep getStringAttribute.*i18n
+    - is <caption title="XYZ"> used, anywhere?
+    - element text
 
 --- Version 0.6.2 - Oct-20-2014
 - In data editor, indicate NAs, explicitly

Modified: trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -52,9 +52,9 @@
 	int selected = 0;
 	int i = 0;
 	for (XMLChildList::const_iterator it = option_elements.begin (); it != option_elements.end (); ++it) {
-		QString label = xml->getStringAttribute (*it, "label", QString::null, DL_ERROR);
-		QString value = xml->getStringAttribute (*it, "value", QString::null, DL_WARNING);
-		QString name = xml->getStringAttribute (*it, "id", QString::null, DL_INFO);
+		QString label = xml->i18nStringAttribute (*it, "label", QString (), DL_ERROR);
+		QString value = xml->getStringAttribute (*it, "value", QString (), DL_WARNING);
+		QString name = xml->getStringAttribute (*it, "id", QString (), DL_INFO);
 
 		Option *opt = new Option;
 		opt->value = value;

Modified: trunk/rkward/rkward/plugin/rkcheckbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcheckbox.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkcheckbox.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -36,7 +36,7 @@
 	// create checkbox
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
-	checkbox = new QCheckBox (xml->getStringAttribute (element, "label", QString::null, DL_WARNING), this);
+	checkbox = new QCheckBox (xml->i18nStringAttribute (element, "label", QString (), DL_WARNING), this);
 	vbox->addWidget (checkbox);
 	checkbox->setChecked (xml->getBoolAttribute (element, "checked", false, DL_INFO));
 	connect (checkbox, SIGNAL (stateChanged (int)), this, SLOT (changedState (int)));

Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -111,7 +111,7 @@
 	int counter = 0;
 
 	// 1: check whether menu already exists, and create new menu otherwise
-	QDomElement menu_element = findOrCreateElement (parent, xml, "Menu", xml.getStringAttribute (description, "id", "none", DL_ERROR), xml.getStringAttribute (description, "label", i18n ("(no label)"), DL_WARNING), xml.getIntAttribute (description, "index", -1, DL_INFO));
+	QDomElement menu_element = findOrCreateElement (parent, xml, "Menu", xml.getStringAttribute (description, "id", "none", DL_ERROR), xml.i18nStringAttribute (description, "label", i18n ("(no label)"), DL_WARNING), xml.getIntAttribute (description, "index", -1, DL_INFO));
 
 	// 2: recurse into submenus (of element to add!)
 	XMLChildList list = xml.getChildElements (description, "menu", DL_INFO);
@@ -476,7 +476,7 @@
 			RKComponentHandle *handle = new RKComponentHandle (pluginmap_file_desc, filename, label, (RKComponentType) type);
 			XMLChildList attributes_list = xml.getChildElements (*it, "attribute", DL_DEBUG);
 			for (XMLChildList::const_iterator ait=attributes_list.begin (); ait != attributes_list.end (); ++ait) {
-				handle->addAttribute (xml.getStringAttribute (*ait, "id", "noid", DL_WARNING), xml.getStringAttribute (*ait, "value", QString (), DL_ERROR), xml.getStringAttribute (*ait, "label", QString (), DL_ERROR));
+				handle->addAttribute (xml.getStringAttribute (*ait, "id", "noid", DL_WARNING), xml.getStringAttribute (*ait, "value", QString (), DL_ERROR), xml.i18nStringAttribute (*ait, "label", QString (), DL_ERROR));
 			}
 			if (!cdependencies.isNull ()) handle->addDependencies (RKComponentDependency::parseDependencies (cdependencies, xml));
 			components.insert (id, handle);

Modified: trunk/rkward/rkward/plugin/rkdropdown.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkdropdown.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkdropdown.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -39,7 +39,7 @@
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
+	QLabel *label = new QLabel (xml->i18nStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
 	vbox->addWidget (label);
 
 	// create ComboBox

Modified: trunk/rkward/rkward/plugin/rkformula.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkformula.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkformula.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -65,7 +65,7 @@
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	vbox->addWidget (new QLabel (xml->getStringAttribute (element, "label", i18n ("Specify model"), DL_INFO), this));
+	vbox->addWidget (new QLabel (xml->i18nStringAttribute (element, "label", i18n ("Specify model"), DL_INFO), this));
 
 	type_selector = new QButtonGroup (this);
 	QRadioButton* button;

Modified: trunk/rkward/rkward/plugin/rkinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkinput.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkinput.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -47,7 +47,7 @@
 	// do all the layouting
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
-	QString label_string = xml->getStringAttribute (element, "label", i18n ("Enter text"), DL_INFO);
+	QString label_string = xml->i18nStringAttribute (element, "label", i18n ("Enter text"), DL_INFO);
 	if (!label_string.isEmpty ()) {
 		QLabel *label = new QLabel (label_string, this);
 		vbox->addWidget (label);

Modified: trunk/rkward/rkward/plugin/rkmatrixinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -41,7 +41,7 @@
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Enter data:"), DL_INFO), this);
+	QLabel *label = new QLabel (xml->i18nStringAttribute (element, "label", i18n ("Enter data:"), DL_INFO), this);
 	vbox->addWidget (label);
 
 	display = new RKTableView (this);

Modified: trunk/rkward/rkward/plugin/rkoptionset.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkoptionset.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -93,7 +93,7 @@
 	for (int i = 0; i < options.size (); ++i) {
 		const QDomElement &e = options.at (i);
 		QString id = xml->getStringAttribute (e, "id", QString (), DL_ERROR);
-		QString label = xml->getStringAttribute (e, "label", QString (), DL_DEBUG);
+		QString label = xml->i18nStringAttribute (e, "label", QString (), DL_DEBUG);
 		QString governor = xml->getStringAttribute (e, "connect", QString (), DL_INFO);
 		bool external = xml->getBoolAttribute (e, "external", false, DL_INFO);
 

Modified: trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginbrowser.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkpluginbrowser.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -50,8 +50,8 @@
 
 	bool only_local = !xml->getBoolAttribute (element, "allow_urls", false, DL_INFO);
 
-	selector = new GetFileNameWidget (this, mode, only_local, xml->getStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), i18n ("Select"), xml->getStringAttribute (element, "initial", QString::null, DL_INFO));
-	QString filter = xml->getStringAttribute (element, "filter", QString::null, DL_INFO);
+	selector = new GetFileNameWidget (this, mode, only_local, xml->i18nStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), i18n ("Select"), xml->getStringAttribute (element, "initial", QString (), DL_INFO));
+	QString filter = xml->getStringAttribute (element, "filter", QString (), DL_INFO);
 	if (!filter.isEmpty ()) {
 		filter.append ("\n*|All files");
 		selector->setFilter (filter);

Modified: trunk/rkward/rkward/plugin/rkpluginframe.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginframe.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkpluginframe.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -33,7 +33,7 @@
 
 	QVBoxLayout *layout = new QVBoxLayout (this);
 	layout->setContentsMargins (0, 0, 0, 0);
-	frame = new QGroupBox (xml->getStringAttribute (element, "label", QString(), DL_INFO), this);
+	frame = new QGroupBox (xml->i18nStringAttribute (element, "label", QString(), DL_INFO), this);
 	layout->addWidget (frame);
 	layout = new QVBoxLayout (frame);
 	page = new KVBox (frame);

Modified: trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -36,7 +36,7 @@
 	bool checkable = xml->getBoolAttribute (element, "checkable", false, DL_INFO);
 	bool checked = xml->getBoolAttribute (element, "checked", false, DL_INFO);
 	bool required = xml->getBoolAttribute (element, "required", true, DL_INFO);
-	QString label = xml->getStringAttribute (element, "label", i18n ("Save to:"), DL_INFO);
+	QString label = xml->i18nStringAttribute (element, "label", i18n ("Save to:"), DL_INFO);
 	QString initial = xml->getStringAttribute (element, "initial", i18n ("my.data"), DL_INFO);
 
 	// create and add properties

Modified: trunk/rkward/rkward/plugin/rkpluginspinbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginspinbox.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkpluginspinbox.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -42,7 +42,7 @@
 	// layout and label
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
-	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Enter value:"), DL_WARNING), this);
+	QLabel *label = new QLabel (xml->i18nStringAttribute (element, "label", i18n ("Enter value:"), DL_WARNING), this);
 	vbox->addWidget (label);
 
 	// create spinbox and read settings

Modified: trunk/rkward/rkward/plugin/rkpreviewbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpreviewbox.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkpreviewbox.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -52,7 +52,7 @@
 	// create checkbox
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
-	toggle_preview_box = new QCheckBox (xml->getStringAttribute (element, "label", i18n ("Preview"), DL_INFO), this);
+	toggle_preview_box = new QCheckBox (xml->i18nStringAttribute (element, "label", i18n ("Preview"), DL_INFO), this);
 	vbox->addWidget (toggle_preview_box);
 	toggle_preview_box->setChecked (preview_active);
 	connect (toggle_preview_box, SIGNAL (stateChanged (int)), this, SLOT (changedState (int)));

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -341,7 +341,7 @@
 	// go
 	builder->buildElement (gui_element, *xml, parent_widget, build_wizard);
 	builder->parseLogic (xml->getChildElement (doc_element, "logic", DL_INFO), *xml);
-	setCaption (xml->getStringAttribute (gui_element, "label", QString::null, DL_WARNING));
+	setCaption (xml->i18nStringAttribute (gui_element, "label", QString (), DL_WARNING));
 
 	// initialize
 	builder->makeConnections ();
@@ -658,7 +658,7 @@
 				if (xml.getBoolAttribute (e, "as_button", false, DL_INFO)) {
 					RKStandardComponent* swidget = handle->invoke (component (), 0);
 					widget = swidget;
-					QString dummy = xml.getStringAttribute (e, "label", "Options", DL_WARNING);
+					QString dummy = xml.i18nStringAttribute (e, "label", i18n ("Options"), DL_WARNING);
 					swidget->setCaption (dummy);
 // TODO we should use a specialized pushbutton, that changes color if the corresponding component is dissatisfied!
 					QPushButton *button = new QPushButton (dummy, parent_widget);

Modified: trunk/rkward/rkward/plugin/rktabpage.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rktabpage.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rktabpage.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -31,7 +31,7 @@
 	RK_TRACE (PLUGIN);
 
 	XMLHelper* xml = parent_component->xmlHelper ();
-	label = xml->getStringAttribute (element, "label", QString::null, DL_WARNING);
+	label = xml->i18nStringAttribute (element, "label", QString (), DL_WARNING);
 
 	QVBoxLayout *layout = new QVBoxLayout (this);
 	page = new KVBox (this);

Modified: trunk/rkward/rkward/plugin/rkvalueselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvalueselector.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkvalueselector.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -47,7 +47,7 @@
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	QString lab = xml->getStringAttribute (element, "label", QString (), DL_INFO);
+	QString lab = xml->i18nStringAttribute (element, "label", QString (), DL_INFO);
 	if (!lab.isNull ()) {
 		QLabel *label = new QLabel (lab, this);
 		vbox->addWidget (label);
@@ -72,7 +72,7 @@
 		for (int i = 0; i < options.size (); ++i) {
 			const QDomElement &child = options[i];
 			QString v = xml->getStringAttribute (child, "value", QString (), DL_WARNING);
-			QString l = xml->getStringAttribute (child, "label", v, DL_INFO);
+			QString l = xml->i18nStringAttribute (child, "label", v, DL_INFO);
 			if (xml->getBoolAttribute (child, "checked", false, DL_INFO)) selected_list.append (v);
 			labels_list.append (l);
 			values_list.append (v);

Modified: trunk/rkward/rkward/plugin/rkvarslot.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvarslot.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/plugin/rkvarslot.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -42,7 +42,7 @@
 	// basic layout
 	QGridLayout *g_layout = new QGridLayout (this);
 
-	QString label_string = xml->getStringAttribute (element, "label", i18n ("Variable:"), DL_INFO);
+	QString label_string = xml->i18nStringAttribute (element, "label", i18n ("Variable:"), DL_INFO);
 	if (!label_string.isEmpty ()) {
 		QLabel *label = new QLabel (label_string, this);
 		g_layout->addWidget (label, 0, 2);

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2014-10-26 18:35:42 UTC (rev 4959)
@@ -594,7 +594,7 @@
 					if (title.isEmpty ()) {
 						QDomElement source_element = component_xml.findElementWithAttribute (component_doc_element, "id", id, true, DL_WARNING);
 						if (source_element.isNull ()) RK_DEBUG (PLUGIN, DL_ERROR, "No such UI element: %s", qPrintable (id));
-						title = component_xml.getStringAttribute (source_element, "label", i18n ("Unnamed GUI element"), DL_WARNING);
+						title = component_xml.i18nStringAttribute (source_element, "label", i18n ("Unnamed GUI element"), DL_WARNING);
 					}
 					writeHTML ("<h4>" + title + "</h4>");
 					writeHTML (renderHelpFragment (*it));
@@ -603,7 +603,7 @@
 					QString title = help_xml.getStringAttribute (*it, "title", QString (), DL_INFO);
 					QDomElement source_element = component_xml.findElementWithAttribute (component_doc_element, "id", id, true, DL_WARNING);
 					if (source_element.isNull ()) RK_DEBUG (PLUGIN, DL_ERROR, "No such UI element: %s", qPrintable (id));
-					title = component_xml.getStringAttribute (source_element, "label", title, DL_WARNING);
+					title = component_xml.i18nStringAttribute (source_element, "label", title, DL_WARNING);
 					writeHTML ("<h3>" + title + "</h3>");
 				} else {
 					help_xml.displayError (&(*it), "Tag not allowed, here", DL_WARNING);

Modified: trunk/rkward/scripts/extract_plugin_messages.py
===================================================================
--- trunk/rkward/scripts/extract_plugin_messages.py	2014-10-26 17:39:08 UTC (rev 4958)
+++ trunk/rkward/scripts/extract_plugin_messages.py	2014-10-26 18:35:42 UTC (rev 4959)
@@ -85,7 +85,7 @@
       rc.append(cn.data)
   return ''.join (rc).strip ()
 
-# Look for an i18n comment in the given node, and write it out to the outfile
+# Look for an i18n comment in the given node, and add automatically extracted file context information
 def getI18nComment (node, attribute=""):
   ret = "/* "
   for cn in node.childNodes:





More information about the rkward-tracker mailing list