From 94309948d1db0d69e9211235428c447b74cf3b00 Mon Sep 17 00:00:00 2001 From: Tacsipacsi Date: Wed, 24 Sep 2025 11:28:55 +0200 Subject: [PATCH] Fall back to `mul` labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wikidata recently introduced “default values for labels” (https://www.wikidata.org/wiki/WD:mul) to reduce size of items. One particular example where these are used is humans, since humans’ names are written the same in all Latin-script languages. Well, mostly. For example, Leonardo da Vinci (https://www.wikidata.org/wiki/Q762) is called “Léonard de Vinci” in French, and because all labels that use the Italian spelling have been removed (including Dutch, English and German), now the Dutch interface falls back to the only label we extracted, saying that the namesake of Leonardo da Vincistraat is “Léonard de Vinci” rather than “Leonardo da Vinci”. (I couldn’t find such an example in Brussels, but it’s possible that *all* labels are removed in favor of `mul`, in which case we wouldn’t extract any label, and the frontend would display `null`. That’d be even worse than showing a French label on the Dutch interface.) This patch fixes this by falling back to the `mul` label if there is no label in the given language. This is only a fallback, so the French interface still says that the rue Léonard de Vinci is named after “Léonard de Vinci”; and it affects only labels, not descriptions, as there are no `mul` descriptions. --- Wikidata/Wikidata.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Wikidata/Wikidata.php b/Wikidata/Wikidata.php index fb1c8d6..32b70f0 100644 --- a/Wikidata/Wikidata.php +++ b/Wikidata/Wikidata.php @@ -42,8 +42,9 @@ public static function extractLabels($entity, array $languages): array $labels = []; foreach ($languages as $language) { - if (isset($entity->labels->{$language})) { // @phpstan-ignore-line - $labels[$language] = $entity->labels->{$language}; // @phpstan-ignore-line + $label = $entity->labels->{$language} ?? $entity->labels->mul ?? null; // @phpstan-ignore-line + if ($label !== null) { + $labels[$language] = $label; } }