Page MenuHomePhabricator

Support language fallback for logo variants
Closed, DeclinedPublic

Description

There are at least 5 Chinese wikis that still have logo variant overrides in site css (T273578), the current approach available in the config is to copy and paste the same logo definition 4 times.
They don't have a wordmark or tagline now, but they may have in the future, which will be a big duplication in the config.

As a part of the user interface, it should be able to follow the fallback chain defined as language properties, like the fallback for interface messages.
We also want to limit the fallback depth, since the fallback chain is not limited to the same group of variants, so I'd like to introduce a new key fallback.

Expected config:

'wmgSiteLogoVariants' => [
	'zhwiki' => [
		'zh-hans' => [
			'fallback' => [ 'zh-cn', 'zh-my', 'zh-sg' ],
			'1x' => '/static/images/project-logos/zhwiki-hans.png',
			'1.5x' => '/static/images/project-logos/zhwiki-hans-1.5x.png',
			'2x' => '/static/images/project-logos/zhwiki-hans-2x.png',
			'wordmark' => [
				'src' => '/static/images/mobile/copyright/wikipedia-wordmark-zh-hans.svg',
				'width' => 105,
				'height' => 23,
			],
			'tagline' => [
				'src' => '/static/images/mobile/copyright/wikipedia-tagline-zh-hans.svg',
				'width' => 103,
				'height' => 15,
			],
		],
	],
],

Inspired by the old description of T273578 by @Legoktm

Event Timeline

Change 775422 had a related patch set uploaded (by Func; author: Func):

[mediawiki/core@master] Support language fallback for logo variants

https://gerrit.wikimedia.org/r/775422

The suggested solution adds complexity to some already complicated code. If the problem trying to be solved is to avoid copy and pasting, I am wondering if you have considered a refactor of the configuration code itself?

the current approach available in the config is to copy and paste the same logo definition 4 times.

The current configuration (wmf-config/CommonSettings.php) looks like this:

if ( isset( $wmgSiteLogo1x ) ) {
	$wgLogos = [
		'1x' => $wmgSiteLogo1x ?? null,
		'1.5x' => $wmgSiteLogo1_5x ?? null,
		'2x' => $wmgSiteLogo2x ?? null,
		'icon' => $wmgSiteLogoIcon ?? null,
		'wordmark' => $wmgSiteLogoWordmark ?? null,
		'tagline' => $wmgSiteLogoTagline ?? null,
		'variants' => $wmgSiteLogoVariants ?? null,
	];
}

Couldn't you do something like this:

if  ( in_array(   $wgLanguageCode, [ 'zh-cn', 'zh-my', 'zh-sg' ] ) ) {
  $wgLogos['variants'] = $wmgSiteLogoChineseVariants;
}

with wmf-config/InitialiseSettings.php:

`
'wmgSiteLogoChineseVariants' => [
			'1x' => '/static/images/project-logos/zhwiki-hans.png',
			'1.5x' => '/static/images/project-logos/zhwiki-hans-1.5x.png',
			'2x' => '/static/images/project-logos/zhwiki-hans-2x.png',
			'wordmark' => [
				'src' => '/static/images/mobile/copyright/wikipedia-wordmark-zh-hans.svg',
				'width' => 105,
				'height' => 23,
			],
			'tagline' => [
				'src' => '/static/images/mobile/copyright/wikipedia-tagline-zh-hans.svg',
				'width' => 103,
				'height' => 15,
			],

Change 775422 abandoned by Func:

[mediawiki/core@master] Support language fallback for logo variants

Reason:

https://gerrit.wikimedia.org/r/775422

I think we should use the language fallback chain instead of defining every language variant.

Change 799415 had a related patch set uploaded (by Stang; author: Stang):

[operations/mediawiki-config@master] Add language fallback support for wmgSiteLogoVariants

https://gerrit.wikimedia.org/r/799415

Change 806944 had a related patch set uploaded (by Stang; author: Stang):

[operations/mediawiki-config@master] Define default value for "wmgSiteLogoVariants"

https://gerrit.wikimedia.org/r/806944

Change 806944 merged by jenkins-bot:

[operations/mediawiki-config@master] Define default value for "wmgSiteLogoVariants"

https://gerrit.wikimedia.org/r/806944

Change 799415 merged by jenkins-bot:

[operations/mediawiki-config@master] Add language fallback support for wmgSiteLogoVariants

https://gerrit.wikimedia.org/r/799415

Mentioned in SAL (#wikimedia-operations) [2022-08-11T20:47:30Z] <thcipriani@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: [[gerrit:806944|Define default value for "wmgSiteLogoVariants" (T305692 T308620)]] (duration: 03m 07s)

Mentioned in SAL (#wikimedia-operations) [2022-08-11T21:04:35Z] <thcipriani@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: revert [[gerrit:806944|Define default value for "wmgSiteLogoVariants" (T305692 T308620)]] (duration: 03m 15s)