X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Flanguage%2FcheckLanguage.inc;h=1e4b94a2f649f5b385bb99593100dd8449c894eb;hb=92cc0f4fd2cad9efda4575a040cc26801063e5d9;hp=52281b575bbcdd46aaa98bed5b729fecfbb9808f;hpb=31c5be42b8de2e441fac6316664e2b52a572d004;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc index 52281b575b..1e4b94a2f6 100644 --- a/maintenance/language/checkLanguage.inc +++ b/maintenance/language/checkLanguage.inc @@ -1,12 +1,34 @@ help(); - exit(); + exit(1); } if ( isset( $options['lang'] ) ) { @@ -42,6 +64,10 @@ class CheckLanguageCLI { $this->includeExif = !isset( $options['noexif'] ); $this->checkAll = isset( $options['all'] ); + if ( isset( $options['prefix'] ) ) { + $this->linksPrefix = $options['prefix']; + } + if ( isset( $options['wikilang'] ) ) { $this->wikiCode = $options['wikilang']; } @@ -92,7 +118,7 @@ class CheckLanguageCLI { /** * Get the checks that can easily be treated by non-speakers of the language. - * @return A list of the easy checks. + * @return Array A list of the easy checks. */ protected function easyChecks() { return array( @@ -185,16 +211,23 @@ class CheckLanguageCLI { Run this script to check a specific language file, or all of them. Command line settings are in form --parameter[=value]. Parameters: - * lang: Language code (default: the installation default language). - * all: Check all customized languages. - * help: Show this help. - * level: Show the following display level (default: 2). - * links: Link the message values (default off). - * wikilang: For the links, what is the content language of the wiki to display the output in (default en). - * whitelist: Do only the following checks (form: code,code). - * blacklist: Don't do the following checks (form: code,code). - * easy: Do only the easy checks, which can be treated by non-speakers of the language. - * noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know that they are currently not translated and want to focus on other problems (default off). + --help: Show this help. + --lang: Language code (default: the installation default language). + --all: Check all customized languages. + --level: Show the following display level (default: 2): + * 0: Skip the checks (useful for checking syntax). + * 1: Show only the stub headers and number of wrong messages, without list of messages. + * 2: Show only the headers and the message keys, without the message values. + * 3: Show both the headers and the complete messages, with both keys and values. + --links: Link the message values (default off). + --prefix: prefix to add to links. + --wikilang: For the links, what is the content language of the wiki to display the output in (default en). + --noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know + that they are currently not translated and want to focus on other problems (default off). + --whitelist: Do only the following checks (form: code,code). + --blacklist: Don't do the following checks (form: code,code). + --easy: Do only the easy checks, which can be treated by non-speakers of the language. + Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc): * untranslated: Messages which are required to translate, but are not translated. * duplicate: Messages which translation equal to fallback @@ -214,11 +247,6 @@ Check codes (ideally, all of them should result 0; all the checks are executed b * magic-case: Magic words whose translation changes the case-sensitivity of the original English word. * special: Special page names that were not translated. * special-old: Special page names which do not exist. -Display levels (default: 2): - * 0: Skip the checks (useful for checking syntax). - * 1: Show only the stub headers and number of wrong messages, without list of messages. - * 2: Show only the headers and the message keys, without the message values. - * 3: Show both the headers and the complete messages, with both keys and values. ENDS; } @@ -292,7 +320,7 @@ ENDS; foreach ( $this->checks as $check ) { if ( isset( $checkBlacklist[$code] ) && in_array( $check, $checkBlacklist[$code] ) ) { - $result[$check] = array(); + $results[$check] = array(); continue; } @@ -316,9 +344,9 @@ ENDS; if ( $this->doLinks ) { $displayKey = ucfirst( $key ); if ( $code == $this->wikiCode ) { - return "[[MediaWiki:$displayKey|$key]]"; + return "[[{$this->linksPrefix}MediaWiki:$displayKey|$key]]"; } else { - return "[[MediaWiki:$displayKey/$code|$key]]"; + return "[[{$this->linksPrefix}MediaWiki:$displayKey/$code|$key]]"; } } else { return $key; @@ -376,9 +404,9 @@ ENDS; * @return The checks results as wiki text. */ function outputWiki() { - global $wgContLang, $IP; + global $wgContLang; $detailText = ''; - $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', $this->checks ); + $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) ); foreach ( $this->results as $code => $results ) { $detailTextForLang = "==$code==\n"; $numbers = array(); @@ -418,7 +446,7 @@ ENDS; $tableRows = implode( "\n|-\n", $rows ); - $version = SpecialVersion::getVersion( $IP ); + $version = SpecialVersion::getVersion( 'nodb' ); echo <<$version @@ -437,8 +465,8 @@ EOL; * @return True if there are any results, false if not. */ protected function isEmpty() { - foreach( $this->results as $code => $results ) { - foreach( $results as $check => $messages ) { + foreach( $this->results as $results ) { + foreach( $results as $messages ) { if( !empty( $messages ) ) { return false; } @@ -448,6 +476,9 @@ EOL; } } +/** + * @ingroup MaintenanceLanguage + */ class CheckExtensionsCLI extends CheckLanguageCLI { private $extensions; @@ -459,7 +490,7 @@ class CheckExtensionsCLI extends CheckLanguageCLI { public function __construct( Array $options, $extension ) { if ( isset( $options['help'] ) ) { echo $this->help(); - exit(); + exit(1); } if ( isset( $options['lang'] ) ) { @@ -587,7 +618,7 @@ Check codes (ideally, all of them should result 0; all the checks are executed b * untranslated: Messages which are required to translate, but are not translated. * duplicate: Messages which translation equal to fallback * obsolete: Messages which are untranslatable, but translated. - * variables: Messages without variables which should be used, or with variables which shouldn't be used. + * variables: Messages without variables which should be used, or with variables which should not be used. * empty: Empty messages. * whitespace: Messages which have trailing whitespace. * xhtml: Messages which are not well-formed XHTML (checks only few common errors). @@ -645,25 +676,40 @@ ENDS; # Blacklist some checks for some languages $checkBlacklist = array( #'code' => array( 'check1', 'check2' ... ) +'az' => array( 'plural' ), +'bo' => array( 'plural' ), +'dz' => array( 'plural' ), +'id' => array( 'plural' ), +'fa' => array( 'plural' ), 'gan' => array( 'plural' ), +'gan-hans' => array( 'plural' ), +'gan-hant' => array( 'plural' ), 'gn' => array( 'plural' ), 'hak' => array( 'plural' ), 'hu' => array( 'plural' ), 'ja' => array( 'plural' ), // Does not use plural +'jv' => array( 'plural' ), 'ka' => array( 'plural' ), 'kk-arab' => array( 'plural' ), 'kk-cyrl' => array( 'plural' ), 'kk-latn' => array( 'plural' ), +'km' => array( 'plural' ), +'kn' => array( 'plural' ), 'ko' => array( 'plural' ), +'lzh' => array( 'plural' ), 'mn' => array( 'plural' ), 'ms' => array( 'plural' ), -'my' => array( 'chars' ), // Uses a lot zwnj +'my' => array( 'plural', 'chars' ), // Uses a lot zwnj 'sah' => array( 'plural' ), 'sq' => array( 'plural' ), 'tet' => array( 'plural' ), 'th' => array( 'plural' ), +'to' => array( 'plural' ), +'tr' => array( 'plural' ), +'vi' => array( 'plural' ), 'wuu' => array( 'plural' ), 'xmf' => array( 'plural' ), +'yo' => array( 'plural' ), 'yue' => array( 'plural' ), 'zh' => array( 'plural' ), 'zh-classical' => array( 'plural' ),