Skip to content

Commit

Permalink
Keyboard layout descriptions: more liberal language name check
Browse files Browse the repository at this point in the history
Checking whether the layout+variant description from evdev starts
with the exact ISO-ified name of the language or country with
which it's associated is rather too strict. See things like the
official ISO name of Iran - "Iran, Islamic Republic of" - or the
ISO name of modern Greek - "Greek, Modern (1453-)" - or Berber -
"Berber languages". These cases mean our layout list winds up with
entries like "Greek, Modern (1453-) (Greek)" in it.

Avoid that with a more liberal check. Once we have our 'lang'
string, take the first word of it, strip any trailing commas and
semi-colons, then check if that word is in the evdev description,
and if so, don't prepend the lang string.

Signed-off-by: Adam Williamson <[email protected]>
  • Loading branch information
AdamWill committed Nov 21, 2023
1 parent 2870794 commit 3b6be72
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pyanaconda/ui/gui/xkl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,16 @@ def get_layout_variant_description(self, layout_variant, with_lang=True, xlated=
lang = upcase_first_letter(layout_info.langs[0])
description = layout_info.desc

if with_lang and lang and not description.startswith(lang):
return "%s (%s)" % (lang, description)
else:
return description
if with_lang and lang:
# ISO language/country names can be things like
# "Occitan (post 1500); Provencal", or
# "Iran, Islamic Republic of", or "Greek, Modern (1453-)"
# or "Catalan; Valencian": let's handle that gracefully
checklang = lang.split()[0].strip(",;")
if checklang not in description:
return "%s (%s)" % (lang, description)

return description

def get_switch_opt_description(self, switch_opt):
"""
Expand Down

0 comments on commit 3b6be72

Please sign in to comment.