EVOLUTION-MANAGER
Edit File: checkPoFiles.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: Check Translation Files for Inconsistent Format Strings</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 checkPoFiles {tools}"><tr><td>checkPoFiles {tools}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Check Translation Files for Inconsistent Format Strings</h2> <h3>Description</h3> <p>These functions compare formats embedded in English messages with translated strings to check for consistency. <code>checkPoFile</code> checks one file, while <code>checkPoFiles</code> checks all files for a specified language. </p> <h3>Usage</h3> <pre> checkPoFile(f, strictPlural = FALSE) checkPoFiles(language, dir = ".") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>f</code></td> <td> <p>a character string giving a single filepath.</p> </td></tr> <tr valign="top"><td><code>strictPlural</code></td> <td> <p>whether to compare formats of singular and plural forms in a strict way.</p> </td></tr> <tr valign="top"><td><code>language</code></td> <td> <p>a character string giving a language code.</p> </td></tr> <tr valign="top"><td><code>dir</code></td> <td> <p>a path to a directory in which to check files.</p> </td></tr> </table> <h3>Details</h3> <p>Part of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>'s internationalization depends on translations of messages in ‘<span class="file">.po</span>’ files. In these files an ‘English’ message taken from the <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> sources is followed by a translation into another language. Many of these messages are format strings for C or <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> <code><a href="../../base/html/sprintf.html">sprintf</a></code> and related functions. In these cases, the translation must give a compatible format or an error will be generated when the message is displayed. </p> <p>The rules for compatibility differ between C and <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> in several ways. C supports several conversions not supported by <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>, namely <code>c</code>, <code>u</code>, <code>p</code>, <code>n</code>. It is allowed in C's <code>sprintf()</code> function to have more arguments than are needed by the format string, but in <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> the counts must match exactly. <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> requires types of arguments to match, whereas C will do the display whether it makes sense or not. </p> <p>These functions compromise on the testing as follows. The additional formats allowed in C are accepted, and all differences in argument type or count are reported. As a consequence some reported differences are not errors. </p> <p>If the <code>strictPlural</code> argument is <code>TRUE</code>, then argument lists must agree exactly between singular and plural forms of messages; if <code>FALSE</code>, then translations only need to match one or the other of the two forms. When <code>checkPoFiles</code> calls <code>checkPoFile</code>, the <code>strictPlural</code> argument is set to <code>TRUE</code> for files with names starting ‘<span class="file">R-</span>’, and to <code>FALSE</code> otherwise. </p> <p>Items marked as ‘fuzzy’ in the ‘<span class="file">.po</span>’ file are not processed (as they are ignored by the message compiler). </p> <p>If a difference is found, the translated string is checked for variant percent signs (e.g., the wide percent sign <code>"\uFF05"</code>). Such signs will not be recognized as format specifiers, and are likely to be errors. </p> <h3>Value</h3> <p>Both functions return an object of S3 class <code>"check_po_files"</code>. A <code>print</code> method is defined for this class to display a report on the differences. </p> <h3>Author(s)</h3> <p>Duncan Murdoch </p> <h3>References</h3> <p>See the GNU gettext manual for the ‘<span class="file">.po</span>’ file format:<br /> <a href="https://www.gnu.org/software/gettext/manual/gettext.html">https://www.gnu.org/software/gettext/manual/gettext.html</a>. </p> <h3>See Also</h3> <p><code><a href="update_pkg_po.html">update_pkg_po</a>()</code> which calls <code>checkPoFile()</code>; <code><a href="xgettext.html">xgettext</a></code>, <code><a href="../../base/html/sprintf.html">sprintf</a></code>. </p> <h3>Examples</h3> <pre> ## Not run: checkPoFiles("de", "/path/to/R/src/directory") ## 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>