X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Flanguage%2FcheckLanguage.inc;h=1860f4a5a2986547e3cfeb5c630ec5c4034c0f75;hb=29ab088e2fb938b0b3330bc4d4891a155e9420d2;hp=51de8014f4a1c558fcb2515ea9c5cbc62b80ef17;hpb=3a4268ef7a40a0786d247a5c01a7c4462a0307d5;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc index 51de8014f4..1860f4a5a2 100644 --- a/maintenance/language/checkLanguage.inc +++ b/maintenance/language/checkLanguage.inc @@ -1,15 +1,714 @@ help(); + exit(1); + } + + if ( isset( $options['lang'] ) ) { + $this->code = $options['lang']; + } else { + global $wgLanguageCode; + $this->code = $wgLanguageCode; + } + + if ( isset( $options['level'] ) ) { + $this->level = $options['level']; + } + + $this->doLinks = isset( $options['links'] ); + $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']; + } + + if ( isset( $options['whitelist'] ) ) { + $this->checks = explode( ',', $options['whitelist'] ); + } elseif ( isset( $options['blacklist'] ) ) { + $this->checks = array_diff( + isset( $options['easy'] ) ? $this->easyChecks() : $this->defaultChecks(), + explode( ',', $options['blacklist'] ) + ); + } elseif ( isset( $options['easy'] ) ) { + $this->checks = $this->easyChecks(); + } else { + $this->checks = $this->defaultChecks(); + } + + if ( isset( $options['output'] ) ) { + $this->output = $options['output']; + } + + $this->L = new languages( $this->includeExif ); + } + + /** + * Get the default checks. + * @return array A list of the default checks. + */ + protected function defaultChecks() { + return array( + 'untranslated', 'duplicate', 'obsolete', 'variables', 'empty', 'plural', + 'whitespace', 'xhtml', 'chars', 'links', 'unbalanced', 'namespace', + 'projecttalk', 'magic', 'magic-old', 'magic-over', 'magic-case', + 'special', 'special-old', + ); + } + + /** + * Get the checks which check other things than messages. + * @return array A list of the non-message checks. + */ + protected function nonMessageChecks() { + return array( + 'namespace', 'projecttalk', 'magic', 'magic-old', 'magic-over', + 'magic-case', 'special', 'special-old', + ); + } + + /** + * Get the checks that can easily be treated by non-speakers of the language. + * @return Array A list of the easy checks. + */ + protected function easyChecks() { + return array( + 'duplicate', 'obsolete', 'empty', 'whitespace', 'xhtml', 'chars', 'magic-old', + 'magic-over', 'magic-case', 'special-old', + ); + } + + /** + * Get all checks. + * @return array An array of all check names mapped to their function names. + */ + protected function getChecks() { + return array( + 'untranslated' => 'getUntranslatedMessages', + 'duplicate' => 'getDuplicateMessages', + 'obsolete' => 'getObsoleteMessages', + 'variables' => 'getMessagesWithMismatchVariables', + 'plural' => 'getMessagesWithoutPlural', + 'empty' => 'getEmptyMessages', + 'whitespace' => 'getMessagesWithWhitespace', + 'xhtml' => 'getNonXHTMLMessages', + 'chars' => 'getMessagesWithWrongChars', + 'links' => 'getMessagesWithDubiousLinks', + 'unbalanced' => 'getMessagesWithUnbalanced', + 'namespace' => 'getUntranslatedNamespaces', + 'projecttalk' => 'getProblematicProjectTalks', + 'magic' => 'getUntranslatedMagicWords', + 'magic-old' => 'getObsoleteMagicWords', + 'magic-over' => 'getOverridingMagicWords', + 'magic-case' => 'getCaseMismatchMagicWords', + 'special' => 'getUntraslatedSpecialPages', + 'special-old' => 'getObsoleteSpecialPages', + ); + } + + /** + * Get total count for each check non-messages check. + * @return array An array of all check names mapped to a two-element array: + * function name to get the total count and language code or null + * for checked code. + */ + protected function getTotalCount() { + return array( + 'namespace' => array( 'getNamespaceNames', 'en' ), + 'projecttalk' => null, + 'magic' => array( 'getMagicWords', 'en' ), + 'magic-old' => array( 'getMagicWords', null ), + 'magic-over' => array( 'getMagicWords', null ), + 'magic-case' => array( 'getMagicWords', null ), + 'special' => array( 'getSpecialPageAliases', 'en' ), + 'special-old' => array( 'getSpecialPageAliases', null ), + ); + } + + /** + * Get all check descriptions. + * @return array An array of all check names mapped to their descriptions. + */ + protected function getDescriptions() { + return array( + 'untranslated' => '$1 message(s) of $2 are not translated to $3, but exist in en:', + 'duplicate' => '$1 message(s) of $2 are translated the same in en and $3:', + 'obsolete' => '$1 message(s) of $2 do not exist in en or are in the ignore list, but exist in $3:', + 'variables' => '$1 message(s) of $2 in $3 don\'t match the variables used in en:', + 'plural' => '$1 message(s) of $2 in $3 don\'t use {{plural}} while en uses:', + 'empty' => '$1 message(s) of $2 in $3 are empty or -:', + 'whitespace' => '$1 message(s) of $2 in $3 have trailing whitespace:', + 'xhtml' => '$1 message(s) of $2 in $3 contain illegal XHTML:', + 'chars' => '$1 message(s) of $2 in $3 include hidden chars which should not be used in the messages:', + 'links' => '$1 message(s) of $2 in $3 have problematic link(s):', + 'unbalanced' => '$1 message(s) of $2 in $3 have unbalanced {[]}:', + 'namespace' => '$1 namespace name(s) of $2 are not translated to $3, but exist in en:', + 'projecttalk' => '$1 namespace name(s) and alias(es) in $3 are project talk namespaces without the parameter:', + 'magic' => '$1 magic word(s) of $2 are not translated to $3, but exist in en:', + 'magic-old' => '$1 magic word(s) of $2 do not exist in en, but exist in $3:', + 'magic-over' => '$1 magic word(s) of $2 in $3 do not contain the original en word(s):', + 'magic-case' => '$1 magic word(s) of $2 in $3 change the case-sensitivity of the original en word:', + 'special' => '$1 special page alias(es) of $2 are not translated to $3, but exist in en:', + 'special-old' => '$1 special page alias(es) of $2 do not exist in en, but exist in $3:', + ); + } + + /** + * Get help. + * @return string The help string. + */ + protected function help() { + return <<