Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/228617
Change subject: Use 'PageContentLanguage' hook to set proper lang & div
attributes
......................................................................
Use 'PageContentLanguage' hook to set proper lang & div attributes
Attempt to get the content language code of the remote wiki through
$wgConf. The content language code is not necessarily the page view
language of the remote user page, but it's probably better than the
current wiki's content language.
This will cause the <div lang="$lang" dir="$dir" class="mw-
content-$dir"> around the content to be set appropriately (it is
actually set by the skin).
Bug: T90612
Change-Id: I53aa995d385b09bae41b210664b45143d7789861
---
M GlobalUserPage.hooks.php
M extension.json
2 files changed, 25 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUserPage
refs/changes/17/228617/1
diff --git a/GlobalUserPage.hooks.php b/GlobalUserPage.hooks.php
index b3317bf..161ee33 100644
--- a/GlobalUserPage.hooks.php
+++ b/GlobalUserPage.hooks.php
@@ -156,4 +156,26 @@
return true;
}
+
+ /**
+ * @param Title $title
+ * @param string $pageLang
+ * @return bool
+ */
+ public static function onPageContentLanguage( Title $title, &$pageLang
) {
+ global $wgConf;
+ if ( !$title->exists() &&
GlobalUserPage::shouldDisplayGlobalPage( $title ) ) {
+ $config =
ConfigFactory::getDefaultInstance()->makeConfig( 'globaluserpage' );
+ // $wgLanguageCode is not the same as
Title::getPageViewLanguage, but it's probably
+ // closer to reality.
+ $code = $wgConf->get( 'wgLanguageCode', $config->get(
'GlobalUserPageDBname' ) );
+ if ( $code ) {
+ $pageLang = $code;
+ return false;
+ }
+ // TODO: Use an API request to get the remote view
language
+ }
+
+ return true;
+ }
}
diff --git a/extension.json b/extension.json
index 13f42c3..b44cf64 100644
--- a/extension.json
+++ b/extension.json
@@ -37,6 +37,9 @@
],
"TitleGetEditNotices": [
"GlobalUserPageHooks::onTitleGetEditNotices"
+ ],
+ "PageContentLanguage": [
+ "GlobalUserPageHooks::onPageContentLanguage"
]
},
"config": {
--
To view, visit https://gerrit.wikimedia.org/r/228617
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I53aa995d385b09bae41b210664b45143d7789861
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalUserPage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits