http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95948
Revision: 95948
Author: siebrand
Date: 2011-09-01 08:23:20 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
Update whitespace and braces.
Modified Paths:
--------------
trunk/extensions/Translate/Groups.php
Modified: trunk/extensions/Translate/Groups.php
===================================================================
--- trunk/extensions/Translate/Groups.php 2011-09-01 08:21:50 UTC (rev
95947)
+++ trunk/extensions/Translate/Groups.php 2011-09-01 08:23:20 UTC (rev
95948)
@@ -30,16 +30,19 @@
* @return string
*/
public function getId();
+
/**
* Returns the human readable label (as plain text).
* @return string
*/
public function getLabel();
+
/**
* Returns a longer description about the group. Description can use
wiki text.
* @return string
*/
public function getDescription();
+
/**
* Returns the namespace where messages are placed.
* @return int
@@ -52,6 +55,7 @@
* @return bool
*/
public function isMeta();
+
/**
* If this function returns false, the message group is ignored and
treated
* like it would not be configured at all. Useful for graceful
degradation.
@@ -66,12 +70,14 @@
* @return FFS or null
*/
public function getFFS();
+
/**
* Returns a message checker object or null.
* @todo Make an interface for message checkers.
* @return MessageChecker or null
*/
public function getChecker();
+
/**
* Return a message mangler or null.
* @todo Make an interface for message manglers
@@ -85,6 +91,7 @@
* @return MessageCollection
*/
public function initCollection( $code );
+
/**
* Returns a list of messages in a given language code. For some groups
* that list may be identical with the translation in the wiki. For
other
@@ -93,12 +100,14 @@
* @return array
*/
public function load( $code );
+
/**
* Returns message tags. If type is given, only messages keys with that
* tag is returnted. Otherwise an array[tag => keys] is returnted.
* @return array
*/
public function getTags( $type = null );
+
/**
* Returns the definition or translation for given message key in given
* language code.
@@ -145,6 +154,7 @@
public function getSourceLanguage() {
$conf = $this->getFromConf( 'BASIC', 'sourcelanguage' );
+
return $conf !== null ? $conf : 'en';
}
@@ -263,9 +273,11 @@
public function getTags( $type = null ) {
if ( $type === null ) {
$taglist = array();
+
foreach ( $this->getRawTags() as $type => $patterns ) {
$taglist[$type] = $this->parseTags( $patterns );
}
+
return $taglist;
} else {
return $this->parseTags( $this->getRawTags( $type ) );
@@ -371,7 +383,6 @@
* custom type of message groups.
*/
class FileBasedMessageGroup extends MessageGroupBase {
-
/**
* Constructs a FileBasedMessageGroup from any normal message group.
* Useful for doing special Gettext exports from any group.
@@ -391,6 +402,7 @@
'targetPattern' => '',
),
);
+
return MessageGroupBase::factory( $conf );
}
@@ -401,18 +413,21 @@
public function load( $code ) {
$ffs = $this->getFFS();
$data = $ffs->read( $code );
+
return $data ? $data['MESSAGES'] : array();
}
public function getSourceFilePath( $code ) {
if ( $this->isSourceLanguage( $code ) ) {
$pattern = $this->getFromConf( 'FILES',
'definitionFile' );
+
if ( $pattern !== null ) {
return $this->replaceVariables( $pattern, $code
);
}
}
$pattern = $this->getFromConf( 'FILES', 'sourcePattern' );
+
if ( $pattern === null ) {
throw new MWException( 'No source file pattern
defined.' );
}
@@ -470,7 +485,6 @@
public function isValidLanguage( $code ) {
return $this->mapCode( $code ) !== 'x-invalidLanguageCode';
}
-
}
/**
@@ -527,7 +541,6 @@
* - Only groups of same type and in the same namespace.
*/
class AggregateMessageGroup extends MessageGroupBase {
-
public function exists() {
// Group exists if there are any subgroups.
$exists = (bool) $this->conf['GROUPS'];
@@ -553,6 +566,7 @@
if ( !isset( $this->mangler ) ) {
$this->mangler = StringMatcher::emptyMatcher();
}
+
return $this->mangler;
}
@@ -582,8 +596,10 @@
$groups[$id] = $group;
}
+
$this->groups = $groups;
}
+
return $this->groups;
}
@@ -596,6 +612,7 @@
*/
protected function expandWildcards( $ids ) {
$hasWild = false;
+
foreach ( $ids as $id ) {
if ( strpos( $id, '*' ) !== false ) {
$hasWild = true;
@@ -603,10 +620,13 @@
}
}
- if ( !$hasWild ) return $ids;
+ if ( !$hasWild ) {
+ return $ids;
+ }
$matcher = new StringMatcher( '', $ids );
$all = array();
+
foreach ( MessageGroups::singleton()->getGroups() as $id => $_
) {
if ( $matcher->match( $id ) ) {
$all[] = $id;
@@ -617,6 +637,7 @@
public function initCollection( $code ) {
$messages = array();
+
foreach ( $this->getGroups() as $group ) {
$cache = new MessageGroupCache( $group );
if ( $cache->exists() ) {
@@ -632,6 +653,7 @@
$namespace = $this->getNamespace();
$definitions = new MessageDefinitions( $namespace, $messages );
$collection = MessageCollection::newFromDefinitions(
$definitions, $code );
+
$this->setTags( $collection );
return $collection;
@@ -640,6 +662,7 @@
public function getMessage( $key, $code ) {
$id = TranslateUtils::messageKeyToGroup( $this->getNamespace(),
$key );
$groups = $this->getGroups();
+
if ( isset( $groups[$id] ) ) {
return $groups[$id]->getMessage( $key, $code );
} else {
@@ -649,9 +672,11 @@
public function getTags( $type = null ) {
$tags = array();
+
foreach ( $this->getGroups() as $group ) {
$tags = array_merge_recursive( $tags, $group->getTags(
$type ) );
}
+
return $tags;
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs