summaryrefslogtreecommitdiff
path: root/maintenance/language/languages.inc
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/language/languages.inc')
-rw-r--r--maintenance/language/languages.inc113
1 files changed, 60 insertions, 53 deletions
diff --git a/maintenance/language/languages.inc b/maintenance/language/languages.inc
index a10cae9e..9472e254 100644
--- a/maintenance/language/languages.inc
+++ b/maintenance/language/languages.inc
@@ -5,8 +5,6 @@
* @addtogroup Maintenance
*/
-require_once( 'messageTypes.inc' );
-
class languages {
protected $mLanguages; # List of languages
protected $mRawMessages; # Raw list of the messages in each language
@@ -22,7 +20,7 @@ class languages {
* @param $exif Treat the EXIF messages?
*/
function __construct( $exif = true ) {
- global $wgIgnoredMessages, $wgOptionalMessages, $wgEXIFMessages;
+ require( dirname(__FILE__) . '/messageTypes.inc' );
$this->mIgnoredMessages = $wgIgnoredMessages;
if ( $exif ) {
$this->mOptionalMessages = array_merge( $wgOptionalMessages );
@@ -62,9 +60,9 @@ class languages {
}
/**
- * Load the raw messages for a specific langauge from the messages file.
+ * Load the raw messages for a specific language from the messages file.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*/
protected function loadRawMessages( $code ) {
if ( isset( $this->mRawMessages[$code] ) ) {
@@ -149,7 +147,7 @@ class languages {
}
/**
- * Get all the messages for a specific langauge (not English), without the
+ * Get all the messages for a specific language (not English), without the
* fallback language messages, divided to groups:
* all - all the messages.
* required - messages which should be translated in order to get a complete translation.
@@ -157,7 +155,7 @@ class languages {
* obsolete - messages which should not be translated, either because they are not exist, or they are ignored messages.
* translated - messages which are either required or optional, but translated from English and needed.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages in this language.
*/
@@ -184,7 +182,7 @@ class languages {
/**
* Get the untranslated messages for a specific language.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The untranslated messages for this language.
*/
@@ -203,7 +201,7 @@ class languages {
/**
* Get the duplicate messages for a specific language.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The duplicate messages for this language.
*/
@@ -219,10 +217,16 @@ class languages {
return $duplicateMessages;
}
+ public function getObsoleteMessages( $code ) {
+ $this->loadGeneralMessages();
+ $this->loadMessages( $code );
+ return $this->mMessages[$code]['obsolete'];
+ }
+
/**
* Get the messages which do not use some variables.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages which do not use some variables in this language.
*/
@@ -249,7 +253,7 @@ class languages {
/**
* Get the messages which do not use plural.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages which do not use plural in this language.
*/
@@ -268,7 +272,7 @@ class languages {
/**
* Get the empty messages.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The empty messages for this language.
*/
@@ -287,7 +291,7 @@ class languages {
/**
* Get the messages with trailing whitespace.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages with trailing whitespace in this language.
*/
@@ -306,7 +310,7 @@ class languages {
/**
* Get the non-XHTML messages.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The non-XHTML messages for this language.
*/
@@ -332,7 +336,7 @@ class languages {
/**
* Get the messages which include wrong characters.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages which include wrong characters in this language.
*/
@@ -366,49 +370,52 @@ class languages {
return $wrongCharsMessages;
}
- /**
- * Output a messages list
- *
- * @param $messages The messages list
- * @param $code The language code
- * @param $text The text to show before the list (optional)
- * @param $level The display level (optional)
- * @param $links Show links (optional)
- * @param $wikilang The langauge of the wiki to display the list in, for the links (optional)
- */
- public function outputMessagesList( $messages, $code, $text = '', $level = 2, $links = false, $wikilang = null ) {
- if ( count( $messages ) == 0 ) {
- return;
- }
- if ( $text ) {
- echo "$text\n";
- }
- if ( $level == 1 ) {
- echo "[messages are hidden]\n";
- } else {
- foreach ( $messages as $key => $value ) {
- if ( $links ) {
- $displayKey = ucfirst( $key );
- if ( !isset( $wikilang ) ) {
- global $wgContLang;
- $wikilang = $wgContLang->getCode();
- }
- if ( $code == $wikilang ) {
- $displayKey = "[[MediaWiki:$displayKey|$key]]";
- } else {
- $displayKey = "[[MediaWiki:$displayKey/$code|$key]]";
- }
- } else {
- $displayKey = $key;
+ public function getMessagesWithDubiousLinks( $code ) {
+ $this->loadGeneralMessages();
+ $this->loadMessages( $code );
+ $tc = Title::legalChars() . '#%{}';
+ $messages = array();
+ 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++ ) {
+ if ( preg_match( "/.*project.*/isDu", $matches[1][$i]) ) {
+ $messages[$key][] = $matches[0][$i];
}
- if ( $level == 2 ) {
- echo "* $displayKey\n";
- } else {
- echo "* $displayKey: '$value'\n";
+ }
+
+
+ if ( isset( $messages[$key] ) ) {
+ $messages[$key] = implode( $messages[$key],", " );
+ }
+ }
+ return $messages;
+ }
+
+ public function getMessagesWithUnbalanced( $code ) {
+ $this->loadGeneralMessages();
+ $this->loadMessages( $code );
+ $messages = array();
+ foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
+
+ $a = $b = $c = $d = 0;
+ foreach ( preg_split('//', $value) as $char ) {
+ switch ($char) {
+ case '[': $a++; break;
+ case ']': $b++; break;
+ case '{': $c++; break;
+ case '}': $d++; break;
}
}
+
+ if ( $a !== $b || $c !== $d ) {
+ $messages[$key] = "$a, $b, $c, $d";
+ }
+
}
+ return $messages;
}
+
}
?>