http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94305
Revision: 94305
Author: platonides
Date: 2011-08-11 23:53:48 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
Change getAvailableLangs (added in r84981) to return by default the languages
available
in the main domain, which is what I think most tools would need.
'Helper' domains such as General will have much more translations than the tool
itself,
but showing all those language as available would be deceiving (OTOH, if they
happen to
have such enable from the Intuition board, or if they manually hack the url, it
still works).
The old $I18N->getAvailableLangs() behavior is now available with
$I18N->getAvailableLangs('any');
The only usage of getAvailableLangs was in searchPage.php of Monuments API,
which is well-filled.
Modified Paths:
--------------
trunk/tools/ToolserverI18N/TsIntuition.php
trunk/tools/ToolserverI18N/public_html/index.php
Modified: trunk/tools/ToolserverI18N/TsIntuition.php
===================================================================
--- trunk/tools/ToolserverI18N/TsIntuition.php 2011-08-11 23:43:52 UTC (rev
94304)
+++ trunk/tools/ToolserverI18N/TsIntuition.php 2011-08-11 23:53:48 UTC (rev
94305)
@@ -612,9 +612,25 @@
return is_array( $this->langNames ) ? $this->langNames :
array();
}
- public function getAvailableLangs() {
+ /**
+ * Return all languages loaded in at least one domain
+ * @param $domain
+ * false - Show languages for which there is a translation in the
current domain
+ * 'any' - Show languages for which there is a translation in at least
one domain
+ * domain name - Show languages for which there is a translation in
the given domain
+ */
+ public function getAvailableLangs($domain = 'any') {
+ if ( $domain == 'any' ) {
+ $from = $this->availableLanguages;
+ } else {
+ if ( $domain === false )
+ $domain = $this->getDomain();
+
+ $from = $messageBlob[$domain];
+ }
+
$return = array();
- foreach( array_keys( $this->availableLanguages ) as $lang ) {
+ foreach( array_keys( $from ) as $lang ) {
$return[$lang] = $this->getLangName( $lang );
}
ksort( $return );
Modified: trunk/tools/ToolserverI18N/public_html/index.php
===================================================================
--- trunk/tools/ToolserverI18N/public_html/index.php 2011-08-11 23:43:52 UTC
(rev 94304)
+++ trunk/tools/ToolserverI18N/public_html/index.php 2011-08-11 23:53:48 UTC
(rev 94305)
@@ -33,7 +33,7 @@
$I18N = new TsIntuition( $opts );
-// Load all domains so can get some statistics later on and
+// Load all domains so we can get some statistics later on and
// make sure "getAvailableLangs" is compelte
foreach ( $I18N->getAllRegisteredDomains() as $domainKey => $domainInfo ) {
$I18N->loadTextdomain( $domainKey );
@@ -213,7 +213,7 @@
// XXX: Quick way to build the form
$dropdown = '<select name="fpLang">';
$selected = ' selected="selected"';
-foreach ( $I18N->getAvailableLangs() as $langCode => $langName ) {
+foreach ( $I18N->getAvailableLangs( 'any' ) as $langCode => $langName ) {
$attr = $langCode == $I18N->getLang() ? $selected : '';
$dropdown .= '<option value="' . $langCode . '"' . $attr . '>' .
"$langCode - $langName" . '</option>';
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs