695927fb12cc0819d5fcbd0e2314ca519d9261a3
3 * Copyright (C) 2007 Ashar Voultoiz <hashar@altern.org>
6 * Copyright (C) 2005 Brion Vibber <brion@pobox.com>
8 * http://www.mediawiki.org
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 * @subpackage SpecialPage
30 # Lacking documentation. An example is:
31 # php checkExtensioni18n.php /opt/mw/extensions/CentralAuth/CentralAuth.i18n.php wgCentralAuthMessages
34 require_once( dirname(__FILE__
).'/../commandLine.inc' );
35 require_once( 'languages.inc' );
36 require_once( 'checkLanguage.inc' );
38 class extensionLanguages
extends languages
{
39 private $mExt18nFilename, $mExtArrayName ;
42 function __construct( $ext18nFilename, $extArrayName ) {
44 $this->mExt18nFilename
= $ext18nFilename;
45 $this->mExtArrayName
= $extArrayName;
47 $this->mIgnoredMessages
= array() ;
48 $this->mOptionalMessages
= array() ;
50 if ( file_exists( $this->mExt18nFilename
) ) {
51 require_once( $this->mExt18nFilename
);
52 $this->mExtArray
= $
{$this->mExtArrayName
} ;
53 $this->mLanguages
= array_keys( $this->mExtArray
);
55 wfDie( "File $this->mExt18nFilename not found\n" );
59 protected function loadRawMessages( $code ) {
60 if ( isset( $this->mRawMessages
[$code] ) ) {
63 if( isset( $this->mExtArray
[$code] ) ) {
64 $this->mRawMessages
[$code] = $this->mExtArray
[$code] ;
66 $this->mRawMessages
[$code] = array();
70 public function getLanguages() {
71 return $this->mLanguages
;
79 Usage: php checkExtensioni18n.php <filename> <arrayname>
87 if ( isset( $argv[0] ) ) {
89 if (file_exists( $argv[0] ) ) {
92 print "Unable to open file '{$argv[0]}'\n";
96 if ( isset( $argv[1] ) ) {
97 $arrayname = $argv[1];
99 print "You must give an array name to be checked\n";
106 $extLanguages = new extensionLanguages($filename, $arrayname);
108 // Stuff needed by the checkLanguage routine (globals)
109 $wgGeneralMessages = $extLanguages->getGeneralMessages();
110 $wgRequiredMessagesNumber = count( $wgGeneralMessages['required'] );
112 $wgChecks = array( 'untranslated', 'obsolete', 'variables', 'empty', 'whitespace', 'xhtml', 'chars' );
114 foreach( $extLanguages->getLanguages() as $lang ) {
115 if( $lang == 'en' ) {
116 print "Skipped english language\n";
119 checkLanguage( $extLanguages, $lang );
121 print "== $lang ==\n";
122 print count($ext->getUntranslatedMessages( $lang ) ) . "\n";
123 print count($ext->getEmptyMessages( $lang ) ) . "\n";