]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - maintenance/language/languages.inc
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / maintenance / language / languages.inc
1 <?php
2 /**
3  * Handle messages in the language files.
4  *
5  * @file
6  * @ingroup MaintenanceLanguage
7  */
8
9 /**
10  * @ingroup MaintenanceLanguage
11  */
12 class languages {
13         protected $mLanguages; # List of languages
14
15         protected $mRawMessages; # Raw list of the messages in each language
16         protected $mMessages; # Messages in each language (except for English), divided to groups
17         protected $mFallback; # Fallback language in each language
18         protected $mGeneralMessages; # General messages in English, divided to groups
19         protected $mIgnoredMessages; # All the messages which should be exist only in the English file
20         protected $mOptionalMessages; # All the messages which may be translated or not, depending on the language
21
22         protected $mNamespaceNames; # Namespace names
23         protected $mNamespaceAliases; # Namespace aliases
24         protected $mMagicWords; # Magic words
25         protected $mSpecialPageAliases; # Special page aliases
26
27         /**
28          * Load the list of languages: all the Messages*.php
29          * files in the languages directory.
30          *
31          * @param $exif Treat the EXIF messages?
32          */
33         function __construct( $exif = true ) {
34                 require( dirname(__FILE__) . '/messageTypes.inc' );
35                 $this->mIgnoredMessages = $wgIgnoredMessages;
36                 if ( $exif ) {
37                         $this->mOptionalMessages = array_merge( $wgOptionalMessages );
38                 } else {
39                         $this->mOptionalMessages = array_merge( $wgOptionalMessages, $wgEXIFMessages );
40                 }
41
42                 $this->mLanguages = array_keys( Language::getLanguageNames( true ) );
43                 sort( $this->mLanguages );
44         }
45
46         /**
47          * Get the language list.
48          *
49          * @return The language list.
50          */
51         public function getLanguages() {
52                 return $this->mLanguages;
53         }
54
55         /**
56          * Get the ignored messages list.
57          *
58          * @return The ignored messages list.
59          */
60         public function getIgnoredMessages() {
61                 return $this->mIgnoredMessages;
62         }
63
64         /**
65          * Get the optional messages list.
66          *
67          * @return The optional messages list.
68          */
69         public function getOptionalMessages() {
70                 return $this->mOptionalMessages;
71         }
72
73         /**
74          * Load the language file.
75          *
76          * @param $code The language code.
77          */
78         protected function loadFile( $code ) {
79                 if ( isset( $this->mRawMessages[$code] ) &&
80                         isset( $this->mFallback[$code] ) &&
81                         isset( $this->mNamespaceNames[$code] ) &&
82                         isset( $this->mNamespaceAliases[$code] ) &&
83                         isset( $this->mMagicWords[$code] ) &&
84                         isset( $this->mSpecialPageAliases[$code] ) ) {
85                         return;
86                 }
87                 $this->mRawMessages[$code] = array();
88                 $this->mFallback[$code] = '';
89                 $this->mNamespaceNames[$code] = array();
90                 $this->mNamespaceAliases[$code] = array();
91                 $this->mMagicWords[$code] = array();
92                 $this->mSpecialPageAliases[$code] = array();
93                 $filename = Language::getMessagesFileName( $code );
94                 if ( file_exists( $filename ) ) {
95                         require( $filename );
96                         if ( isset( $messages ) ) {
97                                 $this->mRawMessages[$code] = $messages;
98                         }
99                         if ( isset( $fallback ) ) {
100                                 $this->mFallback[$code] = $fallback;
101                         }
102                         if ( isset( $namespaceNames ) ) {
103                                 $this->mNamespaceNames[$code] = $namespaceNames;
104                         }
105                         if ( isset( $namespaceAliases ) ) {
106                                 $this->mNamespaceAliases[$code] = $namespaceAliases;
107                         }
108                         if ( isset( $magicWords ) ) {
109                                 $this->mMagicWords[$code] = $magicWords;
110                         }
111                         if ( isset( $specialPageAliases ) ) {
112                                 $this->mSpecialPageAliases[$code] = $specialPageAliases;
113                         }
114                 }
115         }
116
117         /**
118          * Load the messages for a specific language (which is not English) and divide them to groups:
119          * all - all the messages.
120          * required - messages which should be translated in order to get a complete translation.
121          * optional - messages which can be translated, the fallback translation is used if not translated.
122          * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages.
123          * translated - messages which are either required or optional, but translated from English and needed.
124          *
125          * @param $code The language code.
126          */
127         private function loadMessages( $code ) {
128                 if ( isset( $this->mMessages[$code] ) ) {
129                         return;
130                 }
131                 $this->loadFile( $code );
132                 $this->loadGeneralMessages();
133                 $this->mMessages[$code]['all'] = $this->mRawMessages[$code];
134                 $this->mMessages[$code]['required'] = array();
135                 $this->mMessages[$code]['optional'] = array();
136                 $this->mMessages[$code]['obsolete'] = array();
137                 $this->mMessages[$code]['translated'] = array();
138                 foreach ( $this->mMessages[$code]['all'] as $key => $value ) {
139                         if ( isset( $this->mGeneralMessages['required'][$key] ) ) {
140                                 $this->mMessages[$code]['required'][$key] = $value;
141                                 $this->mMessages[$code]['translated'][$key] = $value;
142                         } else if ( isset( $this->mGeneralMessages['optional'][$key] ) ) {
143                                 $this->mMessages[$code]['optional'][$key] = $value;
144                                 $this->mMessages[$code]['translated'][$key] = $value;
145                         } else {
146                                 $this->mMessages[$code]['obsolete'][$key] = $value;
147                         }
148                 }
149         }
150
151         /**
152          * Load the messages for English and divide them to groups:
153          * all - all the messages.
154          * required - messages which should be translated to other languages in order to get a complete translation.
155          * optional - messages which can be translated to other languages, but it's not required for a complete translation.
156          * ignored - messages which should not be translated to other languages.
157          * translatable - messages which are either required or optional, but can be translated from English.
158          */
159         private function loadGeneralMessages() {
160                 if ( isset( $this->mGeneralMessages ) ) {
161                         return;
162                 }
163                 $this->loadFile( 'en' );
164                 $this->mGeneralMessages['all'] = $this->mRawMessages['en'];
165                 $this->mGeneralMessages['required'] = array();
166                 $this->mGeneralMessages['optional'] = array();
167                 $this->mGeneralMessages['ignored'] = array();
168                 $this->mGeneralMessages['translatable'] = array();
169                 foreach ( $this->mGeneralMessages['all'] as $key => $value ) {
170                         if ( in_array( $key, $this->mIgnoredMessages ) ) {
171                                 $this->mGeneralMessages['ignored'][$key] = $value;
172                         } else if ( in_array( $key, $this->mOptionalMessages ) ) {
173                                 $this->mGeneralMessages['optional'][$key] = $value;
174                                 $this->mGeneralMessages['translatable'][$key] = $value;
175                         } else {
176                                 $this->mGeneralMessages['required'][$key] = $value;
177                                 $this->mGeneralMessages['translatable'][$key] = $value;
178                         }
179                 }
180         }
181
182         /**
183          * Get all the messages for a specific language (not English), without the
184          * fallback language messages, divided to groups:
185          * all - all the messages.
186          * required - messages which should be translated in order to get a complete translation.
187          * optional - messages which can be translated, the fallback translation is used if not translated.
188          * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages.
189          * translated - messages which are either required or optional, but translated from English and needed.
190          *
191          * @param $code The language code.
192          *
193          * @return The messages in this language.
194          */
195         public function getMessages( $code ) {
196                 $this->loadMessages( $code );
197                 return $this->mMessages[$code];
198         }
199
200         /**
201          * Get all the general English messages, divided to groups:
202          * all - all the messages.
203          * required - messages which should be translated to other languages in order to get a complete translation.
204          * optional - messages which can be translated to other languages, but it's not required for a complete translation.
205          * ignored - messages which should not be translated to other languages.
206          * translatable - messages which are either required or optional, but can be translated from English.
207          *
208          * @return The general English messages.
209          */
210         public function getGeneralMessages() {
211                 $this->loadGeneralMessages();
212                 return $this->mGeneralMessages;
213         }
214
215         /**
216          * Get fallback language code for a specific language.
217          *
218          * @param $code The language code.
219          *
220          * @return Fallback code.
221          */
222         public function getFallback( $code ) {
223                 $this->loadFile( $code );
224                 return $this->mFallback[$code];
225         }
226
227         /**
228          * Get namespace names for a specific language.
229          *
230          * @param $code The language code.
231          *
232          * @return Namespace names.
233          */
234         public function getNamespaceNames( $code ) {
235                 $this->loadFile( $code );
236                 return $this->mNamespaceNames[$code];
237         }
238
239         /**
240          * Get namespace aliases for a specific language.
241          *
242          * @param $code The language code.
243          *
244          * @return Namespace aliases.
245          */
246         public function getNamespaceAliases( $code ) {
247                 $this->loadFile( $code );
248                 return $this->mNamespaceAliases[$code];
249         }
250
251         /**
252          * Get magic words for a specific language.
253          *
254          * @param $code The language code.
255          *
256          * @return Magic words.
257          */
258         public function getMagicWords( $code ) {
259                 $this->loadFile( $code );
260                 return $this->mMagicWords[$code];
261         }
262
263         /**
264          * Get special page aliases for a specific language.
265          *
266          * @param $code The language code.
267          *
268          * @return Special page aliases.
269          */
270         public function getSpecialPageAliases( $code ) {
271                 $this->loadFile( $code );
272                 return $this->mSpecialPageAliases[$code];
273         }
274
275         /**
276          * Get the untranslated messages for a specific language.
277          *
278          * @param $code The language code.
279          *
280          * @return The untranslated messages for this language.
281          */
282         public function getUntranslatedMessages( $code ) {
283                 $this->loadGeneralMessages();
284                 $this->loadMessages( $code );
285                 return array_diff_key( $this->mGeneralMessages['required'], $this->mMessages[$code]['required'] );
286         }
287
288         /**
289          * Get the duplicate messages for a specific language.
290          *
291          * @param $code The language code.
292          *
293          * @return The duplicate messages for this language.
294          */
295         public function getDuplicateMessages( $code ) {
296                 $this->loadGeneralMessages();
297                 $this->loadMessages( $code );
298                 $duplicateMessages = array();
299                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
300                         if ( $this->mGeneralMessages['translatable'][$key] == $value ) {
301                                 $duplicateMessages[$key] = $value;
302                         }
303                 }
304                 return $duplicateMessages;
305         }
306
307         /**
308          * Get the obsolete messages for a specific language.
309          *
310          * @param $code The language code.
311          *
312          * @return The obsolete messages for this language.
313          */
314         public function getObsoleteMessages( $code ) {
315                 $this->loadGeneralMessages();
316                 $this->loadMessages( $code );
317                 return $this->mMessages[$code]['obsolete'];
318         }
319
320         /**
321          * Get the messages whose variables do not match the original ones.
322          *
323          * @param $code The language code.
324          *
325          * @return The messages whose variables do not match the original ones.
326          */
327         public function getMessagesWithMismatchVariables( $code ) {
328                 $this->loadGeneralMessages();
329                 $this->loadMessages( $code );
330                 $variables = array( '\$1', '\$2', '\$3', '\$4', '\$5', '\$6', '\$7', '\$8', '\$9' );
331                 $mismatchMessages = array();
332                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
333                         $missing = false;
334                         foreach ( $variables as $var ) {
335                                 if ( preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
336                                         !preg_match( "/$var/sU", $value ) ) {
337                                         $missing = true;
338                                 }
339                                 if ( !preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
340                                         preg_match( "/$var/sU", $value ) ) {
341                                         $missing = true;
342                                 }
343                         }
344                         if ( $missing ) {
345                                 $mismatchMessages[$key] = $value;
346                         }
347                 }
348                 return $mismatchMessages;
349         }
350
351         /**
352          * Get the messages which do not use plural.
353          *
354          * @param $code The language code.
355          *
356          * @return The messages which do not use plural in this language.
357          */
358         public function getMessagesWithoutPlural( $code ) {
359                 $this->loadGeneralMessages();
360                 $this->loadMessages( $code );
361                 $messagesWithoutPlural = array();
362                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
363                         if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false && stripos( $value, '{{plural:' ) === false ) {
364                                 $messagesWithoutPlural[$key] = $value;
365                         }
366                 }
367                 return $messagesWithoutPlural;
368         }
369
370         /**
371          * Get the empty messages.
372          *
373          * @param $code The language code.
374          *
375          * @return The empty messages for this language.
376          */
377         public function getEmptyMessages( $code ) {
378                 $this->loadGeneralMessages();
379                 $this->loadMessages( $code );
380                 $emptyMessages = array();
381                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
382                         if ( $value === '' || $value === '-' ) {
383                                 $emptyMessages[$key] = $value;
384                         }
385                 }
386                 return $emptyMessages;
387         }
388
389         /**
390          * Get the messages with trailing whitespace.
391          *
392          * @param $code The language code.
393          *
394          * @return The messages with trailing whitespace in this language.
395          */
396         public function getMessagesWithWhitespace( $code ) {
397                 $this->loadGeneralMessages();
398                 $this->loadMessages( $code );
399                 $messagesWithWhitespace = array();
400                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
401                         if ( $this->mGeneralMessages['translatable'][$key] !== '' && $value !== rtrim( $value ) ) {
402                                 $messagesWithWhitespace[$key] = $value;
403                         }
404                 }
405                 return $messagesWithWhitespace;
406         }
407
408         /**
409          * Get the non-XHTML messages.
410          *
411          * @param $code The language code.
412          *
413          * @return The non-XHTML messages for this language.
414          */
415         public function getNonXHTMLMessages( $code ) {
416                 $this->loadGeneralMessages();
417                 $this->loadMessages( $code );
418                 $wrongPhrases = array(
419                         '<hr *\\?>',
420                         '<br *\\?>',
421                         '<hr/>',
422                         '<br/>',
423                         '<hr>',
424                         '<br>',
425                 );
426                 $wrongPhrases = '~(' . implode( '|', $wrongPhrases ) . ')~sDu';
427                 $nonXHTMLMessages = array();
428                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
429                         if ( preg_match( $wrongPhrases, $value ) ) {
430                                 $nonXHTMLMessages[$key] = $value;
431                         }
432                 }
433                 return $nonXHTMLMessages;
434         }
435
436         /**
437          * Get the messages which include wrong characters.
438          *
439          * @param $code The language code.
440          *
441          * @return The messages which include wrong characters in this language.
442          */
443         public function getMessagesWithWrongChars( $code ) {
444                 $this->loadGeneralMessages();
445                 $this->loadMessages( $code );
446                 $wrongChars = array(
447                         '[LRM]' => "\xE2\x80\x8E",
448                         '[RLM]' => "\xE2\x80\x8F",
449                         '[LRE]' => "\xE2\x80\xAA",
450                         '[RLE]' => "\xE2\x80\xAB",
451                         '[POP]' => "\xE2\x80\xAC",
452                         '[LRO]' => "\xE2\x80\xAD",
453                         '[RLO]' => "\xE2\x80\xAB",
454                         '[ZWSP]'=> "\xE2\x80\x8B",
455                         '[NBSP]'=> "\xC2\xA0",
456                         '[WJ]'  => "\xE2\x81\xA0",
457                         '[BOM]' => "\xEF\xBB\xBF",
458                         '[FFFD]'=> "\xEF\xBF\xBD",
459                 );
460                 $wrongRegExp = '/(' . implode( '|', array_values( $wrongChars ) ) . ')/sDu';
461                 $wrongCharsMessages = array();
462                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
463                         if ( preg_match( $wrongRegExp, $value ) ) {
464                                 foreach ( $wrongChars as $viewableChar => $hiddenChar ) {
465                                         $value = str_replace( $hiddenChar, $viewableChar, $value );
466                                 }
467                                 $wrongCharsMessages[$key] = $value;
468                         }
469                 }
470                 return $wrongCharsMessages;
471         }
472
473         /**
474          * Get the messages which include dubious links.
475          *
476          * @param $code The language code.
477          *
478          * @return The messages which include dubious links in this language.
479          */
480         public function getMessagesWithDubiousLinks( $code ) {
481                 $this->loadGeneralMessages();
482                 $this->loadMessages( $code );
483                 $tc = Title::legalChars() . '#%{}';
484                 $messages = array();
485                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
486                         $matches = array();
487                         preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches );
488                         for ($i = 0; $i < count($matches[0]); $i++ ) {
489                                 if ( preg_match( "/.*project.*/isDu",  $matches[1][$i] ) ) {
490                                         $messages[$key][] = $matches[0][$i];
491                                 }
492                         }
493
494
495                         if ( isset( $messages[$key] ) ) {
496                                 $messages[$key] = implode( $messages[$key],", " );
497                         }
498                 }
499                 return $messages;
500         }
501
502         /**
503          * Get the messages which include unbalanced brackets.
504          *
505          * @param $code The language code.
506          *
507          * @return The messages which include unbalanced brackets in this language.
508          */
509         public function getMessagesWithUnbalanced( $code ) {
510                 $this->loadGeneralMessages();
511                 $this->loadMessages( $code );
512                 $messages = array();
513                 foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
514                         $a = $b = $c = $d = 0;
515                         foreach ( preg_split( '//', $value ) as $char ) {
516                                 switch ( $char ) {
517                                         case '[':
518                                                 $a++;
519                                                 break;
520                                         case ']':
521                                                 $b++;
522                                                 break;
523                                         case '{':
524                                                 $c++;
525                                                 break;
526                                         case '}':
527                                                 $d++;
528                                                 break;
529                                 }
530                         }
531
532                         if ( $a !== $b || $c !== $d ) {
533                                 $messages[$key] = "$a, $b, $c, $d";
534                         }
535                         
536                 }
537                 return $messages;
538         }
539
540         /**
541          * Get the untranslated namespace names.
542          *
543          * @param $code The language code.
544          *
545          * @return The untranslated namespace names in this language.
546          */
547         public function getUntranslatedNamespaces( $code ) {
548                 $this->loadFile( 'en' );
549                 $this->loadFile( $code );
550                 $namespacesDiff = array_diff_key( $this->mNamespaceNames['en'], $this->mNamespaceNames[$code] );
551                 if ( isset( $namespacesDiff[NS_MAIN] ) ) unset( $namespacesDiff[NS_MAIN] );
552                 return $namespacesDiff;
553         }
554
555         /**
556          * Get the project talk namespace names with no $1.
557          *
558          * @param $code The language code.
559          *
560          * @return The problematic project talk namespaces in this language.
561          */
562         public function getProblematicProjectTalks( $code ) {
563                 $this->loadFile( $code );
564                 $namespaces = array();
565
566                 # Check default namespace name
567                 if( isset( $this->mNamespaceNames[$code][NS_PROJECT_TALK] ) ) {
568                         $default = $this->mNamespaceNames[$code][NS_PROJECT_TALK];
569                         if ( strpos( $default, '$1' ) === FALSE ) {
570                                 $namespaces[$default] = 'default';
571                         }
572                 }
573
574                 # Check namespace aliases
575                 foreach( $this->mNamespaceAliases[$code] as $key => $value ) {
576                         if ( $value == NS_PROJECT_TALK && strpos( $key, '$1' ) === FALSE ) {
577                                 $namespaces[$key] = '';
578                         }
579                 }
580
581                 return $namespaces;
582         }
583
584         /**
585          * Get the untranslated magic words.
586          *
587          * @param $code The language code.
588          *
589          * @return The untranslated magic words in this language.
590          */
591         public function getUntranslatedMagicWords( $code ) {
592                 $this->loadFile( 'en' );
593                 $this->loadFile( $code );
594                 $magicWords = array();
595                 foreach ( $this->mMagicWords['en'] as $key => $value ) {
596                         if ( !isset( $this->mMagicWords[$code][$key] ) ) {
597                                 $magicWords[$key] = $value[1];
598                         }
599                 }
600                 return $magicWords;
601         }
602
603         /**
604          * Get the obsolete magic words.
605          *
606          * @param $code The language code.
607          *
608          * @return The obsolete magic words in this language.
609          */
610         public function getObsoleteMagicWords( $code ) {
611                 $this->loadFile( 'en' );
612                 $this->loadFile( $code );
613                 $magicWords = array();
614                 foreach ( $this->mMagicWords[$code] as $key => $value ) {
615                         if ( !isset( $this->mMagicWords['en'][$key] ) ) {
616                                 $magicWords[$key] = $value[1];
617                         }
618                 }
619                 return $magicWords;
620         }
621
622         /**
623          * Get the magic words that override the original English magic word.
624          *
625          * @param $code The language code.
626          *
627          * @return The overriding magic words in this language.
628          */
629         public function getOverridingMagicWords( $code ) {
630                 $this->loadFile( 'en' );
631                 $this->loadFile( $code );
632                 $magicWords = array();
633                 foreach ( $this->mMagicWords[$code] as $key => $local ) {
634                         if ( !isset( $this->mMagicWords['en'][$key] ) ) {
635                                 # Unrecognized magic word
636                                 continue;
637                         }
638                         $en = $this->mMagicWords['en'][$key];
639                         array_shift( $local );
640                         array_shift( $en );
641                         foreach ( $en as $word ) {
642                                 if ( !in_array( $word, $local ) ) {
643                                         $magicWords[$key] = $word;
644                                         break;
645                                 }
646                         }
647                 }
648                 return $magicWords;
649         }
650
651         /**
652          * Get the magic words which do not match the case-sensitivity of the original words.
653          *
654          * @param $code The language code.
655          *
656          * @return The magic words whose case does not match in this language.
657          */
658         public function getCaseMismatchMagicWords( $code ) {
659                 $this->loadFile( 'en' );
660                 $this->loadFile( $code );
661                 $magicWords = array();
662                 foreach ( $this->mMagicWords[$code] as $key => $local ) {
663                         if ( !isset( $this->mMagicWords['en'][$key] ) ) {
664                                 # Unrecognized magic word
665                                 continue;
666                         }
667                         if ( $local[0] != $this->mMagicWords['en'][$key][0] ) {
668                                 $magicWords[$key] = $local[0];
669                         }
670                 }
671                 return $magicWords;
672         }
673
674         /**
675          * Get the untranslated special page names.
676          *
677          * @param $code The language code.
678          *
679          * @return The untranslated special page names in this language.
680          */
681         public function getUntraslatedSpecialPages( $code ) {
682                 $this->loadFile( 'en' );
683                 $this->loadFile( $code );
684                 $specialPageAliases = array();
685                 foreach ( $this->mSpecialPageAliases['en'] as $key => $value ) {
686                         if ( !isset( $this->mSpecialPageAliases[$code][$key] ) ) {
687                                 $specialPageAliases[$key] = $value[0];
688                         }
689                 }
690                 return $specialPageAliases;
691         }
692
693         /**
694          * Get the obsolete special page names.
695          *
696          * @param $code The language code.
697          *
698          * @return The obsolete special page names in this language.
699          */
700         public function getObsoleteSpecialPages( $code ) {
701                 $this->loadFile( 'en' );
702                 $this->loadFile( $code );
703                 $specialPageAliases = array();
704                 foreach ( $this->mSpecialPageAliases[$code] as $key => $value ) {
705                         if ( !isset( $this->mSpecialPageAliases['en'][$key] ) ) {
706                                 $specialPageAliases[$key] = $value[0];
707                         }
708                 }
709                 return $specialPageAliases;
710         }
711 }
712
713 class extensionLanguages extends languages {
714         private $mMessageGroup; # The message group
715
716         /**
717          * Load the messages group.
718          * @param $group The messages group.
719          */
720         function __construct( MessageGroup $group ) {
721                 $this->mMessageGroup = $group;
722
723                 $bools = $this->mMessageGroup->getBools();
724                 $this->mIgnoredMessages = $bools['ignored'];
725                 $this->mOptionalMessages = $bools['optional'];
726         }
727
728         /**
729          * Get the extension name.
730          *
731          * @return The extension name.
732          */
733         public function name() {
734                 return $this->mMessageGroup->getLabel();
735         }
736
737         /**
738          * Load the language file.
739          *
740          * @param $code The language code.
741          */
742         protected function loadFile( $code ) {
743                 if( !isset( $this->mRawMessages[$code] ) ) {
744                         $this->mRawMessages[$code] = $this->mMessageGroup->load( $code );
745                         if( empty( $this->mRawMessages[$code] ) ) {
746                                 $this->mRawMessages[$code] = array();
747                         }
748                 }
749         }
750 }