EVOLUTION-MANAGER
Edit File: xgettext.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Extract Translatable Messages from R Files in a Package</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for xgettext {tools}"><tr><td>xgettext {tools}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Extract Translatable Messages from R Files in a Package</h2> <h3>Description</h3> <p>For each file in the ‘<span class="file">R</span>’ directory (including system-specific subdirectories) of a package, extract the unique arguments passed to <code><a href="../../base/html/stop.html">stop</a></code>, <code><a href="../../base/html/warning.html">warning</a></code>, <code><a href="../../base/html/message.html">message</a></code>, <code><a href="../../base/html/gettext.html">gettext</a></code> and <code><a href="../../base/html/sprintf.html">gettextf</a></code>, or to <code><a href="../../base/html/gettext.html">ngettext</a></code>. </p> <h3>Usage</h3> <pre> xgettext(dir, verbose = FALSE, asCall = TRUE) xngettext(dir, verbose = FALSE) xgettext2pot(dir, potFile, name = "R", version, bugs) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>dir</code></td> <td> <p>the directory of a source package.</p> </td></tr> <tr valign="top"><td><code>verbose</code></td> <td> <p>logical: should each file be listed as it is processed?</p> </td></tr> <tr valign="top"><td><code>asCall</code></td> <td> <p>logical: if <code>TRUE</code> each argument is returned whole, otherwise the strings within each argument are extracted.</p> </td></tr> <tr valign="top"><td><code>potFile</code></td> <td> <p>name of <code>po</code> template file to be produced. Defaults to ‘<span class="file">R-<var>pkgname</var>.pot</span>’ where <var>pkgname</var> is the basename of ‘<span class="file">dir</span>’.</p> </td></tr> <tr valign="top"><td><code>name, version, bugs</code></td> <td> <p>as recorded in the template file: <code>version</code> defaults the version number of the currently running <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>, and <code>bugs</code> to <code>"bugs.r-project.org"</code>.</p> </td></tr> </table> <h3>Details</h3> <p>Leading and trailing white space (space, tab and linefeed) is removed for calls to <code>gettext</code>, <code>gettextf</code>, <code>stop</code>, <code>warning</code>, and <code>message</code>, as it is by the internal code that passes strings for translation. </p> <p>We look to see if these functions were called with <code>domain = NA</code> and if so omit the call if <code>asCall = TRUE</code>: note that the call might contain a call to <code>gettext</code> which would be visible if <code>asCall = FALSE</code>. </p> <p><code>xgettext2pot</code> calls <code>xgettext</code> and then <code>xngettext</code>, and writes a PO template file for use with the <span class="pkg">GNU Gettext</span> tools. This ensures that the strings for simple translation are unique in the file (as <span class="pkg">GNU Gettext</span> requires), but does not do so for <code>ngettext</code> calls (and the rules are not stated in the Gettext manual, but <code>msgfmt</code> complains if there is duplication between the sets.). </p> <p>If applied to the <span class="pkg">base</span> package, this also looks in the ‘<span class="file">.R</span>’ files in ‘<span class="file"><var><a href="../../base/html/Rhome.html">R_HOME</a></var>/share/R</span>’. </p> <h3>Value</h3> <p>For <code>xgettext</code>, a list of objects of class <code>"xgettext"</code> (which has a <code>print</code> method), one per source file that potentially contains translatable strings. </p> <p>For <code>xngettext</code>, a list of objects of class <code>"xngettext"</code>, which are themselves lists of length-2 character strings. </p> <h3>See Also</h3> <p><code><a href="update_pkg_po.html">update_pkg_po</a>()</code> which calls <code>xgettext2pot()</code>. </p> <h3>Examples</h3> <pre>## Not run: ## in a source-directory build of R: xgettext(file.path(R.home(), "src", "library", "splines")) ## End(Not run)</pre> <hr /><div style="text-align: center;">[Package <em>tools</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>