cvs: peardoc / configure.php
[email protected] ("Christian Weiske")
| Newsgroups | php.pear.doc |
|---|---|
| Message-ID | <cvscweiske1232884569@cvsserver> |
cweiske Sun Jan 25 11:56:09 2009 UTC
Modified files:
/peardoc configure.php
Log:
Implement ignoring broken translation files
see #47194: documentation workflow change
http://bugs.php.net/bug.php?id=47194
http://cvs.php.net/viewvc.cgi/peardoc/configure.php?r1=1.7&r2=1.8&diff_format=u
Index: peardoc/configure.php
diff -u peardoc/configure.php:1.7 peardoc/configure.php:1.8
--- peardoc/configure.php:1.7 Fri Jan 2 14:21:58 2009
+++ peardoc/configure.php Sun Jan 25 11:56:05 2009
@@ -16,7 +16,11 @@
$GLOBALS['errorcode'] = 0;
try {
createVersionEnt('entities/version.ent');
- createChaptersEnt($opts['language'], $opts['display_untranslated']);
+ createChaptersEnt(
+ $opts['language'], $opts['display_untranslated'],
+ $opts['use_broken_translation_filename']
+ ? $opts['broken_translation_filename'] : null
+ );
createGiant($opts['giant_file'], $opts['validate'], $opts['hide_xml_errors']);
logMsg('Now call phd:');
logMsg(' phd -f xhtml -t pearchunkedhtml'
@@ -43,7 +47,7 @@
require_once 'Console/CommandLine.php';
$parser = new Console_CommandLine(array(
'description' => 'configure the pear manual build',
- 'version' => '$Id: configure.php,v 1.7 2009/01/02 14:21:58 cweiske Exp $'
+ 'version' => '$Id: configure.php,v 1.8 2009/01/25 11:56:05 cweiske Exp $'
));
$parser->addOption('verbose', array(
@@ -73,6 +77,19 @@
'description' => 'Do not display untranslated files',
'default' => true
));
+ $parser->addOption('broken_translation_filename', array(
+ 'long_name' => '--broken-translation-filename',
+ 'help_name' => 'file',
+ 'action' => 'StoreString',
+ 'description' => 'Filename of list with broken/outdaten translation files',
+ 'default' => 'broken-files.txt'
+ ));
+ $parser->addOption('use_broken_translation_filename', array(
+ 'long_name' => '--ignore-broken-file-listing',
+ 'action' => 'StoreFalse',
+ 'description' => 'Do not use broken-translation-filename setting',
+ 'default' => true
+ ));
$parser->addOption('hide_xml_errors', array(
'long_name' => '--no-hide-xml-errors',
'action' => 'StoreFalse',
@@ -117,16 +134,30 @@
* to every manual file.
* English files are used as fallback in case a translation misses a file.
*
-* @param string $lang Language to use ("en", "de", "pt_BR")
-* @param boolean $bDisplayUntranslated If the names of untranslated files shall
-* be displayed
+* @param string $lang Language to use ("en", "de", "pt_BR")
+* @param boolean $bDisplayUntranslated If the names of untranslated files shall
+* be displayed
+* @param string $brokenTranslationFile Name of file listing broken translation
+* files. Those files will not be used.
+* Set it to null to deactivate it.
*
* @return void
*/
-function createChaptersEnt($lang, $bDisplayUntranslated)
-{
+function createChaptersEnt($lang, $bDisplayUntranslated = true,
+ $brokenTranslationFile = null
+) {
logMsg('Generating chapters.ent for ' . $lang);
+ $brokenFilePath = $lang . '/' . $brokenTranslationFile;
+ if ($brokenTranslationFile && file_exists($brokenFilePath)) {
+ logMsg(' Ignoring broken translations listed in ' . $brokenFilePath);
+ $arBroken = array_flip(
+ array_map('trim', file($brokenFilePath))
+ );
+ } else {
+ $arBroken = array();
+ }
+
$cwd = getcwd();
chdir('en');
$arXmlFiles = glob('{,*/,*/*/,*/*/*/,*/*/*/*/,*/*/*/*/*/}*.xml', GLOB_BRACE);
@@ -137,28 +168,38 @@
fputs($hdl, "<!-- DON'T TOUCH - AUTOGENERATED BY configure.php -->\n");
$nUntranslated = $nUntranslatedPhp = 0;
+
+ //XML files
foreach ($arXmlFiles as $file) {
- if ($lang != 'en' && !file_exists($lang . '/' . $file)) {
+ $langfile = $lang . '/' . $file;
+ if ($lang == 'en'
+ || (file_exists($langfile) && !isset($arBroken[$file]))
+ ) {
+ $entfile = $langfile;
+ } else {
++$nUntranslated;
if ($bDisplayUntranslated) {
- logMsg(' Untranslated file: ' . $lang . '/' . $file);
+ logMsg(' Untranslated file: ' . $langfile);
}
$entfile = 'en/' . $file;
- } else {
- $entfile = $lang . '/' . $file;
}
$name = str_replace(array('/', '_'), array('.', '-'), substr($file, 0, -4));
fputs($hdl, '<!ENTITY ' . $name . ' SYSTEM "' . $entfile . "\">\n");
}
+
+ //PHP example files
foreach ($arPhpFiles as $file) {
- if ($lang != 'en' && !file_exists($lang . '/' . $file)) {
+ $langfile = $lang . '/' . $file;
+ if ($lang == 'en'
+ || (file_exists($langfile) && !isset($arBroken[$file]))
+ ) {
+ $entfile = $langfile;
+ } else {
++$nUntranslatedPhp;
if ($bDisplayUntranslated) {
- logMsg(' Untranslated example: ' . $lang . '/' . $file);
+ logMsg(' Untranslated example: ' . $langfile);
}
$entfile = 'en/' . $file;
- } else {
- $entfile = $lang . '/' . $file;
}
$name = str_replace(array('/', '_'), array('.', '-'), $file);
fputs($hdl, '<!ENTITY ' . $name . ' "' . $entfile . "\">\n");
@@ -167,7 +208,8 @@
fclose($hdl);
logMsg(' ' . count($arXmlFiles) . ' xml files');
- logMsg(' ' . count($arPhpFiles) . ' php examples files');
+ logMsg(' ' . count($arPhpFiles) . ' php example files');
+
if ($nUntranslated > 1) {
logMsg(
' ' . $nUntranslated . ' untranslated files'