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

tfry at users.sf.net tfry at users.sf.net
Wed Nov 5 14:52:14 UTC 2014


Revision: 4990
          http://sourceforge.net/p/rkward/code/4990
Author:   tfry
Date:     2014-11-05 14:52:13 +0000 (Wed, 05 Nov 2014)
Log Message:
-----------
Add comment()-function for use in JS (automatically i18n'ed)

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/testing/test1.js
    trunk/rkward/rkward/scriptbackends/common.js
    trunk/rkward/scripts/extract_plugin_messages.py

Modified: trunk/rkward/rkward/plugins/testing/test1.js
===================================================================
--- trunk/rkward/rkward/plugins/testing/test1.js	2014-11-04 21:06:45 UTC (rev 4989)
+++ trunk/rkward/rkward/plugins/testing/test1.js	2014-11-05 14:52:13 UTC (rev 4990)
@@ -1,5 +1,5 @@
 function preprocess () {
-	printIndented ("\t\t", "This is\n\t\a\ntest");
+	printIndented ("\t\t", "This is\n\t\a\ntest\n");
 }
 
 function calculate () {
@@ -13,7 +13,7 @@
 //	makeHeaderCode ("SimpleAnova", new Array ("Model", "Data"))
 	echo ('rk.echo (result)\n');
 
-	echo ('### i18n tests below ###\n');
+	comment ('i18n tests below');
 	echo ('print (' + i18n ("This is an i18n text") + ')\n');
 	echo ('print (' + i18n ('This is a single quoted i18n text, with a variety of quoting chars (\' " \` \" `), and a %1 inside:', 1) + ')\n');
 	echo ('# A comment: ' + i18nc ("Dummy context", noquote ("This is a non-auto-quoted i18n'ed text with context")) + '\n');

Modified: trunk/rkward/rkward/scriptbackends/common.js
===================================================================
--- trunk/rkward/rkward/scriptbackends/common.js	2014-11-04 21:06:45 UTC (rev 4989)
+++ trunk/rkward/rkward/scriptbackends/common.js	2014-11-05 14:52:13 UTC (rev 4990)
@@ -85,6 +85,14 @@
 	return (noquote (quote (ret)));
 }
 
+comment = function (message, indentation) {
+	var args = Array ().slice.call (arguments, 2);
+	args.unshift ("R code comment", noquote (message));
+	message = i18nc.apply (this, args);
+	if (typeof (indentation) == 'undefined') indentation = "";
+	printIndented (indentation + "# ", message + "\n");
+}
+
 makeHeaderCode = function (title, parameters) {
 	echo ("rk.header(" + quote (title));
 	if (parameters.length) {

Modified: trunk/rkward/scripts/extract_plugin_messages.py
===================================================================
--- trunk/rkward/scripts/extract_plugin_messages.py	2014-11-04 21:06:45 UTC (rev 4989)
+++ trunk/rkward/scripts/extract_plugin_messages.py	2014-11-05 14:52:13 UTC (rev 4990)
@@ -311,10 +311,10 @@
   jsbuf = JSParseBuffer (buf)
   while (True):
     call = ""
-    junk = jsbuf.nibble_until ("i18n")
+    junk = jsbuf.nibble_until (("i18n", "comment"))
     if (jsbuf.atEof ()):
       break
-    for candidate in ["i18n", "i18nc", "i18np", "i18ncp"]:
+    for candidate in ["i18n", "i18nc", "i18np", "i18ncp", "comment"]:
       if (jsbuf.isAtFunctionCall (candidate)):
         call = candidate
         break
@@ -343,6 +343,9 @@
     if (offset >= 0):
       text += ":" + str (offset + line + 1)
     text += "\ni18n: ectx: (" + caption + ") */\n"
+    if (call == "comment"):
+      call = "i18nc" # for xgettext
+      parameters = parameters.replace ('(', '("R code comment", ', 1)
     text += call + normalizeQuotes (parameters) + ";\n"
     outfile.write (text)
 





More information about the rkward-tracker mailing list