Skip to content

apps: Support empty lang attribute#23079

Open
Venefilyn wants to merge 2 commits intocockpit-project:mainfrom
Venefilyn:apps/support-empty-lang
Open

apps: Support empty lang attribute#23079
Venefilyn wants to merge 2 commits intocockpit-project:mainfrom
Venefilyn:apps/support-empty-lang

Conversation

@Venefilyn
Copy link
Copy Markdown
Member

@Venefilyn Venefilyn commented Mar 31, 2026

When we look for a specific language for an element in AppStream, such
as Summary or Description, we first try to find the requested language
otherwise we fallback to the first element we found.

As the first item might not be the default language in some cases we
could get a format like this

<summary xml:lang="fr">Gestionnaire d'abonnement dans Cockpit</summary>
<summary>Subscription Manager in Cockpit</summary>
<summary xml:lang="it">Gestore abbonamenti nel Cockpit</summary>
<summary xml:lang="ja">Cockpit のサブスクリプションマネージャー</summary>
<summary xml:lang="ka">გამოწერების მმართველი Cockpit-ში</summary>
<summary xml:lang="ko">Cockpit 서브스크립션 관리자</summary>
<summary xml:lang="ru">Менеджер подписок в Cockpit</summary>
<summary xml:lang="zh-Hans-CN">Cockpit 中的订阅管理器</summary>

In this case we'd choose the first summary found which would be French
instead of English.

Instead, we can first look for the language we want, and if we found an
element without language attribute we use that as a fallback. If both
fail we still fallback to the first element found.

Signed-off-by: Freya Gustavsson freya@venefilyn.se

@Venefilyn Venefilyn force-pushed the apps/support-empty-lang branch 2 times, most recently from 9d00c0a to 287191b Compare April 1, 2026 13:50
Copy link
Copy Markdown
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the "choose the element with no language tag" should also apply to the case that lang is None? ie: we probably want to loop in that case as well now, and select the "no language" item and return it.

A comment at the bottom "in case we don't find the requested language or an element without a language tag, we use the first tag as a final fallback" might be useful.

It might also be useful to add typing here, in general because it's nice, but specifically since it would force us to reason about the possibility that xml.find() returns None...

@allisonkarlitskaya
Copy link
Copy Markdown
Member

... also, those test fails seem possibly relevant.

@Venefilyn Venefilyn force-pushed the apps/support-empty-lang branch from 287191b to 11e59c9 Compare April 13, 2026 15:46
When we look for a specific language for an element in AppStream, such
as Summary or Description, we first try to find the requested language
otherwise we fallback to the first element we found.

As the first item might not be the default language in some cases we
could get a format like this

<summary xml:lang="fr">Gestionnaire d'abonnement dans Cockpit</summary>
<summary>Subscription Manager in Cockpit</summary>
<summary xml:lang="it">Gestore abbonamenti nel Cockpit</summary>
<summary xml:lang="ja">Cockpit のサブスクリプションマネージャー</summary>
<summary xml:lang="ka">გამოწერების მმართველი Cockpit-ში</summary>
<summary xml:lang="ko">Cockpit 서브스크립션 관리자</summary>
<summary xml:lang="ru">Менеджер подписок в Cockpit</summary>
<summary xml:lang="zh-Hans-CN">Cockpit 中的订阅管理器</summary>

In this case we'd choose the first summary found which would be French
instead of English.

Instead, we can first look for the language we want, and if we found an
element without language attribute we use that as a fallback. If both
fail we still fallback to the first element found.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
Due to frequent timeouts during testing lets increase the timeout to
make sure it has time to update before the timeout.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
@Venefilyn Venefilyn force-pushed the apps/support-empty-lang branch from 11e59c9 to b1c7556 Compare April 14, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants