r94305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94304‎ | r94305 | r94306 >
Date:23:53, 11 August 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
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 (modified) (history)
  • /trunk/tools/ToolserverI18N/public_html/index.php (modified) (history)

Diff [purge]

Index: trunk/tools/ToolserverI18N/TsIntuition.php
@@ -612,9 +612,25 @@
613613 return is_array( $this->langNames ) ? $this->langNames : array();
614614 }
615615
616 - public function getAvailableLangs() {
 616+ /**
 617+ * Return all languages loaded in at least one domain
 618+ * @param $domain
 619+ * false - Show languages for which there is a translation in the current domain
 620+ * 'any' - Show languages for which there is a translation in at least one domain
 621+ * domain name - Show languages for which there is a translation in the given domain
 622+ */
 623+ public function getAvailableLangs($domain = 'any') {
 624+ if ( $domain == 'any' ) {
 625+ $from = $this->availableLanguages;
 626+ } else {
 627+ if ( $domain === false )
 628+ $domain = $this->getDomain();
 629+
 630+ $from = $messageBlob[$domain];
 631+ }
 632+
617633 $return = array();
618 - foreach( array_keys( $this->availableLanguages ) as $lang ) {
 634+ foreach( array_keys( $from ) as $lang ) {
619635 $return[$lang] = $this->getLangName( $lang );
620636 }
621637 ksort( $return );
Index: trunk/tools/ToolserverI18N/public_html/index.php
@@ -33,7 +33,7 @@
3434
3535 $I18N = new TsIntuition( $opts );
3636
37 -// Load all domains so can get some statistics later on and
 37+// Load all domains so we can get some statistics later on and
3838 // make sure "getAvailableLangs" is compelte
3939 foreach ( $I18N->getAllRegisteredDomains() as $domainKey => $domainInfo ) {
4040 $I18N->loadTextdomain( $domainKey );
@@ -213,7 +213,7 @@
214214 // XXX: Quick way to build the form
215215 $dropdown = '<select name="fpLang">';
216216 $selected = ' selected="selected"';
217 -foreach ( $I18N->getAvailableLangs() as $langCode => $langName ) {
 217+foreach ( $I18N->getAvailableLangs( 'any' ) as $langCode => $langName ) {
218218 $attr = $langCode == $I18N->getLang() ? $selected : '';
219219 $dropdown .= '<option value="' . $langCode . '"' . $attr . '>' . "$langCode - $langName" . '</option>';
220220 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94308Follow up r94305. But still, things don't seem to be right...platonides00:04, 12 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84981Continue implementation of spec + added some stuff that I had in the TS worki...krinkle21:14, 29 March 2011

Comments

#Comment by Platonides (talk | contribs)   15:26, 18 September 2011

This didn't change the default, since the default parameter of $domain is still 'any'

Status & tagging log