Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-08-30 19:34:25 +0200
committerGitHub <noreply@github.com>2022-08-30 19:34:25 +0200
commitf6e695871cdf55dd5277a955ff63a1ee1fd14348 (patch)
treec5ced73dd09e9fdf1d9058f358ded7acc955921f /archinstall/lib
parentee64276f0e3651367de51e1423f3767dde1be525 (diff)
Homogenize language option during handling (#1446)
* Adding a more elaborate fix * Added recovery function to selecting language too * Tweaked return value of display_language() to return the Language() object.
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/menu/global_menu.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/archinstall/lib/menu/global_menu.py b/archinstall/lib/menu/global_menu.py
index f631c086..fc7c90bc 100644
--- a/archinstall/lib/menu/global_menu.py
+++ b/archinstall/lib/menu/global_menu.py
@@ -36,10 +36,21 @@ from ..user_interaction import add_number_of_parrallel_downloads
from ..models.users import User
from ..user_interaction.partitioning_conf import current_partition_layout
from ..output import FormattedOutput
+from ..translationhandler import Language
if TYPE_CHECKING:
_: Any
+def display_language(global_menu, x):
+ if type(x) == Language:
+ return x
+ elif type(x) == str:
+ translation_handler = global_menu._translation_handler
+ for language in translation_handler._get_translations():
+ if language.lang == x:
+ return language
+ else:
+ raise ValueError(f"Language entry needs to Language() object or string of full language like 'English'.")
class GlobalMenu(GeneralMenu):
def __init__(self,data_store):
@@ -51,8 +62,8 @@ class GlobalMenu(GeneralMenu):
self._menu_options['archinstall-language'] = \
Selector(
_('Archinstall language'),
- lambda x: self._select_archinstall_language(x),
- display_func=lambda x: x.display_name,
+ lambda x: self._select_archinstall_language(display_language(self, x)),
+ display_func=lambda x: display_language(self, x).display_name,
default=self.translation_handler.get_language('en'))
self._menu_options['keyboard-layout'] = \
Selector(