jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/367326 )
Change subject: Add a hook into LanguageConverter#getPreferredVariant() to allow extensions to pull the desired variant from cookies (or other such source) ...................................................................... Add a hook into LanguageConverter#getPreferredVariant() to allow extensions to pull the desired variant from cookies (or other such source) Example implementation using this hook: wikiHow's ChineseVariantSelector extension, installed on zh.wikihow.com, which uses cookies to store the preferred language variant, allowing anonymous users to change the language variant without registering/logging in. Change-Id: I5295a26578b45a8d51f2b7550938088fec18404f --- M docs/hooks.txt M languages/LanguageConverter.php 2 files changed, 9 insertions(+), 0 deletions(-) Approvals: Brian Wolff: Looks good to me, approved jenkins-bot: Verified diff --git a/docs/hooks.txt b/docs/hooks.txt index 3ff3365..c21ce8a 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1662,6 +1662,13 @@ 'GetIP': modify the ip of the current user (called only once). &$ip: string holding the ip as determined so far +'GetLangPreferredVariant': Called in LanguageConverter#getPreferredVariant() to + allow fetching the language variant code from cookies or other such + alternative storage. +&$req: language variant from the URL (string) or boolean false if no variant + was specified in the URL; the value of this variable comes from + LanguageConverter#getURLVariant() + 'GetLinkColours': modify the CSS class of an array of page links. $linkcolour_ids: array of prefixed DB keys of the pages linked to, indexed by page_id. diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 6d0368c..d9e64b4 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -160,6 +160,8 @@ $req = $this->getURLVariant(); + Hooks::run( 'GetLangPreferredVariant', [ &$req ] ); + if ( $wgUser->isSafeToLoad() && $wgUser->isLoggedIn() && !$req ) { $req = $this->getUserVariant(); } elseif ( !$req ) { -- To view, visit https://gerrit.wikimedia.org/r/367326 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5295a26578b45a8d51f2b7550938088fec18404f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jack Phoenix <ash...@uncyclomedia.co> Gerrit-Reviewer: Bartosz DziewoĆski <matma....@gmail.com> Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com> Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org> Gerrit-Reviewer: Liangent <liang...@gmail.com> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits