GettextDocumentationAid.php

Go to the documentation of this file.
00001 <?php
00017 class GettextDocumentationAid extends TranslationAid {
00018     public function getData() {
00019 
00020         // We need to get the primary group to get the correct file
00021         // So $group can be different from $this->group
00022         $group = $this->handle->getGroup();
00023         if ( !$group instanceof FileBasedMessageGroup ) {
00024             throw new TranslationHelperException( "Not a Gettext group" );
00025         }
00026 
00027         $ffs = $group->getFFS();
00028         if ( !$ffs instanceof GettextFFS ) {
00029             throw new TranslationHelperException( "Not a Gettext group" );
00030         }
00031 
00032         global $wgContLang;
00033         $mykey = $wgContLang->lcfirst( $this->handle->getKey() );
00034         $mykey = str_replace( ' ', '_', $mykey );
00035         $data = $ffs->read( $group->getSourceLanguage() );
00036         $help = $data['TEMPLATE'][$mykey]['comments'];
00037 
00038         $conf = $group->getConfiguration();
00039         if ( isset( $conf['BASIC']['codeBrowser'] ) ) {
00040             $pattern = $conf['BASIC']['codeBrowser'];
00041             $pattern = str_replace( '%FILE%', '\1', $pattern );
00042             $pattern = str_replace( '%LINE%', '\2', $pattern );
00043             $pattern = "[$pattern \\1:\\2]";
00044         } else {
00045             $pattern = "\\1:\\2";
00046         }
00047 
00048         $out = '';
00049         foreach ( $help as $type => $lines ) {
00050             if ( $type === ':' ) {
00051                 $files = '';
00052                 foreach ( $lines as $line ) {
00053                     $files .= ' ' . preg_replace( '/([^ :]+):(\d+)/', $pattern, $line );
00054                 }
00055                 $out .= "<nowiki>#:</nowiki> $files<br />";
00056             } else {
00057                 foreach ( $lines as $line ) {
00058                     $out .= "<nowiki>#$type</nowiki> $line<br />";
00059                 }
00060             }
00061         }
00062 
00063         return array(
00064             'language' => $wgContLang->getCode(),
00065             // @todo Provide raw data when possible
00066             //'value' => $help,
00067             'html' => $this->context->getOutput()->parse( $out ),
00068         );
00069     }
00070 }
Generated on Tue Oct 29 00:00:25 2013 for MediaWiki Translate Extension by  doxygen 1.6.3