<?php
-if ( !defined( 'MEDIAWIKI' ) ) {
- die();
-}
/**
* Statistic output classes.
*
global $wgDummyLanguageCodes;
$version = SpecialVersion::getVersion( 'nodb' );
echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
- echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
- echo "For additional information on specific languages (the message names, the actual problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
+ echo "'''Note:''' These statistics can be generated by running " .
+ "<code>php maintenance/language/transstat.php</code>.\n\n";
+ echo "For additional information on specific languages (the message names, the actual " .
+ "problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
echo 'English (en) is excluded because it is the default localization';
if ( is_array( $wgDummyLanguageCodes ) ) {
$dummyCodes = array();
foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
$dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
}
- echo ', as well as the following languages that are not intended for system message translations, usually because they redirect to other language codes: ' . implode( ', ', $dummyCodes );
+ echo ', as well as the following languages that are not intended for ' .
+ 'system message translations, usually because they redirect to other ' .
+ 'language codes: ' . implode( ', ', $dummyCodes );
}
echo ".\n\n"; # dot to end sentence
- echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
+ echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
+ 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
}
function footer() {
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:',
+ '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:',
+ '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:',
+ '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:',
+ '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:',
);
--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.
+ * 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: Do not 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).
+ --wikilang: For the links, what is the content language of the wiki to
+ display the output in (default en).
+ --noexif: Do not check for Exif messages (a bit hard and boring to
+ translate), if you know what they are currently not translated and want
+ to focus on other problems (default off).
--whitelist: Do only the following checks (form: code,code).
--blacklist: Do not 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
- * obsolete: Messages which are untranslatable or do not exist, but are translated.
- * variables: Messages without variables which should be used, or with variables which should not be used.
+ --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.
+ * obsolete: Messages which are untranslatable or do not exist, but are
+ translated.
+ * variables: Messages without variables which should be used, or with
+ variables which should not be used.
* empty: Empty messages and messages that contain only -.
* whitespace: Messages which have trailing whitespace.
- * xhtml: Messages which are not well-formed XHTML (checks only few common errors).
+ * xhtml: Messages which are not well-formed XHTML (checks only few common
+ errors).
* chars: Messages with hidden characters.
* links: Messages which contains broken links to pages (does not find all).
- * unbalanced: Messages which contains unequal numbers of opening {[ and closing ]}.
+ * unbalanced: Messages which contains unequal numbers of opening {[ and
+ closing ]}.
* namespace: Namespace names that were not translated.
- * projecttalk: Namespace names and aliases where the project talk does not contain $1.
+ * projecttalk: Namespace names and aliases where the project talk does not
+ contain $1.
* magic: Magic words that were not translated.
* magic-old: Magic words which do not exist.
* magic-over: Magic words that override the original English word.
- * magic-case: Magic words whose translation changes the case-sensitivity of the original English word.
+ * 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.
*/
function outputWiki() {
$detailText = '';
- $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
+ $rows[] = '! Language !! Code !! Total !! ' .
+ implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
foreach ( $this->results as $code => $results ) {
$detailTextForLang = "==$code==\n";
$numbers = array();
$tableRows = implode( "\n|-\n", $rows );
$version = SpecialVersion::getVersion( 'nodb' );
+ // @codingStandardsIgnoreStart Long line.
echo <<<EOL
'''Check results are for:''' <code>$version</code>
$detailText
EOL;
+ // @codingStandardsIgnoreEnd
}
/**
*/
protected function help() {
return <<<ENDS
-Run this script to check the status of a specific language in extensions, or all of them.
-Command line settings are in form --parameter[=value], except for the first one.
+Run this script to check the status of a specific language in extensions, or
+all of them. Command line settings are in form --parameter[=value], except for
+the first one.
Parameters:
- * First parameter (mandatory): Extension name, multiple extension names (separated by commas), "all" for all the extensions, "wikimedia" for extensions used by Wikimedia or "flaggedrevs" for all FLaggedRevs extension messages.
+ * First parameter (mandatory): Extension name, multiple extension names
+ (separated by commas), "all" for all the extensions, "wikimedia" for
+ extensions used by Wikimedia or "flaggedrevs" for all FLaggedRevs
+ extension messages.
* lang: Language code (default: the installation default language).
* 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).
+ * 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: Do not perform 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
+ * 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.
* obsolete: Messages which are untranslatable, but translated.
- * variables: Messages without variables which should be used, or with variables which should not 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).
+ * xhtml: Messages which are not well-formed XHTML (checks only few common
+ errors).
* chars: Messages with hidden characters.
* links: Messages which contains broken links to pages (does not find all).
- * unbalanced: Messages which contains unequal numbers of opening {[ and closing ]}.
+ * unbalanced: Messages which contains unequal numbers of opening {[ and
+ closing ]}.
+
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.
+ * 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;
}
if ( !$this->hasOption( 'unicode-data-file' ) ) {
$this->dataFile = 'UnicodeData.txt';
if ( !file_exists( $this->dataFile ) ) {
- $this->error( "Unable to find UnicodeData.txt. Please specify its location with --unicode-data-file=<FILE>" );
+ $this->error( "Unable to find UnicodeData.txt. Please specify " .
+ "its location with --unicode-data-file=<FILE>" );
exit( 1 );
}
} else {
* @ingroup MaintenanceLanguage
*/
class languages {
- protected $mLanguages; # List of languages
+ /** @var array List of languages */
+ protected $mLanguages; #
- protected $mRawMessages; # Raw list of the messages in each language
- protected $mMessages; # Messages in each language (except for English), divided to groups
- protected $mFallback; # Fallback language in each language
- protected $mGeneralMessages; # General messages in English, divided to groups
- protected $mIgnoredMessages; # All the messages which should be exist only in the English file
- protected $mOptionalMessages; # All the messages which may be translated or not, depending on the language
+ /** @var array Raw list of the messages in each language */
+ protected $mRawMessages;
- protected $mNamespaceNames; # Namespace names
- protected $mNamespaceAliases; # Namespace aliases
- protected $mMagicWords; # Magic words
- protected $mSpecialPageAliases; # Special page aliases
+ /** @var array Messages in each language (except for English), divided to groups */
+ protected $mMessages;
+
+ /** @var array Fallback language in each language */
+ protected $mFallback;
+
+ /** @var array General messages in English, divided to groups */
+ protected $mGeneralMessages;
+
+ /** @var array All the messages which should be exist only in the English file */
+ protected $mIgnoredMessages;
+
+ /** @var array All the messages which may be translated or not, depending on the language */
+ protected $mOptionalMessages;
+
+ /** @var array Namespace names */
+ protected $mNamespaceNames;
+
+ /** @var array Namespace aliases */
+ protected $mNamespaceAliases;
+
+ /** @var array Magic words */
+ protected $mMagicWords;
+
+ /** @var array Special page aliases */
+ protected $mSpecialPageAliases;
/**
* Load the list of languages: all the Messages*.php
}
/**
- * Load the messages for a specific language (which is not English) and divide them to groups:
+ * Load the messages for a specific language (which is not English) and divide them to
+ * groups:
* all - all the messages.
* required - messages which should be translated in order to get a complete translation.
- * optional - messages which can be translated, the fallback translation is used if not translated.
- * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages.
- * translated - messages which are either required or optional, but translated from English and needed.
+ * optional - messages which can be translated, the fallback translation is used if not
+ * translated.
+ * obsolete - messages which should not be translated, either because they do not exist,
+ * or they are ignored messages.
+ * translated - messages which are either required or optional, but translated from
+ * English and needed.
*
* @param $code string The language code.
*/
/**
* Load the messages for English and divide them to groups:
* all - all the messages.
- * required - messages which should be translated to other languages in order to get a complete translation.
- * optional - messages which can be translated to other languages, but it's not required for a complete translation.
+ * required - messages which should be translated to other languages in order to get a
+ * complete translation.
+ * optional - messages which can be translated to other languages, but it's not required
+ * for a complete translation.
* ignored - messages which should not be translated to other languages.
- * translatable - messages which are either required or optional, but can be translated from English.
+ * translatable - messages which are either required or optional, but can be translated
+ * from English.
*/
private function loadGeneralMessages() {
if ( isset( $this->mGeneralMessages ) ) {
* fallback language messages, divided to groups:
* all - all the messages.
* required - messages which should be translated in order to get a complete translation.
- * optional - messages which can be translated, the fallback translation is used if not translated.
- * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages.
- * translated - messages which are either required or optional, but translated from English and needed.
+ * optional - messages which can be translated, the fallback translation is used if not
+ * translated.
+ * obsolete - messages which should not be translated, either because they do not exist,
+ * or they are ignored messages.
+ * translated - messages which are either required or optional, but translated from
+ * English and needed.
*
* @param $code string The language code.
*
/**
* Get all the general English messages, divided to groups:
* all - all the messages.
- * required - messages which should be translated to other languages in order to get a complete translation.
- * optional - messages which can be translated to other languages, but it's not required for a complete translation.
+ * required - messages which should be translated to other languages in
+ * order to get a complete translation.
+ * optional - messages which can be translated to other languages, but it's
+ * not required for a complete translation.
* ignored - messages which should not be translated to other languages.
- * translatable - messages which are either required or optional, but can be translated from English.
+ * translatable - messages which are either required or optional, but can be
+ * translated from English.
*
* @return array The general English messages.
*/
$this->loadMessages( $code );
$messagesWithoutPlural = array();
foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
- if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false && stripos( $value, '{{plural:' ) === false ) {
+ if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false &&
+ stripos( $value, '{{plural:' ) === false
+ ) {
$messagesWithoutPlural[$key] = $value;
}
}
foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
$matches = array();
preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches );
- for ( $i = 0; $i < count( $matches[0] ); $i++ ) {
+ $numMatches = count( $matches[0] );
+ for ( $i = 0; $i < $numMatches; $i++ ) {
if ( preg_match( "/.*project.*/isDu", $matches[1][$i] ) ) {
$messages[$key][] = $matches[0][$i];
}
}
class extensionLanguages extends languages {
-
/**
* @var MessageGroup
*/
'cologneblue' => 'Cologne Blue skin',
'vector' => 'Vector skin',
'miscellaneous2' => '',
- 'links' => 'All link text and link target definitions of links into project namespace that get used by other message strings, with the exception of user group pages (see grouppage).',
+ 'links' => 'All link text and link target definitions of links into project namespace ' .
+ 'that get used by other message strings, with the exception of user group pages (see grouppage).',
'badaccess' => '',
'versionrequired' => '',
'miscellaneous3' => '',
'uploadstash' => 'Special:UploadStash',
'img-auth' => 'img_auth script messages',
'http-errors' => 'HTTP errors',
- 'upload-curl-errors' => 'Some likely curl errors. More could be added from <http://curl.haxx.se/libcurl/c/libcurl-errors.html>',
+ 'upload-curl-errors' => 'Some likely curl errors. More could be added from ' .
+ '<http://curl.haxx.se/libcurl/c/libcurl-errors.html>',
'licenses' => '',
'filelist' => 'Special:ListFiles',
'filedescription' => 'File description page',
'imagedeletion' => 'Image deletion',
'browsediffs' => 'Browsing diffs',
'newfiles' => 'Special:NewFiles',
- 'video-info' => 'Video information, used by Language::formatTimePeriod() to format lengths in the above messages',
+ 'video-info' => 'Video information, used by Language::formatTimePeriod() to ' .
+ 'format lengths in the above messages',
'human-timestamps' => 'Human-readable timestamps',
'badimagelist' => 'Bad image list',
'variantname-zh' => "Short names for language variants used for language conversion links.
* @param $dupeMsgSource string The source file intended to remove from the array.
* @param $messagesFolder String: path to a folder to store the MediaWiki messages.
*/
-function rebuildLanguage( $languages, $code, $write, $listUnknown, $removeUnknown, $removeDupes, $dupeMsgSource, $messagesFolder ) {
+function rebuildLanguage( $languages, $code, $write, $listUnknown, $removeUnknown,
+ $removeDupes, $dupeMsgSource, $messagesFolder
+) {
$messages = $languages->getMessages( $code );
$messages = $messages['all'];
if ( $removeDupes ) {
$messages = removeDupes( $messages, $dupeMsgSource );
}
- MessageWriter::writeMessagesToFile( $messages, $code, $write, $listUnknown, $removeUnknown, $messagesFolder );
+ MessageWriter::writeMessagesToFile(
+ $messages,
+ $code,
+ $write,
+ $listUnknown,
+ $removeUnknown,
+ $messagesFolder
+ );
}
/**
# Show help
if ( isset( $options['help'] ) ) {
echo <<<TEXT
-Run this script to rewrite the messages array in the files languages/messages/MessagesXX.php.
+Run this script to rewrite the messages array in the files
+languages/messages/MessagesXX.php.
Parameters:
- * lang: Language code (default: the installation default language). You can also specify "all" to check all the languages.
+ * lang: Language code (default: the installation default language).
+ You can also specify "all" to check all the languages.
* help: Show this help.
Options:
* dry-run: Do not write the array to the file.
# Write all the language
if ( $wgCode == 'all' ) {
foreach ( $languages->getLanguages() as $languageCode ) {
- rebuildLanguage( $languages, $languageCode, $wgWriteToFile, $wgListUnknownMessages, $wgRemoveUnknownMessages, $wgRemoveDuplicateMessages, $wgDupeMessageSource, $messagesFolder );
+ rebuildLanguage(
+ $languages,
+ $languageCode,
+ $wgWriteToFile,
+ $wgListUnknownMessages,
+ $wgRemoveUnknownMessages,
+ $wgRemoveDuplicateMessages,
+ $wgDupeMessageSource,
+ $messagesFolder
+ );
}
} else {
- rebuildLanguage( $languages, $wgCode, $wgWriteToFile, $wgListUnknownMessages, $wgRemoveUnknownMessages, $wgRemoveDuplicateMessages, $wgDupeMessageSource, $messagesFolder );
+ rebuildLanguage(
+ $languages,
+ $wgCode,
+ $wgWriteToFile,
+ $wgListUnknownMessages,
+ $wgRemoveUnknownMessages,
+ $wgRemoveDuplicateMessages,
+ $wgDupeMessageSource,
+ $messagesFolder
+ );
}
$messages = $wgLanguages->getMessages( $code );
$messagesNumber = count( $messages['translated'] );
$requiredMessagesNumber = count( $messages['required'] );
- $requiredMessagesPercent = $output->formatPercent( $requiredMessagesNumber, $wgRequiredMessagesNumber );
+ $requiredMessagesPercent = $output->formatPercent(
+ $requiredMessagesNumber,
+ $wgRequiredMessagesNumber
+ );
$obsoleteMessagesNumber = count( $messages['obsolete'] );
- $obsoleteMessagesPercent = $output->formatPercent( $obsoleteMessagesNumber, $messagesNumber, true );
+ $obsoleteMessagesPercent = $output->formatPercent(
+ $obsoleteMessagesNumber,
+ $messagesNumber,
+ true
+ );
$messagesWithMismatchVariables = $wgLanguages->getMessagesWithMismatchVariables( $code );
$emptyMessages = $wgLanguages->getEmptyMessages( $code );
$messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code );
$nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code );
$messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code );
- $problematicMessagesNumber = count( array_unique( array_merge( $messagesWithMismatchVariables, $emptyMessages, $messagesWithWhitespace, $nonXHTMLMessages, $messagesWithWrongChars ) ) );
- $problematicMessagesPercent = $output->formatPercent( $problematicMessagesNumber, $messagesNumber, true );
+ $problematicMessagesNumber = count( array_unique( array_merge(
+ $messagesWithMismatchVariables,
+ $emptyMessages,
+ $messagesWithWhitespace,
+ $nonXHTMLMessages,
+ $messagesWithWrongChars
+ ) ) );
+ $problematicMessagesPercent = $output->formatPercent(
+ $problematicMessagesNumber,
+ $messagesNumber,
+ true
+ );
# Output them
$output->blockstart();
* @ingroup MaintenanceLanguage
*/
class MessageWriter {
- static $optionalComment = 'only translate this message to other languages if you have to change it';
+ static $optionalComment =
+ 'only translate this message to other languages if you have to change it';
static $ignoredComment = "do not translate or duplicate this message to other languages";
static $messageStructure;
* @param $write Boolean: write to the messages file?
* @param $listUnknown Boolean: list the unknown messages?
* @param $removeUnknown Boolean: whether to remove unkown messages
- * @param $messagesFolder String: path to a folder to store the MediaWiki messages. Defaults to the current install.
+ * @param $messagesFolder String: path to a folder to store the MediaWiki messages.
+ * Defaults to the current install.
*/
- public static function writeMessagesToFile( $messages, $code, $write, $listUnknown, $removeUnknown, $messagesFolder = false ) {
+ public static function writeMessagesToFile( $messages, $code, $write, $listUnknown,
+ $removeUnknown, $messagesFolder = false
+ ) {
# Rewrite the messages array
$messages = self::writeMessagesArray( $messages, $code == 'en', false, $removeUnknown );
$messagesText = $messages[0];
file_put_contents( $filename, $new );
echo "Generated and wrote messages for language $code.\n";
} else {
- echo "Generated messages for language $code. Please run the script again (without the parameter \"dry-run\") to write the array to the file.\n";
+ echo "Generated messages for language $code.\n" .
+ "Please run the script again (without the parameter \"dry-run\") " .
+ "to write the array to the file.\n";
}
}
- if ( $listUnknown && isset( $sortedMessages['unknown'] ) && !empty( $sortedMessages['unknown'] ) ) {
+ if ( $listUnknown && isset( $sortedMessages['unknown'] ) &&
+ !empty( $sortedMessages['unknown'] )
+ ) {
if ( $removeUnknown ) {
- echo "\nThe following " . count( $sortedMessages['unknown'] ) . " unknown messages have been removed:\n";
+ echo "\nThe following " . count( $sortedMessages['unknown'] ) .
+ " unknown messages have been removed:\n";
} else {
- echo "\nThere are " . count( $sortedMessages['unknown'] ) . " unknown messages, please check them:\n";
+ echo "\nThere are " . count( $sortedMessages['unknown'] ) .
+ " unknown messages, please check them:\n";
}
foreach ( $sortedMessages['unknown'] as $key => $value ) {
echo "* " . $key . "\n";
*
* @return Array of the PHP text and the sorted messages array.
*/
- public static function writeMessagesArray( $messages, $ignoredComments = false, $prefix = false, $removeUnknown = false ) {
+ public static function writeMessagesArray( $messages, $ignoredComments = false,
+ $prefix = false, $removeUnknown = false
+ ) {
# Load messages
$dir = $prefix ? $prefix : __DIR__;
if ( strpos( $value, $single ) === false ) {
# Nothing ugly, just use '
$blockText .= $single . $value . $single;
- } elseif ( strpos( $value, $double ) === false && !preg_match( '/\$[a-zA-Z_\x7f-\xff]/', $value ) ) {
+ } elseif ( strpos( $value, $double ) === false &&
+ !preg_match( '/\$[a-zA-Z_\x7f-\xff]/', $value )
+ ) {
# No "-quotes, no variables that need quoting, use "
$blockText .= $double . $value . $double;
} else {
# Something needs quoting, pick the quote which causes less quoting
- $quote = substr_count( $value, $double ) + substr_count( $value, '$' ) >= substr_count( $value, $single ) ? $single : $double;
+
+ if ( substr_count( $value, $double ) + substr_count( $value, '$' ) >=
+ substr_count( $value, $single )
+ ) {
+ $quote = $single;
+ } else {
+ $quote = $double;
+ }
+
if ( $quote === $double ) {
$extra = '$';
} else {