Nikerabbit has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/51839


Change subject: Refactor formatGettextComments
......................................................................

Refactor formatGettextComments

Change-Id: I7fdb92faee54099e451022fd879e77d36b53b646
---
M translationaids/DocumentationAid.php
1 file changed, 32 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/39/51839/1

diff --git a/translationaids/DocumentationAid.php 
b/translationaids/DocumentationAid.php
index f6c0f92..9e04043 100644
--- a/translationaids/DocumentationAid.php
+++ b/translationaids/DocumentationAid.php
@@ -48,38 +48,41 @@
                }
 
                $ffs = $group->getFFS();
-               if ( $ffs instanceof GettextFFS ) {
-                       global $wgContLang;
-                       $mykey = $wgContLang->lcfirst( $this->handle->getKey() 
);
-                       $mykey = str_replace( ' ', '_', $mykey );
-                       $data = $ffs->read( $group->getSourceLanguage() );
-                       $help = $data['TEMPLATE'][$mykey]['comments'];
-                       // Do not display an empty comment. That's no help and 
takes up unnecessary space.
-                       $conf = $group->getConfiguration();
-                       if ( isset( $conf['BASIC']['codeBrowser'] ) ) {
-                               $out = '';
-                               $pattern = $conf['BASIC']['codeBrowser'];
-                               $pattern = str_replace( '%FILE%', '\1', 
$pattern );
-                               $pattern = str_replace( '%LINE%', '\2', 
$pattern );
-                               $pattern = "[$pattern \\1:\\2]";
-                               foreach ( $help as $type => $lines ) {
-                                       if ( $type === ':' ) {
-                                               $files = '';
-                                               foreach ( $lines as $line ) {
-                                                       $files .= ' ' . 
preg_replace( '/([^ :]+):(\d+)/', $pattern, $line );
-                                               }
-                                               $out .= "<nowiki>#:</nowiki> 
$files<br />";
-                                       } else {
-                                               foreach ( $lines as $line ) {
-                                                       $out .= 
"<nowiki>#$type</nowiki> $line<br />";
-                                               }
-                                       }
+               if ( !$ffs instanceof GettextFFS ) {
+                       return '';
+               }
+
+               global $wgContLang;
+               $mykey = $wgContLang->lcfirst( $this->handle->getKey() );
+               $mykey = str_replace( ' ', '_', $mykey );
+               $data = $ffs->read( $group->getSourceLanguage() );
+               $help = $data['TEMPLATE'][$mykey]['comments'];
+
+               $conf = $group->getConfiguration();
+               if ( isset( $conf['BASIC']['codeBrowser'] ) ) {
+                       $pattern = $conf['BASIC']['codeBrowser'];
+                       $pattern = str_replace( '%FILE%', '\1', $pattern );
+                       $pattern = str_replace( '%LINE%', '\2', $pattern );
+                       $pattern = "[$pattern \\1:\\2]";
+               } else {
+                       $pattern = "\\1:\\2";
+               }
+
+               $out = '';
+               foreach ( $help as $type => $lines ) {
+                       if ( $type === ':' ) {
+                               $files = '';
+                               foreach ( $lines as $line ) {
+                                       $files .= ' ' . preg_replace( '/([^ 
:]+):(\d+)/', $pattern, $line );
                                }
-                               return "$out";
+                               $out .= "<nowiki>#:</nowiki> $files<br />";
+                       } else {
+                               foreach ( $lines as $line ) {
+                                       $out .= "<nowiki>#$type</nowiki> 
$line<br />";
+                               }
                        }
                }
 
-               return '';
+               return $out;
        }
-
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/51839
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7fdb92faee54099e451022fd879e77d36b53b646
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to