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 [ '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 [ '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 [ '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 [ '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 [ 'namespace' => [ 'getNamespaceNames', 'en' ], 'projecttalk' => null, 'magic' => [ 'getMagicWords', 'en' ], 'magic-old' => [ 'getMagicWords', null ], 'magic-over' => [ 'getMagicWords', null ], 'magic-case' => [ 'getMagicWords', null ], 'special' => [ 'getSpecialPageAliases', 'en' ], 'special-old' => [ 'getSpecialPageAliases', null ], ]; } /** * Get all check descriptions. * @return array An array of all check names mapped to their descriptions. */ protected function getDescriptions() { return [ '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 <<