r72855 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72854‎ | r72855 | r72856 >
Date:12:02, 12 September 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Improve tag/flag handling and clean up the code a bit
Modified paths:
  • /trunk/extensions/Translate/ffs/Gettext.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/ffs/Gettext.php
@@ -626,13 +626,23 @@
627627 $template = $this->read( $collection->code );
628628 $output = $this->doGettextHeader( $collection, $template );
629629 foreach ( $collection as $key => $m ) {
 630+ $transTemplate = isset( $template['TEMPLATE'][$key] ) ?
 631+ $template['TEMPLATE'][$key] : array();
 632+ $potTemplate = isset( $pot['TEMPLATE'][$key] ) ?
 633+ $pot['TEMPLATE'][$key] : array();
 634+
630635 $tags = $m->getTags();
631 - if ( $tags ) {
632 - $output .= "#, " . implode( ', ', $tags ) . "\n";
 636+ $flags = isset( $transTemplate['flags'] ) ? $transTemplate['flags'] : array();
 637+
 638+ $outFlags = array_unique( array_merge( $tags, $flags ) );
 639+
 640+ if ( $outFlags ) {
 641+ sort( $outFlags );
 642+ $output .= "#, " . implode( ', ', $outFlags ) . "\n";
633643 }
634644
635 - if ( isset( $pot['TEMPLATE'][$key]['msgctxt'] ) ) {
636 - $output .= 'msgctxt ' . self::escape( $pot['TEMPLATE'][$key]['msgctxt'] ) . "\n";
 645+ if ( isset( $potTemplate['msgctxt'] ) ) {
 646+ $output .= 'msgctxt ' . self::escape( $potTemplate['msgctxt'] ) . "\n";
637647 }
638648
639649 $translation = str_replace( TRANSLATE_FUZZY, '', $m->translation() );

Status & tagging log