r29294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29293‎ | r29294 | r29295 >
Date:16:15, 5 January 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Export documentation messages as "extracted comments" in po export
* Import fuzzy messages as fuzzy in po import
Modified paths:
  • /trunk/extensions/Translate/README (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateTasks.php (modified) (history)
  • /trunk/extensions/Translate/poimport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -11,7 +11,7 @@
1212 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1313 */
1414
15 -define( 'TRANSLATE_VERSION', '7.9' );
 15+define( 'TRANSLATE_VERSION', '7.10' );
1616
1717 $wgExtensionCredits['specialpage'][] = array(
1818 'name' => 'Translate',
Index: trunk/extensions/Translate/TranslateTasks.php
@@ -373,7 +373,7 @@
374374 }
375375
376376 public function output() {
377 - global $IP;
 377+ global $IP, $wgServer, $wgTranslateDocumentationLanguageCode;
378378
379379 $lang = Language::factory( 'en' );
380380
@@ -385,9 +385,10 @@
386386
387387 $headers = array();
388388 $headers['Project-Id-Version'] = 'MediaWiki ' . SpecialVersion::getVersion();
389 - $headers['Report-Msgid-Bugs-To'] = 'Bugzilla?';
 389+ // TODO: make this customisable or something
 390+ $headers['Report-Msgid-Bugs-To'] = $wgServer;
390391 // TODO: sprintfDate doesn't support any time zone flags
391 - $headers['POT-Creation-Date'] = $lang->sprintfDate( 'xnY-xnm-xnd xnH:xni:xns O', $now );
 392+ $headers['POT-Creation-Date'] = $lang->sprintfDate( 'xnY-xnm-xnd xnH:xni:xns+0000', $now );
392393 $headers['Language-Team'] = TranslateUtils::getLanguageName( $this->options->getLanguage() );
393394 $headers['Content-Type'] = 'text-plain; charset=UTF-8';
394395 $headers['Content-Transfer-Encoding'] = '8bit';
@@ -400,14 +401,9 @@
401402 $headerlines[] = "$key: $value\n";
402403 }
403404
404 -
405 - $out .= "# Translation of $label to $languageName\n# This is an experimental feature\n";
 405+ $out .= "# Translation of $label to $languageName\n";
406406 $out .= self::formatmsg( '', $headerlines );
407407
408 -
409 - // Todo: move to MessageGroup
410 - require( $IP . '/maintenance/language/messages.inc' );
411 -
412408 foreach ( $this->messages as $key => $m) {
413409 $flags = array();
414410
@@ -430,9 +426,10 @@
431427 $flags[] = 'fuzzy';
432428 }
433429
434 - $comments = array( $key );
435 - if ( isset( $wgMessageComments[$key] ) ) {
436 - $comments[] = $wgMessageComments[$key];
 430+ $comments = '';
 431+ if ( $wgTranslateDocumentationLanguageCode ) {
 432+ $documentation = TranslateUtils::getMessageContent( $key, $wgTranslateDocumentationLanguageCode );
 433+ if ( $documentation ) $comments = $documentation;
437434 }
438435
439436 $out .= self::formatcomments( $comments, $flags );
@@ -453,10 +450,7 @@
454451 private static function formatcomments( $comments = false, $flags = false ) {
455452 $output = array();
456453 if ( $comments ) {
457 - if ( !is_array( $comments ) ) {
458 - $comments = array( $comments );
459 - }
460 - $output[] = '#. ' . implode( "\n#. ", $comments );
 454+ $output[] = '#. ' . implode( "\n#. ", explode( "\n", $comments ) );
461455 }
462456
463457 if ( $flags ) {
Index: trunk/extensions/Translate/README
@@ -46,6 +46,8 @@
4747 * New variable $wgTranslateCC for adding custom groups
4848 * WikiMessageGroup class, which is easy to use class for defining a message group for wiki's custom user interface elements
4949 * Array keys in $wgTranslateEC and $wgTranslateAC are not used for alphabetical sorting only. MessageGroup::$id and MessageGroup::getId() are used for everything else.
 50+* Export documentation messages as "extracted comments" in po export
 51+* Import fuzzy messages as fuzzy in po import
5052
5153 == Changes in version 7 ==
5254 * Released 2007-12-29
Index: trunk/extensions/Translate/poimport.php
@@ -1,4 +1,11 @@
22 <?php
 3+/**
 4+ * Imports po files exported from Special:Translate back.
 5+ *
 6+ * @author Niklas Laxström
 7+ * @copyright Copyright © 2007-2008 Niklas Laxström
 8+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 9+ */
310
411 $optionsWithArgs = array( 'file', 'user' );
512
@@ -146,6 +153,11 @@
147154 continue;
148155 }
149156
 157+ // Fuzzy messages
 158+ if ( preg_match( '/^#, fuzzy$/m', $section ) ) {
 159+ $translation = TRANSLATE_FUZZY . $translation;
 160+ }
 161+
150162 if ( $translation !== $contents[$key]->translation ) {
151163 echo "Translation of $key differs:\n$translation\n\n";
152164 $changes["$key/$code"] = $translation;

Status & tagging log