From 51e047c0670bec5cf9e25bdcfa819ab807fcd12d Mon Sep 17 00:00:00 2001 From: carstenklapp Date: Fri, 28 Dec 2001 09:53:34 +0000 Subject: [PATCH] Found more strings needing gettext _() and sprintf. Error strings containing function names now use sprintf. Some debugging strings intentionally left alone. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@920 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/DbaDatabase.php | 4 ++-- lib/ErrorManager.php | 4 ++-- lib/FileFinder.php | 4 ++-- lib/WikiDB.php | 14 ++++++------- lib/main.php | 14 ++++++------- lib/savepage.php | 44 +++++++++++++++++++------------------- lib/stdlib.php | 22 +++++++++---------- lib/ziplib.php | 50 ++++++++++++++++++++++---------------------- 8 files changed, 78 insertions(+), 78 deletions(-) diff --git a/lib/DbaDatabase.php b/lib/DbaDatabase.php index 549eb5330..d28e6a6d4 100644 --- a/lib/DbaDatabase.php +++ b/lib/DbaDatabase.php @@ -1,4 +1,4 @@ -handleError($error); } else { - trigger_error("dba_open failed", E_USER_ERROR); + trigger_error(sprintf(_("%s failed"),'dba_open'), E_USER_ERROR); } } $this->_dbh = $dbh; diff --git a/lib/ErrorManager.php b/lib/ErrorManager.php index 783697757..266fa1f1f 100644 --- a/lib/ErrorManager.php +++ b/lib/ErrorManager.php @@ -1,4 +1,4 @@ -ErrorManager: error while handling error:

\n"; + echo "

ErrorManager: "._("error while handling error:")."

\n"; echo $error->printError(); return; } diff --git a/lib/FileFinder.php b/lib/FileFinder.php index bcd2706bf..fc8f9dbcd 100644 --- a/lib/FileFinder.php +++ b/lib/FileFinder.php @@ -1,4 +1,4 @@ -get_latest_version($pagename); if ($latestversion && $version == $latestversion) { $backend->unlock(); - trigger_error("Attempt to delete most recent revision of '$pagename'", + trigger_error(sprintf(_("Attempt to delete most recent revision of '%s'"),$pagename), E_USER_ERROR); return; } @@ -398,7 +398,7 @@ class WikiDB_Page $latestversion = $backend->get_latest_version($pagename); if ($latestversion && $version == $latestversion) { $backend->unlock(); - trigger_error("Attempt to merge most recent revision of '$pagename'", + trigger_error(sprintf(_("Attempt to merge most recent revision of '%s'"),$pagename), E_USER_ERROR); return; } @@ -485,7 +485,7 @@ class WikiDB_Page // Ensure mtimes are monotonic. $pdata = $cache->get_versiondata($pagename, $latestversion); if ($data['mtime'] < $pdata['mtime']) { - trigger_error("$pagename: Date of new revision non-monotonic", + trigger_error(sprintf(_("%s: Date of new revision is %s"),$pagename,"'non-monotonic'"), E_USER_NOTICE); $data['orig_mtime'] = $data['mtime']; $data['mtime'] = $pdata['mtime']; @@ -510,7 +510,7 @@ class WikiDB_Page // FIXME: probably should have some global state information in the backend // to control when to optimize. if (time() % 50 == 0) { - trigger_error('"Optimizing" backend', E_USER_NOTICE); + trigger_error(sprintf(_("Optimizing %s"),'backend'), E_USER_NOTICE); $backend->optimize(); } @@ -834,8 +834,8 @@ class WikiDB_PageRevision if (empty($data['%content'])) { // Replace empty content with default value. - return sprintf(gettext("Describe [%s] here."), - $this->_pagename); + return sprintf(_("Describe %s here."), + "[". $this->_pagename ."]"); } // There is (non-default) content. diff --git a/lib/main.php b/lib/main.php index 6a0cd6a01..0ba6ce6f5 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ getArg('pagename') == gettext("HomePage") ) { + if ( $action == 'browse' && $request->getArg('pagename') == _("HomePage") ) { // if there is no HomePage, create a basic set of Wiki pages - if ( ! $dbi->isWikiPage(gettext("HomePage")) ) { + if ( ! $dbi->isWikiPage(_("HomePage")) ) { include_once("lib/loadsave.php"); SetupWiki($dbi); ExitWiki(); @@ -96,7 +96,7 @@ function main ($request) { $user->must_be_admin($action); if (isset($DisabledActions) && in_array($action, $DisabledActions)) - ExitWiki(sprintf(gettext("Action %s is disabled in this wiki."), $action)); + ExitWiki(sprintf(_("Action %s is disabled in this wiki."), $action)); // Enable the output of most of the warning messages. // The warnings will screw up zip files and setpref though. @@ -182,7 +182,7 @@ function main ($request) { case 'lock': case 'unlock': - $user->must_be_admin("lock or unlock pages"); + $user->must_be_admin(_("lock or unlock pages")); $page = $dbi->getPage($request->getArg('pagename')); $page->set('locked', $action == 'lock'); @@ -216,7 +216,7 @@ function main ($request) { break; default: - echo QElement('p', sprintf("Bad action: '%s'", urlencode($action))); + echo QElement('p', sprintf(_("Bad action: '%s'"), urlencode($action))); break; } ExitWiki(); diff --git a/lib/savepage.php b/lib/savepage.php index d17ee761c..669f70764 100644 --- a/lib/savepage.php +++ b/lib/savepage.php @@ -1,4 +1,4 @@ -"; - $html .= gettext ("PhpWiki is unable to save your changes, because another user edited and saved the page while you were editing the page too. If saving proceeded now changes from the previous author would be lost."); + $html .= _("PhpWiki is unable to save your changes, because another user edited and saved the page while you were editing the page too. If saving proceeded now changes from the previous author would be lost."); $html .= "

\n

"; - $html .= gettext ("In order to recover from this situation follow these steps:"); + $html .= _("In order to recover from this situation follow these steps:"); $html .= "\n

  1. "; - $html .= gettext ("Use your browser's Back button to go back to the edit page."); + $html .= _("Use your browser's Back button to go back to the edit page."); $html .= "
  2. \n
  3. "; - $html .= gettext ("Copy your changes to the clipboard or to another temporary place (e.g. text editor)."); + $html .= _("Copy your changes to the clipboard or to another temporary place (e.g. text editor)."); $html .= "
  4. \n
  5. "; - $html .= gettext ("Reload the page. You should now see the most current version of the page. Your changes are no longer there."); + $html .= _("Reload the page. You should now see the most current version of the page. Your changes are no longer there."); $html .= "
  6. \n
  7. "; - $html .= gettext ("Make changes to the file again. Paste your additions from the clipboard (or text editor)."); + $html .= _("Make changes to the file again. Paste your additions from the clipboard (or text editor)."); $html .= "
  8. \n
  9. "; - $html .= gettext ("Press Save again."); + $html .= _("Press Save again."); $html .= "

\n"; - $html .= QElement('p', gettext ("Sorry for the inconvenience.")); + $html .= QElement('p', _("Sorry for the inconvenience.")); echo GeneratePage('MESSAGE', $html, - sprintf (gettext ("Problem while updating %s"), $pagename)); + sprintf (_("Problem while updating %s"), $pagename)); ExitWiki(); } function PageIsLocked($pagename) { $html = QElement('p', - gettext("This page has been locked by the administrator and cannot be edited.")); + _("This page has been locked by the administrator and cannot be edited.")); $html .= QElement('p', - gettext ("Sorry for the inconvenience.")); + _("Sorry for the inconvenience.")); echo GeneratePage('MESSAGE', $html, - sprintf (gettext ("Problem while editing %s"), $pagename)); + sprintf (_("Problem while editing %s"), $pagename)); ExitWiki (""); } function NoChangesMade($pagename) { - $html = QElement('p', gettext ("You have not made any changes.")); - $html .= QElement('p', gettext ("New version not saved.")); + $html = QElement('p', _("You have not made any changes.")); + $html .= QElement('p', _("New version not saved.")); echo GeneratePage('MESSAGE', $html, - sprintf(gettext("Edit aborted: %s"), $pagename)); + sprintf(_("Edit aborted: %s"), $pagename)); ExitWiki (""); } function BadFormVars($pagename) { - $html = QElement('p', gettext ("Bad form submission")); - $html .= QElement('p', gettext ("Required form variables are missing.")); + $html = QElement('p', _("Bad form submission")); + $html .= QElement('p', _("Required form variables are missing.")); echo GeneratePage('MESSAGE', $html, - sprintf(gettext("Edit aborted: %s"), $pagename)); + sprintf(_("Edit aborted: %s"), $pagename)); ExitWiki (""); } @@ -152,14 +152,14 @@ function savePage ($dbi, $request) { } } - $html = sprintf(gettext("Thank you for editing %s."), + $html = sprintf(_("Thank you for editing %s."), LinkExistingWikiWord($pagename)); $html .= "
\n"; - $html .= gettext ("Your careful attention to detail is much appreciated."); + $html .= _("Your careful attention to detail is much appreciated."); $html .= "\n"; if ($warnings) { - $html .= Element('p', "Warning! " + $html .= Element('p', ""._("Warning!")." " . htmlspecialchars($warnings) . "
\n"); } diff --git a/lib/stdlib.php b/lib/stdlib.php index b2598b555..8aff30b37 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -1,4 +1,4 @@ -\"]", $url)) { return Element('strong', QElement('u', array('class' => 'baduri'), - _("BAD URL -- remove all of <, >, \""))); //" + _("BAD URL -- remove all of <, >, \""))); } $attr['href'] = $url; @@ -193,10 +193,10 @@ function LinkWikiWord($wikiword, $linktext='') { function LinkImage($url, $alt='[External Image]') { // FIXME: Is this needed (or sufficient?) // As long as the src in htmlspecialchars()ed I think it's safe. - if(ereg('[<>"]', $url)) { + if(ereg("[<>\"]", $url)) { return Element('strong', QElement('u', array('class' => 'baduri'), - 'BAD URL -- remove all of <, >, "')); + _("BAD URL -- remove all of <, >, \""))); } return Element('img', array('src' => $url, 'alt' => $alt)); } @@ -456,7 +456,7 @@ function ExtractWikiPageLinks($content) $links = GetWikiPageLinks($dbi, $pagename); $txt = QElement('strong', - sprintf (gettext ("%d best incoming links:"), NUM_RELATED_PAGES)); + sprintf (_("%d best incoming links:"), NUM_RELATED_PAGES)); for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['in'][$i])) { list($name, $score) = $links['in'][$i]; @@ -466,7 +466,7 @@ function ExtractWikiPageLinks($content) $txt .= "\n" . Element('br'); $txt .= Element('strong', - sprintf (gettext ("%d best outgoing links:"), NUM_RELATED_PAGES)); + sprintf (_("%d best outgoing links:"), NUM_RELATED_PAGES)); for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['out'][$i])) { list($name, $score) = $links['out'][$i]; @@ -477,7 +477,7 @@ function ExtractWikiPageLinks($content) $txt .= "\n" . Element('br'); $txt .= Element('strong', - sprintf (gettext ("%d most popular nearby:"), NUM_RELATED_PAGES)); + sprintf (_("%d most popular nearby:"), NUM_RELATED_PAGES)); for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['popular'][$i])) { list($name, $score) = $links['popular'][$i]; @@ -529,11 +529,11 @@ function split_pagename ($page) { function NoSuchRevision ($page, $version) { $html = Element('p', QElement('strong', gettext("Bad Version"))) . "\n"; $html .= QElement('p', - sprintf(gettext("I'm sorry. Version %d of %s is not in my database."), + sprintf(_("I'm sorry. Version %d of %s is not in my database."), $version, $page->getName())) . "\n"; include_once('lib/Template.php'); - echo GeneratePage('MESSAGE', $html, gettext("Bad Version")); + echo GeneratePage('MESSAGE', $html, _("Bad Version")); ExitWiki (""); } @@ -681,7 +681,7 @@ function __vsprintf ($fmt, $args) { // Format string has '%2$s' style argument reordering. // PHP doesn't support this. if (preg_match('/(? count($args)) - trigger_error("$argnum: argument index out of range", E_USER_WARNING); + trigger_error(sprintf(_("%s: argument index out of range"),$argnum), E_USER_WARNING); $newargs[] = $args[$argnum - 1]; } $args = $newargs; diff --git a/lib/ziplib.php b/lib/ziplib.php index f8b878be5..8b1143b31 100644 --- a/lib/ziplib.php +++ b/lib/ziplib.php @@ -1,5 +1,5 @@ fp = $zipfile; // File already open else if (!($this->fp = fopen($zipfile, "rb"))) - ExitWiki("Can't open zip file '$zipfile' for reading"); + ExitWiki(sprintf(_("Can't open zip file '%s' for reading"),$zipfile)); } function _read ($nbytes) { $chunk = fread($this->fp, $nbytes); if (strlen($chunk) != $nbytes) - ExitWiki("Unexpected EOF in zip file"); + ExitWiki(_("Unexpected EOF in zip file")); return $chunk; } @@ -388,13 +388,13 @@ class ZipReader if ($magic != ZIP_LOCHEAD_MAGIC) { if ($magic != ZIP_CENTHEAD_MAGIC) - ExitWiki("Bad header type: " . htmlspecialchars($magic)); // FIXME: better message? + ExitWiki(sprintf(_("Bad header type: %s"),htmlspecialchars($magic))); // FIXME: better message? return $this->done(); } if (($flags & 0x21) != 0) - ExitWiki("Encryption and/or zip patches not supported."); + ExitWiki(_("Encryption and/or zip patches not supported.")); if (($flags & 0x08) != 0) - ExitWiki("Postponed CRC not yet supported."); // FIXME: ??? + ExitWiki(_("Postponed CRC not yet supported.")); // FIXME: ??? $filename = $this->_read($filename_len); if ($extrafld_len != 0) @@ -413,10 +413,10 @@ class ZipReader ExitWiki(sprintf("CRC mismatch %x != %x", $crc, $crc32)); } else - ExitWiki("Compression method $comp_method unsupported"); + ExitWiki(sprintf(_("Compression method %s unsupported"),$comp_method)); if (strlen($data) != $uncomp_size) - ExitWiki(sprintf("Uncompressed size mismatch %d != %d", + ExitWiki(sprintf(_("Uncompressed size mismatch")."%d != %d", strlen($data), $uncomp_size)); return array($filename, $data, $attrib); @@ -560,7 +560,7 @@ function ParseMimeContentType ($string) . '/' . '\s*(' . MIME_TOKEN_REGEXP . ')\s*:x', $string, $match)) - ExitWiki ("Bad MIME content-type"); + ExitWiki(sprintf(_("Bad %s"),'MIME content-type')); $type = strtolower($match[1]); $subtype = strtolower($match[2]); @@ -578,7 +578,7 @@ function ParseMimeContentType ($string) $val = preg_replace('/[\\\\](.)/s', '\\1', $match[3]); $param[strtolower($match[1])] = $val; - + $string = substr($string, strlen($match[0])); } //" <--(kludge for dumb syntax coloring) @@ -619,7 +619,7 @@ function GenerateFootnotesFromRefs($params) while (list($p, $reference) = each($params)) { if (preg_match('/^ref([1-9][0-9]*)$/', $p, $m)) - $footnotes[$m[1]] = sprintf(gettext ("[%d] See [%s]"), + $footnotes[$m[1]] = sprintf(_("[%d] See [%s]"), $m[1], rawurldecode($reference)); } @@ -627,7 +627,7 @@ function GenerateFootnotesFromRefs($params) { ksort($footnotes); return "-----\n" - . gettext ("!References") . "\n" + . "!" ._("References") . "\n" . join("\n%%%\n", $footnotes) . "\n"; } else -- 2.45.0