new extractor, should work on Windows
Hi, Today I committed several improvements to the translation template generator. These include: - new automatic file discovery (no need to pass all parsed filenames directly) [control freaks can still use the old mode with the --files option] - speedier operation: now uses a lot less memory, and a lot less computational power, due to some trivial optimisations Previously people complained that the extractor is not easy to run on Windows due to the command line nature of how file names were passed in. Actually I did not fix this issue intentionally, I discovered that the previously suggested file wildcards were missing some important files, and only ugly wildcards would have helped. Anway, now the extractor autodiscovers files starting from the current working directory, so it should work out of the box for Windows users. Now those following the PHP.net manual setup suggestions on Windows (ie. they have the php.exe on PATH), should be able to run php extractor.php in their drupal folder (given they copy extractor.php there), and get all the translation templates. Extractor.php itself will be excluded from the source files, when generating the templates. This can be easily done with any contrib project too. It was never easier to run the extractor. Please try on Windows, I don't have a Windows system here, so I cannot do it myself. BTW I also posted updated templates generated with this new script. There were quite some changes lately in the Drupal 4.7 source strings. http://cvs.drupal.org/viewcvs/drupal/contributions/translations/drupal-pot/e... Goba
Gabor Hojtsy wrote:
Today I committed several improvements to the translation template generator. These include: -snip description-
Thanks! This a big improvement for those of us stuck on windows :-) (My .bat file to call extractor was getting a bit messy.)
It was never easier to run the extractor. Please try on Windows, I don't have a Windows system here, so I cannot do it myself.
Testing with PHP 5.1.1 on WinXP, I get the following error when running extractor.php in the root of the Drupal directory: Fatal error: Call to undefined function write_header() in D:\projekter\drupal\drupal-HEAD\extractor.php on line 167 As far as I can tell, the "if (!function_exists("write_header"))" block is never run. The attached diff fixes the problem for me, but it can probably be solved a little more elegantly. Med venlig hilsen / Kind regards, Morten Wulff -- Self Injury Information and Support: http://www.psyke.org/ "I did not, you see, want to kill myself. Not at that time, anyway. But I wanted to know that if need be, if the desperation got so terribly bad, I could inflict harm on my body. And I could." - Elizabeth Wurtzel Index: translations/drupal-pot/extractor.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/translations/drupal-pot/extractor.php,v retrieving revision 1.9 diff -u -r1.9 extractor.php --- translations/drupal-pot/extractor.php 1 Feb 2006 20:51:28 -0000 1.9 +++ translations/drupal-pot/extractor.php 2 Feb 2006 07:29:49 -0000 @@ -163,6 +163,31 @@ $storage[$file][] = $input; } else { + // You can override the header (with a language team specific variant for example), + // if you generate missing templates for yourself, and would like to work quickly. + if (!function_exists("write_header")) { + function write_header($file) { + $output = "# LANGUAGE translation of Drupal (". $file .")\n"; + $output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n"; + $output .= "# --VERSIONS--\n"; + $output .= "#\n"; + $output .= "#, fuzzy\n"; + $output .= "msgid \"\"\n"; + $output .= "msgstr \"\"\n"; + $output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n"; + $output .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; + $output .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n"; + $output .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n"; + $output .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n"; + $output .= "\"MIME-Version: 1.0\\n\"\n"; + $output .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n"; + $output .= "\"Content-Transfer-Encoding: 8bit\\n\"\n"; + $output .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n"; + + return $output; + } + } + $storage[$file] = array(); $storage[$file][0] = write_header($file); $storage[$file][1] = $filelist; @@ -174,31 +199,6 @@ } } - // You can override the header (with a language team specific variant for example), - // if you generate missing templates for yourself, and would like to work quickly. - if (!function_exists("write_header")) { - function write_header($file) { - $output = "# LANGUAGE translation of Drupal (". $file .")\n"; - $output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n"; - $output .= "# --VERSIONS--\n"; - $output .= "#\n"; - $output .= "#, fuzzy\n"; - $output .= "msgid \"\"\n"; - $output .= "msgstr \"\"\n"; - $output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n"; - $output .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; - $output .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n"; - $output .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n"; - $output .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n"; - $output .= "\"MIME-Version: 1.0\\n\"\n"; - $output .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n"; - $output .= "\"Content-Transfer-Encoding: 8bit\\n\"\n"; - $output .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n"; - - return $output; - } - } - function format_quoted_string($str) { $quo = substr($str, 0, 1); $str = substr($str, 1, -1);
Morten Wulff wrote:
Thanks! This a big improvement for those of us stuck on windows :-) (My .bat file to call extractor was getting a bit messy.)
It was never easier to run the extractor. Please try on Windows, I don't have a Windows system here, so I cannot do it myself.
Testing with PHP 5.1.1 on WinXP, I get the following error when running extractor.php in the root of the Drupal directory:
Fatal error: Call to undefined function write_header() in D:\projekter\drupal\drupal-HEAD\extractor.php on line 167
As far as I can tell, the "if (!function_exists("write_header"))" block is never run. The attached diff fixes the problem for me, but it can probably be solved a little more elegantly.
I have committed a different and simpler solution. Now you can define a write_header_custom() function if you would like to overwrite the default POT header with automatic language specific data. Goba
Gabor Hojtsy wrote:
I have committed a different and simpler solution. Now you can define a write_header_custom() function if you would like to overwrite the default POT header with automatic language specific data.
Works like a charm. Med venlig hilsen / Kind regards, Morten Wulff -- Self Injury Information and Support: http://www.psyke.org/ "I did not, you see, want to kill myself. Not at that time, anyway. But I wanted to know that if need be, if the desperation got so terribly bad, I could inflict harm on my body. And I could." - Elizabeth Wurtzel
participants (2)
-
Gabor Hojtsy -
Morten Wulff