Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2795
LanguageTags.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 9:13 PM
2014-11-21 21:13:07 (UTC+0)
Size
5 KB
Referenced Files
None
Subscribers
None
LanguageTags.patch
View Options
Index: skins/MonoBook.php
===================================================================
--- skins/MonoBook.php (revision 14153)
+++ skins/MonoBook.php (working copy)
@@ -47,11 +47,12 @@
* @access private
*/
function execute() {
+ QuickTemplate::setLanguageTag();
// Suppress warnings to prevent notices about missing indexes in $this->data
wfSuppressWarnings();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('langtag') ?>" lang="<?php $this->text('langtag') ?>" dir="<?php $this->text('dir') ?>">
<head>
<meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
<?php $this->html('headlinks') ?>
Index: includes/OutputPage.php
===================================================================
--- includes/OutputPage.php (revision 14153)
+++ includes/OutputPage.php (working copy)
@@ -939,6 +939,60 @@
}
/**
+ * get the correct language tag assiciated with correct font package
+ * @access public
+ * @return string
+ */
+ function getLanguageTag() {
+ global $wgContLanguageCode, $wgDispLangChangeTo, $wgDispLangChanges;
+ global $wgDispLangNeedChanges, $wgUser;
+ $mNeeds2ChangeLangCode = 0;
+ $mLangCodeChanged = 0;
+
+ foreach($wgDispLangNeedChanges as $i => $LanguageCode) {
+ if ($wgDispLangNeedChanges[$i] == $wgContLanguageCode)
+ $mNeeds2ChangeLangCode = 1;
+ }
+
+ if (array_key_exists($wgContLanguageCode, $wgDispLangChangeTo)) {
+ $mDisplayLanguageCode = $wgDispLangChangeTo[$wgContLanguageCode];
+ $mLangCodeChanged = 1;
+ }
+
+ if (($mNeeds2ChangeLangCode == 1) && ($mLangCodeChanged == 0)) {
+
+ if ((is_object($wgUser)) && ($wgUser->isLoggedin())) {
+ $getLanguageCode = $wgUser->getOption('language');
+ }
+ else if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
+ $getLanguageCode = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]));
+ $getLanguageCode = strtok($getLanguageCode,',;');
+ }
+ else {
+ $getLanguageCode = $wgContLanguageCode;
+ }
+
+ if (array_key_exists($getLanguageCode, $wgDispLangChanges))
+ {
+ $mDisplayLanguageCode = $wgDispLangChanges[$getLanguageCode];
+ $mLangCodeChanged = 1;
+ }
+ else
+ {
+ $mDisplayLanguageCode = $wgContLanguageCode;
+ }
+ }
+
+ else if ($mLangCodeChanged == 1); //do nothing
+
+ else {
+ $mDisplayLanguageCode = $wgContLanguageCode;
+ }
+
+ return $mDisplayLanguageCode;
+ }
+
+ /**
* @access private
* @return string
*/
@@ -952,6 +1006,7 @@
$ret = '';
}
+ $langtag = $this->getLanguageTag();
$ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
if ( '' == $this->getHTMLTitle() ) {
@@ -959,7 +1014,7 @@
}
$rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
- $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
+ $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$langtag\" lang=\"$langtag\" $rtl>\n";
$ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
Index: includes/SkinTemplate.php
===================================================================
--- includes/SkinTemplate.php (revision 14153)
+++ includes/SkinTemplate.php (working copy)
@@ -1088,6 +1088,57 @@
}
/**
+ * An ugly hack to get the correct language tag associate with correct font
+ * @public
+ */
+ function setLanguageTag() {
+ global $wgContLanguageCode, $wgDispLangChangeTo, $wgDispLangChanges;
+ global $wgDispLangNeedChanges, $wgUser;
+ $mNeeds2ChangeLangCode = 0;
+ $mLangCodeChanged = 0;
+
+ foreach($wgDispLangNeedChanges as $i => $LanguageCode) {
+ if ($wgDispLangNeedChanges[$i] == $wgContLanguageCode)
+ $mNeeds2ChangeLangCode = 1;
+ }
+
+ if (array_key_exists($wgContLanguageCode, $wgDispLangChangeTo)) {
+ $mDisplayLanguageCode = $wgDispLangChangeTo[$wgContLanguageCode];
+ $mLangCodeChanged = 1;
+ }
+
+ if (($mNeeds2ChangeLangCode == 1) && ($mLangCodeChanged == 0)) {
+
+ if ((is_object($wgUser)) && ($wgUser->isLoggedin())) {
+ $getLanguageCode = $wgUser->getOption('language');
+ }
+ else if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
+ $getLanguageCode = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]));
+ $getLanguageCode = strtok($getLanguageCode,',;');
+ }
+ else {
+ $getLanguageCode = $wgContLanguageCode;
+ }
+
+ if (array_key_exists($getLanguageCode, $wgDispLangChanges)) {
+ $mDisplayLanguageCode = $wgDispLangChanges[$getLanguageCode];
+ $mLangCodeChanged = 1;
+ }
+ else {
+ $mDisplayLanguageCode = $wgContLanguageCode;
+ }
+ }
+
+ else if ($mLangCodeChanged == 1); //do nothing
+
+ else {
+ $mDisplayLanguageCode = $wgContLanguageCode;
+ }
+
+ $this->set('langtag',$mDisplayLanguageCode);
+ }
+
+ /**
* @private
*/
function haveData( $str ) {
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2367
Default Alt Text
LanguageTags.patch (5 KB)
Attached To
Mode
T7790: Having both lang and xml:lang attributes not identical to $wgContLanguageCode
Attached
Detach File
Event Timeline
Log In to Comment