* Therefore added a hook to catch them from an extension (successfully tested with the cldr extension (see next commit))
* Add a title tag to the interlanguage box entries. Only added when the title differ from the shwon text.
No change of behaviour until an extension is enabled.
&$result: Set this and return false to override the internal checks
$user: User the password is being validated for
+'LanguageGetLocalizedLanguageNames': Use to get localized language names
+&$languageNames: localized language names (array)
+$lang: laguage code (string)
+
'LanguageGetMagic': Use this to define synonyms of magic words depending of the language
$magicExtensions: associative array of magic words synonyms
$lang: laguage code (string)
if ( $nt ) {
$language_urls[] = array(
'href' => $nt->getFullURL(),
- 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
- 'class' => $class
+ 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != ''
+ ? $wgContLang->getLanguageName( $nt->getInterwiki() )
+ : $l ),
+ 'class' => $class,
+ 'title' => ( $wgLang->getLanguageNameLocalized( $nt->getInterwiki() ) != ''
+ ? $wgLang->getLanguageNameLocalized( $nt->getInterwiki() )
+ : $l )
);
}
}
return wfMsgExt( $msg, array( 'parsemag', 'language' => $this ) );
}
- function getLanguageName( $code ) {
+ /**
+ * Get a language name
+ *
+ * @param $code String language code
+ * @return $localized boolean gets the localized language name
+ */
+ function getLanguageName( $code, $localized = false ) {
$names = self::getLanguageNames();
if ( !array_key_exists( $code, $names ) ) {
return '';
}
- return $names[$code];
+ if( $localized ) {
+ $languageNames = array();
+ wfRunHooks( 'LanguageGetLocalizedLanguageNames', array( &$languageNames, $this->getCode() ) );
+ return isset( $languageNames[$code] ) ? $languageNames[$code] : $names[$code];
+ } else {
+ return $names[$code];
+ }
+ }
+
+ function getLanguageNameLocalized( $code ) {
+ return self::getLanguageName( $code, true );
}
function getMonthName( $key ) {
<h5><?php $this->msg('otherlanguages') ?></h5>
<div class="pBody">
<ul>
-<?php foreach($this->data['language_urls'] as $langlink) { ?>
+<?php foreach($this->data['language_urls'] as $langlink) {
+ // Add title tag only if differ from shown text
+ $titleTag = $langlink['title'] == $langlink['text']
+ ? ''
+ : 'title="' . htmlspecialchars( $langlink['title'] ) . '"';
+ ?>
<li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
- ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
+ ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"
+ <? echo $titleTag ?> > <?php echo $langlink['text'] ?></a></li>
<?php } ?>
</ul>
</div><!-- pBody -->
<h5><?php $this->msg('otherlanguages') ?></h5>
<div class="pBody">
<ul>
-<?php foreach($this->data['language_urls'] as $langlink) { ?>
+<?php foreach($this->data['language_urls'] as $langlink) {
+ // Add title tag only if differ from shown text
+ $titleTag = $langlink['title'] == $langlink['text']
+ ? ''
+ : 'title="' . htmlspecialchars( $langlink['title'] ) . '"';
+ ?>
<li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
- ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
+ ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"
+ <? echo $titleTag ?> > <?php echo $langlink['text'] ?></a></li>
<?php } ?>
</ul>
</div>