46 if ( isset( $options[
'help'] ) ) {
51 if ( isset( $options[
'lang'] ) ) {
52 $this->code = $options[
'lang'];
58 if ( isset( $options[
'level'] ) ) {
59 $this->level = $options[
'level'];
62 $this->doLinks = isset( $options[
'links'] );
63 $this->includeExif = !isset( $options[
'noexif'] );
64 $this->checkAll = isset( $options[
'all'] );
66 if ( isset( $options[
'prefix'] ) ) {
67 $this->linksPrefix = $options[
'prefix'];
70 if ( isset( $options[
'wikilang'] ) ) {
71 $this->wikiCode = $options[
'wikilang'];
74 if ( isset( $options[
'whitelist'] ) ) {
75 $this->checks = explode(
',', $options[
'whitelist'] );
76 } elseif ( isset( $options[
'blacklist'] ) ) {
77 $this->checks = array_diff(
79 explode(
',', $options[
'blacklist'] )
81 } elseif ( isset( $options[
'easy'] ) ) {
87 if ( isset( $options[
'output'] ) ) {
88 $this->output = $options[
'output'];
91 $this->L =
new Languages( $this->includeExif );
214Run
this script to check a specific language file, or all of them.
215Command line settings are in form --parameter[=value].
218 --lang:
Language code (
default: the installation
default language).
219 --all: Check all customized languages.
220 --level: Show the following display level (
default: 2):
221 * 0: Skip the checks (useful
for checking syntax).
222 * 1: Show only the stub headers and number of wrong messages, without
224 * 2: Show only the headers and the message keys, without the message
226 * 3: Show both the headers and the complete messages, with both keys and
228 --links: Link the message values (
default off).
229 --prefix: prefix to add to links.
230 --wikilang: For the links, what is the content language of the wiki to
231 display the output in (
default en).
232 --noexif: Do not check
for Exif messages (a bit hard and boring to
233 translate),
if you know what they are currently not translated and want
234 to focus on other problems (
default off).
235 --whitelist: Do only the following checks (form: code,code).
236 --blacklist: Do not
do the following checks (form: code,code).
237 --easy: Do only the easy checks, which can be treated by non-speakers of
240Check codes (ideally, all of them should result 0; all the checks are executed
241by
default (except language-specific check blacklists in
checkLanguage.inc):
242 * untranslated: Messages which are required to translate, but are not
244 * duplicate: Messages which translation equal to fallback.
245 * obsolete: Messages which are untranslatable or
do not exist, but are
247 * variables: Messages without variables which should be used, or with
248 variables which should not be used.
249 * empty: Empty messages and messages that contain only -.
250 * whitespace: Messages which have trailing whitespace.
251 * xhtml: Messages which are not well-formed XHTML (checks only few common
253 * chars: Messages with hidden characters.
254 * links: Messages which contains broken links to pages (does not find all).
255 * unbalanced: Messages which contains unequal numbers of opening {[ and
257 *
namespace: Namespace names that were not translated.
258 * projecttalk: Namespace names and aliases where the project talk does not
260 * magic: Magic words that were not translated.
261 * magic-old: Magic words which
do not exist.
262 * magic-over: Magic words that
override the original English word.
263 * magic-
case: Magic words whose translation changes the
case-sensitivity of
264 the original English word.
265 * special: Special page names that were not translated.
266 * special-old: Special page names which
do not exist.
433 $translated = $this->L->getMessages(
$code );
434 $translated = count( $translated[
'translated'] );
435 foreach (
$results as $check => $messages ) {
436 $count = count( $messages );
438 if ( $check ==
'untranslated' ) {
439 $translatable = $this->L->getGeneralMessages();
440 $total = count( $translatable[
'translatable'] );
443 $totalCount = $totalCount[$check];
444 $callback = [
$this->L, $totalCount[0] ];
445 $callCode = $totalCount[1] ? $totalCount[1] :
$code;
446 $total = count( call_user_func( $callback, $callCode ) );
448 $total = $translated;
450 $search = [
'$1',
'$2',
'$3' ];
451 $replace = [ $count, $total,
$code ];
453 echo
"\n" . str_replace( $search, $replace, $descriptions[$check] ) .
"\n";
454 if ( $this->level == 1 ) {
455 echo
"[messages are hidden]\n";
457 foreach ( $messages as $key => $value ) {
461 if ( $this->level == 2 || empty( $value ) ) {
464 echo
"* $key: '$value'\n";
478 $rows[] =
'! Language !! Code !! Total !! ' .
481 $detailTextForLang =
"==$code==\n";
484 $detailTextForLangChecks = [];
485 foreach (
$results as $check => $messages ) {
489 $count = count( $messages );
492 $messageDetails = [];
493 foreach ( $messages as $key => $details ) {
495 $messageDetails[] = $displayKey;
497 $detailTextForLangChecks[] =
"=== $code-$check ===\n* " . implode(
', ', $messageDetails );
498 $numbers[] =
"'''[[#$code-$check|$count]]'''";
504 if ( count( $detailTextForLangChecks ) ) {
505 $detailText .= $detailTextForLang . implode(
"\n", $detailTextForLangChecks ) .
"\n";
509 # Don't list languages without problems
512 $language = Language::fetchLanguageName(
$code );
513 $rows[] =
"| $language || $code || $problems || " . implode(
' || ', $numbers );
516 $tableRows = implode(
"\n|-\n", $rows );
521'''Check results are
for:
''' <code>$version</code>
524{|
class=
"sortable wikitable" border=
"2" cellpadding=
"4" cellspacing=
"0" style=
"background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear: both;"