r25252 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25251‎ | r25252 | r25253 >
Date:19:30, 28 August 2007
Author:nikerabbit
Status:old
Tags:
Comment:
* Bug fixed, some new extensions to the list, rescued some translations
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/TranslateTasks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.i18n.php
@@ -22,4 +22,185 @@
2323
2424 'translate-optional' => '(optional)',
2525 'translate-ignored' => '(ignored)',
26 -);
\ No newline at end of file
 26+
 27+ 'translate-edit-message-format' => 'The format of this message is <b>$1</b>.',
 28+ 'translate-edit-message-in' => 'Current string in <b>$1</b> ($2):',
 29+ 'translate-edit-message-in-fb' => 'Current string in fallback language <b>$1</b> ($2):',
 30+);
 31+
 32+
 33+
 34+$wgTranslateMessages['ar'] = array(
 35+ 'translate' => 'ترجمة',
 36+);
 37+
 38+$wgTranslateMessages['br'] = array(
 39+ 'translate' => 'Treiñ',
 40+ 'translate-edit-message-format' => 'Furmad ar gemennadenn-mañ zo <b>$1</b>.',
 41+ 'translate-edit-message-in' => 'Neudennad red e <b>$1</b> ($2):',
 42+ 'translate-edit-message-in-fb' => 'Neudennad red er yezh kein <b>$1</b> ($2):',
 43+);
 44+
 45+$wgTranslateMessages['ca'] = array(
 46+ 'translate'=> 'Tradueix',
 47+ 'translate-edit-message-in'=> 'Cadena actual en <strong>$1</strong> ($2):',
 48+ 'translate-edit-message-in-fb'=> 'Cadena actual en la llengua per defecte <strong>$1</strong> (2):',
 49+);
 50+
 51+$wgTranslateMessages['cs'] = array(
 52+ 'translate' => 'Přeložit',
 53+ 'translate-edit-message-in' => 'Současný řetězec v <b>$1</b> ($2):',
 54+ 'translate-edit-message-in-fb' => 'Současný řetězec v záložním jazyce <b>$1</b> ($2):',
 55+);
 56+
 57+/* German by Raymond */
 58+$wgTranslateMessages['de'] = array(
 59+ 'translate' => 'Übersetze',
 60+ 'translate-edit-message-format' => 'Das Format dieser Nachricht ist <b>$1</b>.',
 61+ 'translate-edit-message-in' => 'Aktueller Text in <b>$1</b> ($2):',
 62+ 'translate-edit-message-in-fb' => 'Aktueller Text in der Ausweich-Sprache <b>$1</b> ($2):',
 63+);
 64+
 65+$wgTranslateMessages['fr'] = array(
 66+ 'translate' => 'Traduire',
 67+ 'translate-edit-message-format' => 'Le format de ce message est <b>$1</b>.',
 68+ 'translate-edit-message-in' => 'Chaîne actuellement dans <b>$1</b> ($2) :',
 69+ 'translate-edit-message-in-fb' => 'Chaîne actuellement dans la langue par défaut <b>$1</b> ($2) :',
 70+);
 71+
 72+$wgTranslateMessages['he'] = array(
 73+ 'translate' => 'תרגום',
 74+ 'translate-edit-message-format' => 'המבנה של הודעה זו הוא <b>$1</b>.',
 75+ 'translate-edit-message-in' => 'המחרוזת הנוכחית ל־<b>$1</b> ($2):',
 76+ 'translate-edit-message-in-fb' => 'המחרוזת הנוכחית ל־<b>$1</b> בשפת הגיבוי ($2):',
 77+);
 78+
 79+$wgTranslateMessages['id'] = array(
 80+ 'translate' => 'Terjemahan',
 81+ 'translate-edit-message-format' => 'Format pesan ini adalah <b>$1</b>.',
 82+ 'translate-edit-message-in' => 'Kalimat dalam <b>$1</b> ($2):',
 83+ 'translate-edit-message-in-fb' => 'Kalimat dalam bahasa <b>$1</b> ($2):',
 84+);
 85+
 86+$wgTranslateMessages['it'] = array(
 87+ 'translate' => 'Traduzione',
 88+ 'translate-edit-message-format' => 'Formato del messaggio: <b>$1</b>.',
 89+ 'translate-edit-message-in' => 'Contenuto attuale in <b>$1</b> ($2):',
 90+ 'translate-edit-message-in-fb' => 'Contenuto attuale nella lingua di riserva <b>$1</b> ($2):',
 91+);
 92+
 93+$wgTranslateMessages['ja'] = array(
 94+ 'translate' => 'インターフェースの翻訳',
 95+ 'translate-edit-message-format' => 'このメッセージの書式は <b>$1</b> です。',
 96+ 'translate-edit-message-in' => '<b>$1</b> ($2) での現在の文字列:',
 97+);
 98+
 99+$wgTranslateMessages['kk-kz'] = array(
 100+ 'translate' => 'Аудару',
 101+ 'translate-edit-message-format' => 'Бұл хабардың пішімі - <b>$1</b>.',
 102+ 'translate-edit-message-in' => '<b>$1</b> ($2) дегендегі ағымдағы жол:',
 103+ 'translate-edit-message-in-fb' => '<b>$1</b> ($2) деген сүйену тілінде ағымдағы жол:',
 104+);
 105+$wgTranslateMessages['kk-tr'] = array(
 106+ 'translate' => 'Awdarw',
 107+ 'translate-edit-message-format' => 'Bul xabardıñ pişimi - <b>$1</b>.',
 108+ 'translate-edit-message-in' => '<b>$1</b> ($2) degendegi ağımdağı jol:',
 109+ 'translate-edit-message-in-fb' => '<b>$1</b> ($2) degen süýenw tilinde ağımdağı jol:',
 110+);
 111+$wgTranslateMessages['kk-cn'] = array(
 112+ 'translate' => 'اۋدارۋ',
 113+ 'translate-edit-message-format' => 'بۇل حاباردىڭ پٸشٸمٸ - <b>$1</b>.',
 114+ 'translate-edit-message-in' => '<b>$1</b> ($2) دەگەندەگٸ اعىمداعى جول:',
 115+ 'translate-edit-message-in-fb' => '<b>$1</b> ($2) دەگەن سٷيەنۋ تٸلٸندە اعىمداعى جول:',
 116+);
 117+$wgTranslateMessages['kk'] = $wgTranslateMessages['kk-kz'];
 118+
 119+$wgTranslateMessages['nl'] = array(
 120+ 'translate' => 'Vertalen',
 121+ 'translate-edit-message-in' => 'Huidige tekst in <b>$1</b> ($2):',
 122+ 'translate-edit-message-in-fb' => 'Huidige tekst in alternatieve taal <b>$1</b> ($2):',
 123+);
 124+
 125+$wgTranslateMessages['no'] = array(
 126+ 'translate' => 'Oversett',
 127+ 'translate-edit-message-format' => 'Formatet på denne meldingen er <b>$1</b>.',
 128+ 'translate-edit-message-in' => 'Nåværende streng i <b>$1</b> ($2):',
 129+ 'translate-edit-message-in-fb' => 'Nåværende streng i reservespråk <b>$1</b> ($2):',
 130+);
 131+
 132+$wgTranslateMessages['oc'] = array(
 133+ 'translate' => 'Revirar',
 134+ 'translate-edit-message-format' => 'Lo format d\'aqueste messatge es <b>$1</b>.',
 135+ 'translate-edit-message-in' => 'Cadena actualament dins <b>$1</b> ($2) :',
 136+ 'translate-edit-message-in-fb' => 'Cadena actualament dins la lenga per defaut <b>$1</b> ($2) :',
 137+);
 138+
 139+/* Piedmontese (Bèrto 'd Sèra) */
 140+$wgTranslateMessages['pms'] = array(
 141+ 'translate' => 'Viragi',
 142+ 'translate-edit-message-format' => 'La forma d\'ës messagi-sì a l\'é <b>$1</b>.',
 143+ 'translate-edit-message-in' => 'Espression corenta an <b>$1</b> ($2):',
 144+ 'translate-edit-message-in-fb' => 'Espression corenta ant la lenga ëd riserva <b>$1</b> ($2):',
 145+);
 146+
 147+$wgTranslateMessages['ru'] = array(
 148+ 'translate' => 'Перевод',
 149+ 'translate-edit-message-format' => 'Формат текущего сообщения - <b>$1</b>.',
 150+ 'translate-edit-message-in' => 'Текущее выражение на языке <b>$1</b> ($2):',
 151+ 'translate-edit-message-in-fb' => 'Текущее выражение на базовом языке <b>$1</b> ($2):',
 152+);
 153+
 154+$wgTranslateMessages['sk'] = array(
 155+ 'translate' => 'Preložiť',
 156+ 'translate-edit-message-format' => 'Formát tejto správy je <b>$1</b>.',
 157+ 'translate-edit-message-in' => 'Aktuálny reťazec v jazyku <b>$1</b> ($2):',
 158+ 'translate-edit-message-in-fb' => 'Aktuálny reťazec v jazyku <b>$1</b>, ktorý sa použije ak správa nie je preložená ($2):',
 159+);
 160+
 161+$wgTranslateMessages['sr-ec'] = array(
 162+ 'translate' => 'Превод',
 163+ 'translate-edit-message-in' => 'Тренутни стринг у <b>$1</b> ($2):',
 164+ 'translate-edit-message-in-fb' => 'Тренутни стринг у језику <b>$1</b> ($2):',
 165+);
 166+
 167+$wgTranslateMessages['sr-el'] = array(
 168+ 'translate' => 'Prevod',
 169+ 'translate-edit-message-in' => 'Trenutni string u <b>$1</b> ($2):',
 170+ 'translate-edit-message-in-fb' => 'Trenutni string u jeziku <b>$1</b> ($2):',
 171+);
 172+
 173+$wgTranslateMessages['sr'] = $wgTranslateMessages['sr-ec'];
 174+
 175+$wgTranslateMessages['su'] = array(
 176+ 'translate' => 'Alih basakeun',
 177+ 'translate-edit-message-format' => 'Ieu talatah boga format <b>$1</b>.',
 178+ 'translate-edit-message-in' => 'String kiwari dina <b>$1</b> ($2):',
 179+ 'translate-edit-message-in-fb' => 'String kiwari dina basa fallback <b>$1</b> ($2):',
 180+);
 181+
 182+$wgTranslateMessages['yue'] = array(
 183+ 'translate' => '翻譯',
 184+ 'translate-edit-message-format' => '呢句信息嘅格式係 <b>$1</b>。',
 185+ 'translate-edit-message-in' => '響 <b>$1</b> 嘅現行字串 ($2):',
 186+ 'translate-edit-message-in-fb' => '響 <b>$1</b> 於倚靠語言中嘅現行字串 ($2):',
 187+);
 188+
 189+$wgTranslateMessages['zh-hans'] = array(
 190+ 'translate' => '翻译',
 191+ 'translate-edit-message-format' => '这句信息的格式是 <b>$1</b>。',
 192+ 'translate-edit-message-in' => '在 <b>$1</b> 的当前字串 ($2):',
 193+ 'translate-edit-message-in-fb' => '在 <b>$1</b> 于倚靠语言中的当前字串 ($2):',
 194+);
 195+
 196+$wgTranslateMessages['zh-hant'] = array(
 197+ 'translate' => '翻譯',
 198+ 'translate-edit-message-format' => '這句信息的格式是 <b>$1</b>。',
 199+ 'translate-edit-message-in' => '在 <b>$1</b> 的現行字串 ($2):',
 200+ 'translate-edit-message-in-fb' => '在 <b>$1</b> 於倚靠語言中的現行字串 ($2):',
 201+);
 202+
 203+$wgTranslateMessages['zh-cn'] = $wgTranslateMessages['zh-hans'];
 204+$wgTranslateMessages['zh-hk'] = $wgTranslateMessages['zh-hant'];
 205+$wgTranslateMessages['zh-sg'] = $wgTranslateMessages['zh-hans'];
 206+$wgTranslateMessages['zh-tw'] = $wgTranslateMessages['zh-hant'];
 207+$wgTranslateMessages['zh-yue'] = $wgTranslateMessages['yue'];
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -33,6 +33,8 @@
3434 $rows = count(explode("\n", $msg)) -1;
3535 $rows = max(3, min(15, $rows));
3636
 37+ wfLoadExtensionMessages( 'Translate' );
 38+
3739 return
3840 wfMsg( $i18nmsg, $names[$code], $prettyCode ) . " " .
3941 Xml::Element( 'textarea', array( 'rows' => $rows ), $msg );
Index: trunk/extensions/Translate/Translate.php
@@ -12,7 +12,7 @@
1313
1414 $wgExtensionCredits['specialpage'][] = array(
1515 'name' => 'Translate',
16 - 'version' => '4.0-rc2',
 16+ 'version' => '4.0-rc3',
1717 'author' => 'Niklas Laxström',
1818 'description' => 'Special page for translating Mediawiki and beyond'
1919 );
@@ -55,6 +55,7 @@
5656 'ext-citespecial' => 'CiteSpecialMessageGroup',
5757 'ext-confiraccount' => 'ConfirmAccountMessageGroup',
5858 'ext-confirmedit' => 'ConfirmEditMessageGroup',
 59+'ext-contactpage' => 'ContactPageExtensionGroup',
5960 'ext-contributors' => 'ContributorsMessageGroup',
6061 'ext-countedits' => 'CountEditsMessageGroup',
6162 'ext-crossnamespacelinks' => 'CrossNamespaceLinksMessageGroup',
@@ -74,6 +75,7 @@
7576 'ext-makevalidate' => 'MakeValidateMessageGroup',
7677 'ext-minidonation' => 'MiniDonationMessageGroup',
7778 'ext-minimumnamelength' => 'MinimumNameLengthMessageGroup',
 79+'ext-newestpages' => 'NewestPagesMessageGroup',
7880 'ext-newuserlog' => 'NewuserLogMessageGroup',
7981 'ext-ogghandler' => 'OggHandlerMessageGroup',
8082 'ext-patroller' => 'PatrollerMessageGroup',
Index: trunk/extensions/Translate/TranslateTasks.php
@@ -32,6 +32,7 @@
3333
3434 }
3535
 36+
3637 abstract class TranslateTask {
3738 abstract function getId();
3839 public function getLabel() {
@@ -155,7 +156,7 @@
156157
157158 protected function filterTranslated() {
158159 foreach ( $this->messages as $key => $o ) {
159 - if ( ($o['database'] !== null || $o['infile'] !== null ) && !strstr($o['infile'], '!!FUZZY!!') ) {
 160+ if ( ($o['database'] !== null || $o['infile'] !== null ) && !strstr($o['infile'], '!!FUZZY!!') ) {
160161 unset( $this->messages[$key] );
161162 }
162163 }
Index: trunk/extensions/Translate/MessageGroups.php
@@ -139,8 +139,12 @@
140140 }
141141
142142 foreach ( $array as $key => $value ) {
143 - $array[$key]['infile'] = isset( $infile[$key] ) ? $infile[$key] : null;
144 - $array[$key]['fallback'] = isset( $infbfile[$key] ) ? $infbfile[$key] : null;
 143+ if ( isset($infile[$key]) ) {
 144+ $array[$key]['infile'] = $infile[$key];
 145+ }
 146+ if ( isset($infbfile[$key]) ) {
 147+ $array[$key]['fallback'] = $infbfile[$key];
 148+ }
145149 }
146150 }
147151 }
@@ -253,10 +257,12 @@
254258 }
255259
256260 foreach ( $array as $key => $value ) {
257 - $array[$key]['infile'] = isset( $this->msgArray[$code][$key] ) ?
258 - $this->msgArray[$code][$key] : null;
259 - $array[$key]['infbfile'] = isset( $this->msgArray[$fbcode][$key] ) ?
260 - $this->msgArray[$fbcode][$key] : null;
 261+ if ( isset($this->msgArray[$code][$key]) ) {
 262+ $array[$key]['infile'] = $this->msgArray[$code][$key];
 263+ }
 264+ if ( isset($this->msgArray[$fbcode][$key]) ) {
 265+ $array[$key]['infbfile'] = $this->msgArray[$fbcode][$key];
 266+ }
261267 }
262268 }
263269
@@ -305,12 +311,9 @@
306312
307313 private $classes = null;
308314
309 - function __construct() {}
310 -
311315 private function init() {
312316 if ( $this->classes === null ) {
313 - $MG = MessageGroups::singleton();
314 - $this->classes = $MG->getGroups();
 317+ $this->classes = MessageGroups::singleton()->getGroups();
315318 foreach ( $this->classes as $index => $class ) {
316319 if ( (strpos( $class->getId(), 'ext-' ) !== 0) || (strpos( $class->getId(), 'ext-0' ) === 0) ) {
317320 unset( $this->classes[$index] );
@@ -319,6 +322,27 @@
320323 }
321324 }
322325
 326+ protected function load( $code = '' ) {
 327+ if ( $code === '' ) return;
 328+
 329+ $this->init();
 330+
 331+ foreach ( $this->classes as $class ) {
 332+ $class->load( $code );
 333+ }
 334+
 335+ }
 336+
 337+ public function getMessage( $key, $code ) {
 338+ $this->load( $code );
 339+ $msg = null;
 340+ foreach ( $this->classes as $class ) {
 341+ $msg = $class->getMessage( $key, $code );
 342+ if ( $msg !== null ) return $msg;
 343+ }
 344+ return null;
 345+ }
 346+
323347 function getDefinitions() {
324348 $this->init();
325349 $array = array();
@@ -329,14 +353,18 @@
330354 }
331355
332356 function export( &$array, $code ) {
333 - $this->msgArray['en'] = $this->getDefinitions();
334 - parent::export( &$array, $code );
 357+ $this->init();
 358+ $ret = '';
 359+ foreach ( $this->classes as $class ) {
 360+ $ret .= $class->export( &$array, $code ) . "\n\n\n";
 361+ }
 362+ return $ret;
335363 }
336364
337 - function fill( &$array, $language ) {
 365+ function fill( &$array, $code ) {
338366 $this->init();
339367 foreach ( $this->classes as $class ) {
340 - $class->fill( &$array, $language );
 368+ $class->fill( &$array, $code );
341369 }
342370 }
343371
@@ -516,6 +544,21 @@
517545 protected $exportPad = 30;
518546 }
519547
 548+class ContactPageExtensionGroup extends MultipleFileMessageGroup {
 549+ protected $label = 'Extension: Contact Page';
 550+ protected $id = 'ext-contactpage';
 551+
 552+ protected $arrName = 'messages';
 553+ protected $messageFile = 'ContactPage/ContactPage.i18n.php';
 554+ protected $filePattern = 'ContactPage/ContactPage.i18n.$CODE.php';
 555+
 556+ protected $exportStart = '$messages[\'$CODE\'] = array(';
 557+ protected $exportLineP = '';
 558+ protected $exportEnd = '),';
 559+
 560+}
 561+
 562+
520563 class ContributorsMessageGroup extends ExtensionMessageGroup {
521564 protected $label = 'Extension: Contributors';
522565 protected $id = 'ext-contributors';
@@ -748,6 +791,18 @@
749792 protected $exportEnd = '),';
750793 }
751794
 795+class NewestPagesMessageGroup extends ExtensionMessageGroup {
 796+ protected $label = 'Extension: Newest Pages';
 797+ protected $id = 'ext-newestpages';
 798+
 799+ protected $functionName = 'efNewestPagesMessages';
 800+ protected $messageFile = 'NewestPages/NewestPages.i18n.php';
 801+
 802+ protected $exportStart = '\'$CODE\' => array(';
 803+ protected $exportLineP = '';
 804+ protected $exportEnd = '),';
 805+}
 806+
752807 class NewuserLogMessageGroup extends ExtensionMessageGroup {
753808 protected $label = 'Extension: Newuser Log';
754809 protected $id = 'ext-newuserlog';
@@ -961,9 +1016,10 @@
9621017 $this->load( $code );
9631018
9641019 foreach ( $array as $key => $value ) {
965 - $infile = isset($this->msgArray[$code][$key]) ? $this->msgArray[$code][$key] : null ;
9661020 $array[$key]['definition'] = $this->msgArray['en'][$key];
967 - $array[$key]['infile'] = $infile;
 1021+ if ( isset($this->msgArray[$code][$key]) ) {
 1022+ $array[$key]['infile'] = $this->msgArray[$code][$key];
 1023+ }
9681024 }
9691025 }
9701026

Status & tagging log