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
*/
protected function loadFile( $code ) {
if ( isset( $this->mRawMessages[$code] ) &&
+ isset( $this->mFallback[$code] ) &&
isset( $this->mNamespaceNames[$code] ) &&
isset( $this->mNamespaceAliases[$code] ) &&
isset( $this->mMagicWords[$code] ) &&
return;
}
$this->mRawMessages[$code] = array();
+ $this->mFallback[$code] = '';
$this->mNamespaceNames[$code] = array();
$this->mNamespaceAliases[$code] = array();
$this->mMagicWords[$code] = array();
if ( isset( $messages ) ) {
$this->mRawMessages[$code] = $messages;
}
+ if ( isset( $fallback ) ) {
+ $this->mFallback[$code] = $fallback;
+ }
if ( isset( $namespaceNames ) ) {
$this->mNamespaceNames[$code] = $namespaceNames;
}
return $this->mGeneralMessages;
}
+ /**
+ * Get fallback language code for a specific language.
+ *
+ * @param $code The language code.
+ *
+ * @return Fallback code.
+ */
+ public function getFallback( $code ) {
+ $this->loadFile( $code );
+ return $this->mFallback[$code];
+ }
+
/**
* Get namespace names for a specific language.
*
}
/**
- * Get the messages which do not use some variables.
+ * Get the messages whose variables do not match the original ones.
*
* @param $code The language code.
*
- * @return The messages which do not use some variables in this language.
+ * @return The messages whose variables do not match the original ones.
*/
- public function getMessagesWithoutVariables( $code ) {
+ public function getMessagesWithMismatchVariables( $code ) {
$this->loadGeneralMessages();
$this->loadMessages( $code );
$variables = array( '\$1', '\$2', '\$3', '\$4', '\$5', '\$6', '\$7', '\$8', '\$9' );
- $messagesWithoutVariables = array();
+ $mismatchMessages = array();
foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
$missing = false;
foreach ( $variables as $var ) {
!preg_match( "/$var/sU", $value ) ) {
$missing = true;
}
+ if ( !preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
+ preg_match( "/$var/sU", $value ) ) {
+ $missing = true;
+ }
}
if ( $missing ) {
- $messagesWithoutVariables[$key] = $value;
+ $mismatchMessages[$key] = $value;
}
}
- return $messagesWithoutVariables;
+ return $mismatchMessages;
}
/**