Page MenuHomePhabricator

Enable site logo displaying according to user language
Closed, DuplicatePublic

Description

This can allow users to create different logos for different languages.

Details

Reference
bz20807

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:48 PM
bzimport set Reference to bz20807.
bzimport added a subscriber: Unknown Object (MLST).

The logo URL isn't really a localization string; it's site-specific and belongs in the general administration interface (which doesn't exist yet).

Multilingual projects such as Wikispecies (besides many others outside WMF) which have localized names for project would utilize some such feature to display logo according to user language.

Changing the summary to more general and reopening. If closing will follow, I'd suggest rather LATER than WONTFIX.

Hmmm... note that as a hackaround this could be done via site JS for now (check wgUserLanguage and swap out the URL on the logo). Site CSS can also override the logo but I don't think user language is exposed in a way that CSS can consistently get it (the content lang is used on <html lang="xx">)

Related to Bug#14594 which involves different logos for different skins.

While I understand that we have bits of language in different logos, I should note that the golden arches remain the same even in languages that do not use the Latin alphabet: http://www.mylifestylediet.com/blog/latest-news/golden-arches-in-japan-expand-burger-selection-and-calories/

This feature looks suitable for an extension rather than core.

There are obviously some caching issues, but this seems to work:

$wgExtensionFunctions[] = function() {
global $wgUser, $wgLogo;
switch ( $wgUser->getOption( 'language' ) ) {

		case 'en':
			$wgLogo = 'en-logo';
			break;
		case 'fr':
			$wgLogo = 'fr-logo';
			break;
		default:
			$wgLogo = 'default-logo';

}
};

(In reply to comment #6)

There are obviously some caching issues, but this seems to work:

$wgExtensionFunctions[] = function() {

global $wgUser, $wgLogo;
switch ( $wgUser->getOption( 'language' ) ) {
    case 'en':
        $wgLogo = 'en-logo';
        break;
    case 'fr':
        $wgLogo = 'fr-logo';
        break;
    default:
        $wgLogo = 'default-logo';
}

};

Ugh, $wgUser and varying config on request state.

Please use the SkinTemplateOutputPageBeforeExec to modify logopath instead of using that hack.

(In reply to comment #7)

Ugh, $wgUser and varying config on request state.

Please use the SkinTemplateOutputPageBeforeExec to modify logopath instead of
using that hack.

[[m:Cunningham's Law]] strikes again! Thanks, your solution is much better.

For https://nimiarkisto.fi/ I used BeforePageDisplay and CSS approach. Works okay to my knowledge as long as there is no frontend cache.

Current practice is to use Mediawiki:Common.css for this. See d:Mediawiki:Common.css, for example:

/* Language-specific logos */

#p-logo:lang(ar) a {
	background-image: url( //upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Wikidata-logo-ar.png/140px-Wikidata-logo-ar.png ) !important;
}

#p-logo:lang(bn) a {
	background-image: url( //upload.wikimedia.org/wikipedia/commons/b/ba/Wikidata-logo-bn-156px.png ) !important;
}

#p-logo:lang(eo) a {
	background-image: url( //upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Wikidata-logo-eo.svg/156px-Wikidata-logo-eo.svg.png ) !important;
}

#p-logo:lang(lfn) a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Wikidata-logo-lfn.svg/156px-Wikidata-logo-lfn.svg.png) !important;
}

#p-logo:lang(sk) a {
	background-image: url( //upload.wikimedia.org/wikipedia/commons/thumb/5/57/Wikidata-logo-sk.svg/156px-Wikidata-logo-sk.svg.png ) !important;
}

#p-logo:lang(uk) a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Wikidata-logo-uk.svg/156px-Wikidata-logo-uk.svg.png) !important;
}

#p-logo:lang(ur) a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Wikidata-logo-ur.svg/156px-Wikidata-logo-ur.svg.png) !important;
}

Would it be better to use "language" than "variant" for the key name?

Would it be better to use "language" than "variant" for the key name?

I think the "variant" here means "variants of logos", although they are varied by language code.

This will be a good thing. But it should only enable by users manually. If all site has it's fixed wiki logo then it will great. I suggest all users and editor to set their language preference for this action.

I think the "variant" here means "variants of logos", although they are varied by language code.

It is actually quite confusing as the documentation ( https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgLogos ) wrote "Supported variants".