[rkward-cvs] SF.net SVN: rkward-code:[4799] trunk/rkward/packages/rkwarddev

m-eik at users.sf.net m-eik at users.sf.net
Mon Sep 1 21:29:54 UTC 2014


Revision: 4799
          http://sourceforge.net/p/rkward/code/4799
Author:   m-eik
Date:     2014-09-01 21:29:53 +0000 (Mon, 01 Sep 2014)
Log Message:
-----------
enhanced support for internationalisation: several languages can now be in one plugin, each gets its own pluginmap. tested with the ANOVA plugin.

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
    trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
    trunk/rkward/packages/rkwarddev/R/rk.rkh.doc.R
    trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
    trunk/rkward/packages/rkwarddev/man/rk.XML.plugin.Rd
    trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd
    trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd
    trunk/rkward/packages/rkwarddev/man/rk.rkh.doc.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2014-09-01 21:29:53 UTC (rev 4799)
@@ -5,6 +5,9 @@
   - new functions rk.set.language(), rk.get.language() and i18n() to facilitate
     static internationalisation of plugins; makes use of a new internal environment
     .rkdev.env
+  - new parameter "lang" in functions rk.rkh.doc(), rk.XML.plugin(), rk.XML.pluginmap()
+    and rk.plugin.skeleton() for internationalisation. if used, the attributes "lang"
+    and "xml:lang" will be set in the <document> root of the generated files, respectively
 fixed:
   - abbreviation of labels now limits valid characters to [0-9A-Za-z]
     

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R	2014-09-01 21:29:53 UTC (rev 4799)
@@ -43,6 +43,7 @@
 #'    See \code{\link[rkwarddev:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.
 #' @param gen.info Logical, if \code{TRUE} a comment note will be written into the document,
 #'    that it was generated by \code{rkwarddev} and changes should be done to the script.
+#' @param lang Character string, the language of the plugin. See \code{\link[rkwarddev:i18n]{i18n}} for details.
 #' @return An object of class \code{XiMpLe.doc}.
 #' @export
 #' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
@@ -63,7 +64,7 @@
 #' }
 
 rk.XML.plugin <- function(name, dialog=NULL, wizard=NULL, logic=NULL, snippets=NULL, provides=NULL, help=TRUE, include=NULL,
-  label=NULL, clean.name=TRUE, about=NULL, dependencies=NULL, gen.info=TRUE){
+  label=NULL, clean.name=TRUE, about=NULL, dependencies=NULL, gen.info=TRUE, lang=rk.get.language()){
   if(isTRUE(clean.name)){
     name.orig <- name
     name <- clean.name(name)
@@ -75,10 +76,17 @@
     all.children[[length(all.children)+1]] <- generator.info
   } else {}
 
-  all.children[[length(all.children)+1]] <- rk.XML.code(file=paste0(name, ".js"))
+  # check for i18n
+  if(is.null(lang)){
+    lang.file <- NULL
+  } else {
+    lang.file <- paste0(".", lang)
+  }
 
+  all.children[[length(all.children)+1]] <- rk.XML.code(file=paste0(name, lang.file, ".js"))
+
   if(isTRUE(help)){
-    all.children[[length(all.children)+1]] <- rk.XML.help(file=paste0(name, ".rkh"))
+    all.children[[length(all.children)+1]] <- rk.XML.help(file=paste0(name, lang.file, ".rkh"))
   } else {}
 
   if(!is.null(include)){
@@ -147,7 +155,13 @@
     all.children[[length(all.children)+1]] <- wizard
   }
 
-  top.doc <- XMLNode("document", .children=child.list(all.children))
+  # check for possible i18n
+  if(is.null(lang)){
+    lang.attrs <- NULL
+  } else {
+    lang.attrs <- list(lang=lang, "xml:lang"=lang)
+  }
+  top.doc <- XMLNode("document", attrs=lang.attrs, .children=child.list(all.children))
 
   plugin <- XMLTree(
       dtd=list(doctype="rkplugin"),

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2014-09-01 21:29:53 UTC (rev 4799)
@@ -46,13 +46,14 @@
 #' @param namespace Character string, the namespace attribute of the \code{<document>} node, defaults to the plugin name (which you probably shouldn't touch...)
 #' @param priority Character string, the priority attribute of the \code{<document>} node. Must be either "hidden", "low", "medium", or "high",
 #'    defaults to "medium".
+#' @param lang Character string, the language of the document. See \code{\link[rkwarddev:i18n]{i18n}} for details.
 #' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @return An object of class \code{XiMpLe.node}.
 #' @export
 
 rk.XML.pluginmap <- function(name, about=NULL, components, hierarchy="test",
   require=NULL, x11.context=NULL, import.context=NULL, clean.name=TRUE, hints=FALSE, gen.info=TRUE,
-  dependencies=NULL, namespace=name, priority="medium"){
+  dependencies=NULL, namespace=name, priority="medium", lang=rk.get.language()){
   name.orig <- name
   if(isTRUE(clean.name)){
     # to besure, remove all non-character symbols from name
@@ -287,11 +288,14 @@
   if(!priority %in% c("hidden", "low", "medium", "high")){
     stop(simpleError("'priority' must be one of 'hidden', 'low', 'medium' or 'high'!"))
   } else {}
-  top.doc <- XMLNode("document",
-    attrs=list(base_prefix="", namespace=namespace, id=doc.ID.name, priority=priority),
-    .children=all.children
-  )
 
+  all.attrs <- list(base_prefix="", namespace=namespace, id=doc.ID.name, priority=priority)
+  # check for possible i18n
+  if(!is.null(lang)){
+    all.attrs[["lang"]] <- all.attrs[["xml:lang"]] <- lang
+  } else {}
+  top.doc <- XMLNode("document", attrs=all.attrs, .children=all.children)
+
   pluginmap <- XMLTree(
     dtd=list(doctype="rkpluginmap"),
     .children=child.list(top.doc)

Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2014-09-01 21:29:53 UTC (rev 4799)
@@ -90,6 +90,7 @@
 #'    that they were generated by \code{rkwarddev} and changes should be done to the script.
 #' @param hints Logical, if \code{TRUE} and you leave out optional entries (like \code{dependencies=NULL}), dummy sections will be added as comments.
 #' @param indent.by A character string defining the indentation string to use.
+#' @param lang Character string, the language of the plugin. See \code{\link[rkwarddev:i18n]{i18n}} for details.
 #' @return Character string with the path to the plugin root directory.
 #' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @export
@@ -159,7 +160,7 @@
   overwrite=FALSE, tests=TRUE, lazyLoad=TRUE,
   create=c("pmap", "xml", "js", "rkh", "desc", "clog"), suggest.required=TRUE,
   components=list(), dependencies=NULL, edit=FALSE, load=FALSE, show=FALSE, gen.info=TRUE,
-  hints=TRUE, indent.by="\t"){
+  hints=TRUE, indent.by="\t", lang=rk.get.language()){
 
   if(inherits(about, "XiMpLe.node")){
     # check about and dependencies
@@ -183,6 +184,11 @@
   # to besure, remove all non-character symbols from name
   name.orig <- name
   name <- clean.name(name)
+  
+  # check for i18n
+  if(!is.null(lang)){
+    lang <- paste0(".", lang)
+  } else {}
 
   # define paths an file names
   main.dir <- file.path(path, name)
@@ -193,7 +199,7 @@
   rkward.dir <- file.path(main.dir, "inst", "rkward")
   plugin.dir <- file.path(rkward.dir, "plugins")
   # the basic file names
-  plugin.fname.pluginmap <- paste0(name, ".pluginmap")
+  plugin.fname.pluginmap <- paste0(name, lang, ".pluginmap")
   # file names with paths
   plugin.pluginmap <- file.path(rkward.dir, plugin.fname.pluginmap)
   tests.main.dir <- file.path(rkward.dir, "tests")
@@ -258,9 +264,9 @@
       rkh.doc <- slot(this.comp, "rkh")
 
       # the basic file names
-      plugin.fname.xml <- paste0(comp.name, ".xml")
-      plugin.fname.js <- paste0(comp.name, ".js")
-      plugin.fname.rkh <- paste0(comp.name, ".rkh")
+      plugin.fname.xml <- paste0(comp.name, lang, ".xml")
+      plugin.fname.js <- paste0(comp.name, lang, ".js")
+      plugin.fname.rkh <- paste0(comp.name, lang, ".rkh")
       # file names with paths
       plugin.xml <- file.path(plugin.dir, plugin.fname.xml)
       plugin.js <- file.path(plugin.dir, plugin.fname.js)
@@ -310,7 +316,7 @@
       # get components and hierarchy info from the components list
       all.components <- sapply(components, function(this.comp){
           comp.name <- slot(this.comp, "name")
-          named.compo <- paste0("plugins/", clean.name(comp.name), ".xml")
+          named.compo <- paste0("plugins/", clean.name(comp.name), lang, ".xml")
           # we'll name the component, to nicen the menu entry
           names(named.compo) <- comp.name
           return(named.compo)

Modified: trunk/rkward/packages/rkwarddev/R/rk.rkh.doc.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.rkh.doc.R	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/R/rk.rkh.doc.R	2014-09-01 21:29:53 UTC (rev 4799)
@@ -36,6 +36,7 @@
 #' @param hints Logical, if \code{TRUE} and you leave out optional entries (like \code{technical=NULL}), empty dummy sections will be added.
 #' @param gen.info Logical, if \code{TRUE} a comment note will be written into the document,
 #'    that it was generated by \code{rkwarddev} and changes should be done to the script.
+#' @param lang Character string, the language of the help page. See \code{\link[rkwarddev:i18n]{i18n}} for details.
 #' @return An object of class \code{XiMpLe.doc}.
 #' @seealso
 #'    \code{\link[rkwarddev:rk.rkh.summary]{rk.rkh.summary}},
@@ -47,7 +48,7 @@
 #'    and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @export
 
-rk.rkh.doc <- function(summary=NULL, usage=NULL, sections=NULL, settings=NULL, related=NULL, technical=NULL, title=NULL, hints=TRUE, gen.info=TRUE){
+rk.rkh.doc <- function(summary=NULL, usage=NULL, sections=NULL, settings=NULL, related=NULL, technical=NULL, title=NULL, hints=TRUE, gen.info=TRUE, lang=rk.get.language()){
 
   all.children <- list()
 
@@ -162,7 +163,13 @@
     all.children[[length(all.children)+1]] <- rk.rkh.technical()
   } else {}
 
-  rkh.document <- XMLNode("document", .children=child.list(all.children, empty=FALSE))
+  # check for possible i18n
+  if(is.null(lang)){
+    lang.attrs <- NULL
+  } else {
+    lang.attrs <- list(lang=lang, "xml:lang"=lang)
+  }
+  rkh.document <- XMLNode("document", attrs=lang.attrs, .children=child.list(all.children, empty=FALSE))
 
   rkh.main <- XMLTree(rkh.document, dtd=list(doctype="rkhelp"))
 

Modified: trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2014-09-01 21:29:53 UTC (rev 4799)
@@ -7,6 +7,9 @@
       \item new functions \code{rk.set.language()}, \code{rk.get.language()} and \code{i18n()} to facilitate
         static internationalisation of plugins; makes use of a new internal environment
         .rkdev.env
+      \item new parameter \code{"lang"} in functions \code{rk.rkh.doc()}, \code{rk.XML.plugin()}, \code{rk.XML.pluginmap()}
+        and \code{rk.plugin.skeleton()} for internationalisation. if used, the attributes \code{"lang"}
+        and "xml:lang" will be set in the <document> root of the generated files, respectively
     }
   }
   \subsection{fixed}{

Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.plugin.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.plugin.Rd	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.plugin.Rd	2014-09-01 21:29:53 UTC (rev 4799)
@@ -6,7 +6,7 @@
 rk.XML.plugin(name, dialog = NULL, wizard = NULL, logic = NULL,
   snippets = NULL, provides = NULL, help = TRUE, include = NULL,
   label = NULL, clean.name = TRUE, about = NULL, dependencies = NULL,
-  gen.info = TRUE)
+  gen.info = TRUE, lang = rk.get.language())
 }
 \arguments{
 \item{name}{Character string,
@@ -53,6 +53,9 @@
 
 \item{gen.info}{Logical, if \code{TRUE} a comment note will be written into the document,
 that it was generated by \code{rkwarddev} and changes should be done to the script.}
+
+\item{lang}{Character string,
+      the language of the plugin. See \code{\link[rkwarddev:i18n]{i18n}} for details.}
 }
 \value{
 An object of class \code{XiMpLe.doc}.

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd	2014-09-01 21:29:53 UTC (rev 4799)
@@ -6,7 +6,8 @@
 rk.XML.pluginmap(name, about = NULL, components, hierarchy = "test",
   require = NULL, x11.context = NULL, import.context = NULL,
   clean.name = TRUE, hints = FALSE, gen.info = TRUE,
-  dependencies = NULL, namespace = name, priority = "medium")
+  dependencies = NULL, namespace = name, priority = "medium",
+  lang = rk.get.language())
 }
 \arguments{
 \item{name}{Character string, name of the plugin.}
@@ -60,6 +61,9 @@
 \item{priority}{Character string,
       the priority attribute of the \code{<document>} node. Must be either "hidden", "low", "medium", or "high",
 defaults to "medium".}
+
+\item{lang}{Character string,
+      the language of the document. See \code{\link[rkwarddev:i18n]{i18n}} for details.}
 }
 \value{
 An object of class \code{XiMpLe.node}.

Modified: trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd	2014-09-01 21:29:53 UTC (rev 4799)
@@ -9,7 +9,8 @@
   overwrite = FALSE, tests = TRUE, lazyLoad = TRUE, create = c("pmap",
   "xml", "js", "rkh", "desc", "clog"), suggest.required = TRUE,
   components = list(), dependencies = NULL, edit = FALSE, load = FALSE,
-  show = FALSE, gen.info = TRUE, hints = TRUE, indent.by = "\\t")
+  show = FALSE, gen.info = TRUE, hints = TRUE, indent.by = "\\t",
+  lang = rk.get.language())
 }
 \arguments{
 \item{about}{Either an object of class \code{XiMpLe.node} with descriptive information on the plugin and its authors
@@ -129,6 +130,9 @@
       if \code{TRUE} and you leave out optional entries (like \code{dependencies=NULL}), dummy sections will be added as comments.}
 
 \item{indent.by}{A character string defining the indentation string to use.}
+
+\item{lang}{Character string,
+      the language of the plugin. See \code{\link[rkwarddev:i18n]{i18n}} for details.}
 }
 \value{
 Character string with the path to the plugin root directory.

Modified: trunk/rkward/packages/rkwarddev/man/rk.rkh.doc.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.rkh.doc.Rd	2014-09-01 13:31:28 UTC (rev 4798)
+++ trunk/rkward/packages/rkwarddev/man/rk.rkh.doc.Rd	2014-09-01 21:29:53 UTC (rev 4799)
@@ -5,7 +5,7 @@
 \usage{
 rk.rkh.doc(summary = NULL, usage = NULL, sections = NULL,
   settings = NULL, related = NULL, technical = NULL, title = NULL,
-  hints = TRUE, gen.info = TRUE)
+  hints = TRUE, gen.info = TRUE, lang = rk.get.language())
 }
 \arguments{
 \item{summary}{An object of class \code{XiMpLe.node} to be pasted as the \code{<summary>} section. See
@@ -35,6 +35,9 @@
 
 \item{gen.info}{Logical, if \code{TRUE} a comment note will be written into the document,
 that it was generated by \code{rkwarddev} and changes should be done to the script.}
+
+\item{lang}{Character string,
+      the language of the help page. See \code{\link[rkwarddev:i18n]{i18n}} for details.}
 }
 \value{
 An object of class \code{XiMpLe.doc}.





More information about the rkward-tracker mailing list