Commit 67cbb201 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Add i18n to import_export plugins (.js files; messages not yet extracted), and adjust tests.

parent 97710a10
function makeEncodingPreprocessCode () {
if (!getValue ("do_locale_conversion")) return;
echo ('\n');
echo ('# helper function to convert all strings to the current encoding\n');
comment ('helper function to convert all strings to the current encoding');
echo ('iconv.recursive <- function (x, from) {\n');
echo (' attribs <- attributes (x);\n');
echo (' if (is.character (x)) {\n');
......@@ -9,7 +9,7 @@ function makeEncodingPreprocessCode () {
echo (' } else if (is.list (x)) {\n');
echo (' x <- lapply (x, function (sub) iconv.recursive (sub, from))\n');
echo (' }\n');
echo (' # convert factor levels and all other attributes\n');
comment ('convert factor levels and all other attributes', '\t');
echo (' attributes (x) <- lapply (attribs, function (sub) iconv.recursive (sub, from))\n');
echo (' x\n');
echo ('}\n');
......@@ -23,6 +23,6 @@ function makeEncodingCall (varname) {
from_locale = getValue ("user_encoding");
}
echo ('\n');
echo ('# convert all strings to the current encoding\n');
comment ('convert all strings to the current encoding');
echo (varname + ' <- iconv.recursive (' + varname + ', from="' + from_locale + '")\n');
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ function calculate () {
//doing what is left
echo (' na.strings = "' + getValue("na") + '", nrows = ' + getValue("nrows") + ', skip = ' + getValue("skip") + ', check.names = ' + getValue("checkname") + ', strip.white = ' + getValue("stripwhite") + ', blank.lines.skip = ' + getValue("blanklinesskip") + getValue("allow_escapes") + getValue("flush") + getValue("strings_as_factors") + ')\n');
echo ('\n');
echo ('# copy from the local environment to globalenv()\n');
comment ('copy from the local environment to globalenv()');
echo ('.GlobalEnv$' + getValue("name") + ' <- imported\n');
if (getValue ("doedit")) {
echo ('\n');
......@@ -38,6 +38,6 @@ function calculate () {
}
function printout () {
makeHeaderCode ("Import text / csv data", new Array("File" , getValue ("file"), "Import as", getValue ("name")));
new Header (i18n ("Import text / csv data")).addFromUI ("file").addFromUI ("name").print ();
}
......@@ -27,7 +27,7 @@ function calculate () {
makeEncodingCall ('data');
if (getValue ("convert_var_labels")) {
echo ('\n');
echo ('# set variable labels for use in RKWard\n');
comment ('set variable labels for use in RKWard');
echo ('labels <- attr (data, "variable.labels");\n');
echo ('if (!is.null (labels)) {\n');
echo (' for (i in 1:length (labels)) {\n');
......@@ -39,13 +39,13 @@ function calculate () {
echo ('}\n');
}
echo ('\n');
echo ('.GlobalEnv$' + object + ' <- data # assign to globalenv()\n');
echo ('.GlobalEnv$' + object + ' <- data '); comment ('assign to globalenv()');
if (getValue ("doedit") && data_frame) {
echo ('rk.edit (.GlobalEnv$' + object + ')\n');
}
}
function printout () {
makeHeaderCode ("Import SPSS data", new Array("File", getValue ("file"), "Import as", getValue ("saveto")));
new Header (i18n ("Import SPSS data")).addFromUI ("file").addFromUI ("saveto").print ();
}
......@@ -37,7 +37,7 @@ function calculate () {
echo ('data <- read.dta ("' + getValue ("file") + '"' + options + ')\n');
makeEncodingCall ('data');
echo ('\n');
echo ('# set variable labels for use in RKWard\n');
comment ('set variable labels for use in RKWard');
echo ('labels <- attr (data, "var.labels")\n');
echo ('if (!is.null (labels)) {\n');
echo (' for (i in 1:length (labels)) {\n');
......@@ -48,13 +48,13 @@ function calculate () {
echo (' }\n');
echo ('}\n');
echo ('\n');
echo ('.GlobalEnv$' + object + ' <- data # assign to globalenv()\n');
echo ('.GlobalEnv$' + object + ' <- data '); comment ('assign to globalenv()');
if (getValue ("doedit") ) {
echo ('rk.edit (.GlobalEnv$' + object + ')\n');
}
}
function printout () {
makeHeaderCode ("Import Stata File", new Array("File", getValue ("file"), "Imported to", getValue ("saveto")));
new Header (i18n ("Import Stata File")).addFromUI ("file").addFromUI ("saveto").print ();
}
......@@ -20,17 +20,20 @@ function calculate () {
echo ('data <- read.xls ("' + getValue ("file") + '", sheet="' + sheet + '"' + options + ', ');
echo (' nrows=' + getValue ("nrows") + ', skip=' + getValue ("skip") + ', na.string="'+ getValue ("na") +'"' + getValue("strings_as_factors") +
', check.names = ' + getValue("checkname") + ', strip.white = ' + getValue("stripwhite") + ')\n');
echo ('.GlobalEnv$' + object + ' <- data # assign to globalenv()\n');
echo ('.GlobalEnv$' + object + ' <- data '); comment ('assign to globalenv()');
if (getValue ("doedit") ) {
echo ('rk.edit (.GlobalEnv$' + object + ')\n');
}
}
function printout () {
makeHeaderCode ("Import Microsoft EXCEL sheet", new Array("File", getValue ("file"), "Imported to", getValue ("saveto"),
"Imported Sheet", getValue ("sheetname"), "First row as header", getValue ("header"),
"Max number of rows to skip (-1 for no limit)", getValue ("skip"),
"Number of lines to read (-1 for no limit)", getValue ("nrows"),
"Character for missing values", getValue ("na")));
new Header (i18n ("Import Microsoft EXCEL sheet"))
.addFromUI ("file")
.addFromUI ("saveto")
.addFromUI ("sheetname")
.addFromUI ("header")
.addFromUI ("skip")
.addFromUI ("nrows")
.addFromUI ("na").print ();
}
......@@ -17,7 +17,7 @@ function calculate () {
}
function printout () {
makeHeaderCode ("Load data", new Array("File", getValue ("file"), "Import to environment", envir));
new Header (i18n ("Load data")).addFromUI ("file").add (i18n ("Import to environment"), envir).print ();
}
......@@ -19,7 +19,7 @@ function calculate () {
}
function printout () {
makeHeaderCode ("Source R file", new Array("File", getValue ("file")));
new Header (i18n ("Source R file")).addFromUI ("file").print ();
}
// globals
var data;
var file;
function calculate(){
file = getValue("file");
var file = getValue("file");
// read in variables from dialog
var ascii = getValue("ascii");
var compress = getValue("compress");
......@@ -11,7 +7,7 @@ function calculate(){
var xzextreme = getValue("xzextreme");
// the R code to be evaluated
data = getValue("data").split("\n").join(", ");
var data = getValue("data").split("\n").join(", ");
echo("save(" + data);
if(file) {
echo(",\n\tfile=\"" + file + "\"");
......@@ -30,7 +26,6 @@ function calculate(){
}
function printout(){
// printout the results
makeHeaderCode ("Save R objects", new Array("File", file, "Variables", data));
new Header (i18n ("Save R objects")).addFromUI ("file").addFromUI ("data").print ();
}
......@@ -5,6 +5,6 @@ function calculate () {
}
function printout () {
makeHeaderCode ("Create package skeleton", new Array("Name", getValue ("name"), "Directory", getValue ("path")));
new Header (i18n ("Create package skeleton")).addFromUI ("name").addFromUI ("path").print ();
}
......@@ -8,6 +8,6 @@ function calculate () {
}
function printout () {
makeHeaderCode ("Write Variables", new Array("File", getValue ("file"), "Data", getValue ("data")));
new Header (i18n ("Write Variables")).addFromUI ("file").addFromUI ("data").print ();
}
......@@ -7,6 +7,6 @@ function calculate () {
}
function printout () {
makeHeaderCode ("Write as table", new Array("File", getValue ("file"), "Data", getValue ("data")));
new Header (i18n ("Write as table")).addFromUI ("file").addFromUI ("data").print ();
}
......@@ -5,6 +5,6 @@ imported <- read.csv (file="women.csv", row.names=1, na.strings = "NA", nrows =
# copy from the local environment to globalenv()
.GlobalEnv$women <- imported
## Print result
rk.header("Import text / csv data", parameters=list("File", "women.csv",
"Import as", "women"))
rk.header ("Import text / csv data", parameters=list("File name"="women.csv",
"Object to save to"="women"))
})
<h1>Import text / csv data</h1>
<h2>Parameters</h2>
<ul><li>File: women.csv</li>
<li>Import as: women</li>
<ul><li>File name: women.csv</li>
<li>Object to save to: women</li>
</ul>
DATE<br />
Warning message:
In read.spss("import_export_plugins_testfile.sav", to.data.frame = TRUE, :
Warning in read.spss("import_export_plugins_testfile.sav", to.data.frame = TRUE, :
import_export_plugins_testfile.sav: position 1: Variable name character 4 is lowercase letter
......@@ -17,6 +17,6 @@ if (!is.null (labels)) {
.GlobalEnv$my.spss.data <- data # assign to globalenv()
## Print result
rk.header("Import SPSS data", parameters=list("File", "import_export_plugins_testfile.sav",
"Import as", "my.spss.data"))
rk.header ("Import SPSS data", parameters=list("File name"="import_export_plugins_testfile.sav",
"Object to save to"="my.spss.data"))
})
<h1>Import SPSS data</h1>
<h2>Parameters</h2>
<ul><li>File: import_export_plugins_testfile.sav</li>
<li>Import as: my.spss.data</li>
<ul><li>File name: import_export_plugins_testfile.sav</li>
<li>Object to save to: my.spss.data</li>
</ul>
DATE<br />
......
......@@ -33,6 +33,6 @@ if (!is.null (labels)) {
.GlobalEnv$my.stata.data <- data # assign to globalenv()
## Print result
rk.header("Import Stata File", parameters=list("File", "import_export_plugins_testfile.dta",
"Imported to", "my.stata.data"))
rk.header ("Import Stata File", parameters=list("File name"="import_export_plugins_testfile.dta",
"Object to save to"="my.stata.data"))
})
<h1>Import Stata File</h1>
<h2>Parameters</h2>
<ul><li>File: import_export_plugins_testfile.dta</li>
<li>Imported to: my.stata.data</li>
<ul><li>File name: import_export_plugins_testfile.dta</li>
<li>Object to save to: my.stata.data</li>
</ul>
DATE<br />
......
......@@ -2,6 +2,6 @@ local({
## Compute
load (file="women.RData", envir=globalenv())
## Print result
rk.header("Load data", parameters=list("File", "women.RData",
"Import to environment", "globalenv()"))
rk.header ("Load data", parameters=list("R data file to load"="women.RData",
"Import to environment"="globalenv()"))
})
<h1>Load data</h1>
<h2>Parameters</h2>
<ul><li>File: women.RData</li>
<ul><li>R data file to load: women.RData</li>
<li>Import to environment: globalenv()</li>
</ul>
DATE<br />
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment