WikiMessageGroup.php

Go to the documentation of this file.
00001 <?php
00021 class WikiMessageGroup extends MessageGroupOld {
00022     protected $source = null;
00023 
00030     public function __construct( $id, $source ) {
00031         parent::__construct();
00032         $this->id = $id;
00033         $this->source = $source;
00034     }
00035 
00040     public function getSourceLanguage() {
00041         global $wgLanguageCode;
00042 
00043         return $wgLanguageCode;
00044     }
00045 
00050     public function getDefinitions() {
00051         $definitions = array();
00052 
00053         // In theory the page could have templates that are substitued
00054         $source = wfMessage( $this->source );
00055         if ( $source->isDisabled() ) {
00056             return array();
00057         }
00058 
00059         $contents = $source->text();
00060         $contents = preg_replace( '~^\s*#.*$~m', '', $contents );
00061         $messages = preg_split( '/\s+/', $contents );
00062 
00063         foreach ( $messages as $message ) {
00064             if ( !$message ) {
00065                 continue;
00066             }
00067 
00068             $definitions[$message] = wfMessage( $message )->inContentLanguage()->plain();
00069         }
00070 
00071         return $definitions;
00072     }
00073 
00082     public function getMessage( $key, $code ) {
00083         if ( $code && $this->getSourceLanguage() !== $code ) {
00084             return TranslateUtils::getMessageContent( $key, $code );
00085         } else {
00086             return TranslateUtils::getMessageContent( $key, false );
00087         }
00088     }
00089 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3