[rkward-cvs] [rkward] /: Add i18n()-calls to data plugins.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Jan 7 09:06:54 UTC 2015


Git commit 2c0e450476bbf88679fcfe4eaf6ec29d07a34287 by Thomas Friedrichsmeier.
Committed on 07/01/2015 at 08:40.
Pushed by tfry into branch 'master'.

Add i18n()-calls to data plugins.

M  +6    -6    rkward/plugins/data/one_var_tabulation.xml
M  +7    -3    rkward/plugins/data/recode_categorical.js
M  +1    -1    rkward/plugins/data/sort.xml
M  +1    -1    rkward/plugins/data/sort2.xml
M  +6    -6    tests/data_plugin_tests/recode_categorical.rkcommands.R

http://commits.kde.org/rkward/2c0e450476bbf88679fcfe4eaf6ec29d07a34287

diff --git a/rkward/plugins/data/one_var_tabulation.xml b/rkward/plugins/data/one_var_tabulation.xml
index c9fe04b..a59532f 100644
--- a/rkward/plugins/data/one_var_tabulation.xml
+++ b/rkward/plugins/data/one_var_tabulation.xml
@@ -5,7 +5,7 @@
 	<logic>
 		<external id="outvar" default="x"/>
 		<external id="titlevar" default="title"/>
-		<external id="fun_label" default=""Frequency""/>
+		<external id="fun_label"/>
 		<external id="parameters"/>
 
 		<set id="varsource.visible" to="false"/>
@@ -23,22 +23,22 @@
 				var stat = gui.getValue ("stat.string");
 				var label;
 				if (stat == "freq") {
-					label = "Frequency";
+					label = i18n ("Frequency");
 				} else {
 					var obj = makeRObject (gui.getValue ("outcome.available"));
 					if (stat == "sum") {
-						label = "Sum of " + obj.objectname;
+						label = i18n ("Sum of %1", obj.objectname);
 					} else if (stat == "custom") {
-						label = gui.getValue ("custom_stat.text") + " of " + obj.objectname;
+						label = i18nc ("(function name) of (object name)", "%1 of %2", gui.getValue ("custom_stat.text"), obj.objectname);
 					}
 				}
-				gui.setValue ("fun_label", quote (label));
+				gui.setValue ("fun_label", label);
 				updateDescription ();
 			}
 
 			gui.addChangeCommand ("groups.available", "updateDescription ()");
 			updateDescription = function () {
-				gui.setValue ("parameters", '"Tabulation groups"=paste (names (groups), collapse=" by "), "Tabulation statistic"=' + gui.getValue ("fun_label"));
+				gui.setValue ("parameters", i18n ("Tabulation groups") + '=paste (names (groups), collapse=' + i18nc ("Tabulate X by Y [by Z [...]]", " by ") + '), ' + i18n ("Tabulation statistic") + '=' + gui.getValue ("fun_label"));
 			}
 			updateFunLabel ();
 		]]></script>
diff --git a/rkward/plugins/data/recode_categorical.js b/rkward/plugins/data/recode_categorical.js
index 72cb1aa..385a13d 100644
--- a/rkward/plugins/data/recode_categorical.js
+++ b/rkward/plugins/data/recode_categorical.js
@@ -13,7 +13,7 @@ function calculate () {
 	// initialize output vector to defaults
 	echo ('input <- ' + input + '\n');
 	if (is_factor) {
-		echo ('# Use as.character() as intermediate data format, to support adding and dropping levels\n');
+		comment ('Use as.character() as intermediate data format, to support adding and dropping levels');
 		echo ('recoded <- as.character (');
 	} else {
 		echo ('recoded <- as.' + datamode + ' (');
@@ -66,7 +66,7 @@ function calculate () {
 
 	// Produce warnings (or should it be errors?)
 	if (dupes.length > 0) {
-		echo ('\nwarning ("Some input values were specified more than once: ", ' + quote (dupes.join (', ')) + ')\n');
+		echo ('\nwarning (' + i18n ("Some input values were specified more than once: ") + ', ' + quote (dupes.join (', ')) + ')\n');
 	}
 
 	// Set data type and assign to output variable in GlobalEnv
@@ -77,5 +77,9 @@ function calculate () {
 
 function printout () {
 // TODO: Number of differences always shows as 0, if storing to same object...
-	makeHeaderCode ('Recode categorical data', new Array ('Input variable', input, 'Output variable', output, 'Number of differences after recoding', noquote ('sum (' + input + ' != ' + output + ', na.rm=TRUE) + sum (is.na (' + input + ') != is.na (' + output + '))')));
+	new Header (i18n ("Recode categorical data"))
+		.add (i18n ("Input variable"), input)
+		.add (i18n ("Output variable"), output)
+		.add (i18n ("Number of differences after recoding"), noquote ('sum (' + input + ' != ' + output + ', na.rm=TRUE) + sum (is.na (' + input + ') != is.na (' + output + '))'))
+		.print ();
 }
diff --git a/rkward/plugins/data/sort.xml b/rkward/plugins/data/sort.xml
index 91be2f7..bdbd9d8 100644
--- a/rkward/plugins/data/sort.xml
+++ b/rkward/plugins/data/sort.xml
@@ -31,7 +31,7 @@
 					gui.setValue ("notice.text", "");
 				} else {
 					// Not very elegant, but does the trick
-					gui.setValue ("notice.text", "Sorting this type of object is not supported in this plugin");
+					gui.setValue ("notice.text", i18n ("Sorting this type of object is not supported in this plugin"));
 				}
 			}
 			]]></script>
diff --git a/rkward/plugins/data/sort2.xml b/rkward/plugins/data/sort2.xml
index d87e02c..404012f 100644
--- a/rkward/plugins/data/sort2.xml
+++ b/rkward/plugins/data/sort2.xml
@@ -25,7 +25,7 @@
 					gui.setValue ("notice.text", "");
 				} else {
 					// Not very elegant, but does the trick
-					gui.setValue ("notice.text", "Sorting this type of object is not supported in this plugin");
+					gui.setValue ("notice.text", i18n ("Sorting this type of object is not supported in this plugin"));
 				}
 			}
 			]]></script>
diff --git a/tests/data_plugin_tests/recode_categorical.rkcommands.R b/tests/data_plugin_tests/recode_categorical.rkcommands.R
index 6e5f14f..63041a4 100644
--- a/tests/data_plugin_tests/recode_categorical.rkcommands.R
+++ b/tests/data_plugin_tests/recode_categorical.rkcommands.R
@@ -13,9 +13,9 @@ recoded[input == "L"] <- "low"
 recoded[input %in% c("M","H")] <- "midorhigh"
 .GlobalEnv$recoded <- as.factor (recoded)
 ## Print result
-rk.header("Recode categorical data", parameters=list("Input variable", "warpbreaks[[\"tension\"]]",
-	"Output variable", "recoded",
-	"Number of differences after recoding", sum (warpbreaks[["tension"]] != recoded, na.rm=TRUE) + sum (is.na (warpbreaks[["tension"]]) != is.na (recoded))))
+rk.header ("Recode categorical data", parameters=list("Input variable"="warpbreaks[[\"tension\"]]",
+	"Output variable"="recoded",
+	"Number of differences after recoding"=sum (warpbreaks[["tension"]] != recoded, na.rm=TRUE) + sum (is.na (warpbreaks[["tension"]]) != is.na (recoded))))
 })
 local ({
 	x <- {e <- withnas; if (is.factor (e)) {levels (e)} else {sort (unique (e, nmax=10000))}}
@@ -34,7 +34,7 @@ recoded[is.na (input)] <- TRUE
 warning ("Some input values were specified more than once: ", "\"9\", \"10\"")
 .GlobalEnv$recoded2 <- recoded
 ## Print result
-rk.header("Recode categorical data", parameters=list("Input variable", "withnas",
-	"Output variable", "recoded2",
-	"Number of differences after recoding", sum (withnas != recoded2, na.rm=TRUE) + sum (is.na (withnas) != is.na (recoded2))))
+rk.header ("Recode categorical data", parameters=list("Input variable"="withnas",
+	"Output variable"="recoded2",
+	"Number of differences after recoding"=sum (withnas != recoded2, na.rm=TRUE) + sum (is.na (withnas) != is.na (recoded2))))
 })





More information about the rkward-tracker mailing list