Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/menu/list_manager.py8
-rw-r--r--archinstall/lib/menu/selection_menu.py5
-rw-r--r--archinstall/lib/translation.py26
-rw-r--r--archinstall/lib/user_interaction/general_conf.py2
4 files changed, 26 insertions, 15 deletions
diff --git a/archinstall/lib/menu/list_manager.py b/archinstall/lib/menu/list_manager.py
index f3927e6f..4c7e9907 100644
--- a/archinstall/lib/menu/list_manager.py
+++ b/archinstall/lib/menu/list_manager.py
@@ -260,14 +260,14 @@ class ListManager:
self._data.append(self.target)
if self.action == str(_('Copy')):
while True:
- target = TextInput(_('Copy to :'),self.target).run()
+ target = TextInput(_('Copy to: '),self.target).run()
if target != self.target:
self._data.append(self.target)
break
elif self.action == str(_('Edit')):
tgt = self.target
idx = self._data.index(self.target)
- result = TextInput(_('Edite :'),tgt).run()
+ result = TextInput(_('Edit: '),tgt).run()
self._data[idx] = result
elif self.action == str(_('Delete')):
del self._data[self._data.index(self.target)]
@@ -279,7 +279,7 @@ class ListManager:
origkey = None
origval = None
if self.action == str(_('Add')):
- key = TextInput(_('Key :'),None).run()
+ key = TextInput(_('Key: '),None).run()
value = TextInput(_('Value :'),None).run()
self._data[key] = value
if self.action == str(_('Copy')):
@@ -289,7 +289,7 @@ class ListManager:
self._data[key] = origval
break
elif self.action == str(_('Edit')):
- value = TextInput(_(f'Edit {origkey} :'),origval).run()
+ value = TextInput(_('Edit {}: ').format(origkey), origval).run()
self._data[origkey] = value
elif self.action == str(_('Delete')):
del self._data[origkey]
diff --git a/archinstall/lib/menu/selection_menu.py b/archinstall/lib/menu/selection_menu.py
index 54b1441b..123ddf7e 100644
--- a/archinstall/lib/menu/selection_menu.py
+++ b/archinstall/lib/menu/selection_menu.py
@@ -17,7 +17,7 @@ def select_archinstall_language(preset_value: str) -> Optional[str]:
"""
copied from user_interaction/general_conf.py as a temporary measure
"""
- languages = Translation.get_all_names()
+ languages = Translation.get_available_lang()
language = Menu(_('Select Archinstall language'), languages, preset_values=preset_value).run()
return language.value
@@ -306,7 +306,8 @@ class GeneralMenu:
cursor_index=cursor_pos,
preview_command=self._preview_display,
preview_size=self.preview_size,
- skip_empty_entries=True
+ skip_empty_entries=True,
+ skip=False
).run()
if selection.type_ == MenuSelectionType.Selection:
diff --git a/archinstall/lib/translation.py b/archinstall/lib/translation.py
index 74ffd691..c9dd065a 100644
--- a/archinstall/lib/translation.py
+++ b/archinstall/lib/translation.py
@@ -5,14 +5,14 @@ import os
import gettext
from pathlib import Path
-from typing import List, Dict, Any, TYPE_CHECKING
+from typing import List, Dict, Any, TYPE_CHECKING, Tuple
from .exceptions import TranslationError
if TYPE_CHECKING:
_: Any
-class Languages:
+class LanguageDefinitions:
def __init__(self):
self._mappings = self._get_language_mappings()
@@ -70,11 +70,12 @@ class Translation:
def __init__(self, locales_dir):
self._languages = {}
- for name in self.get_all_names():
+ for names in self._get_translation_lang():
try:
- self._languages[name] = gettext.translation('base', localedir=locales_dir, languages=[name])
+ print(names)
+ self._languages[names[0]] = gettext.translation('base', localedir=locales_dir, languages=names)
except FileNotFoundError as error:
- raise TranslationError(f"Could not locate language file for '{name}': {error}")
+ raise TranslationError(f"Could not locate language file for '{names}': {error}")
def activate(self, name):
if language := self._languages.get(name, None):
@@ -94,10 +95,19 @@ class Translation:
return locales_dir
@classmethod
- def get_all_names(cls) -> List[str]:
+ def _defined_languages(cls) -> List[str]:
locales_dir = cls.get_locales_dir()
filenames = os.listdir(locales_dir)
- def_languages = filter(lambda x: len(x) == 2, filenames)
+ return list(filter(lambda x: len(x) == 2, filenames))
- languages = Languages()
+ @classmethod
+ def _get_translation_lang(cls) -> List[Tuple[str, str]]:
+ def_languages = cls._defined_languages()
+ languages = LanguageDefinitions()
+ return [(languages.get_language(lang), lang) for lang in def_languages]
+
+ @classmethod
+ def get_available_lang(cls) -> List[str]:
+ def_languages = cls._defined_languages()
+ languages = LanguageDefinitions()
return [languages.get_language(lang) for lang in def_languages]
diff --git a/archinstall/lib/user_interaction/general_conf.py b/archinstall/lib/user_interaction/general_conf.py
index af996331..43afef8d 100644
--- a/archinstall/lib/user_interaction/general_conf.py
+++ b/archinstall/lib/user_interaction/general_conf.py
@@ -119,7 +119,7 @@ def select_mirror_regions(preset_values: Dict[str, Any] = {}) -> Dict[str, Any]:
def select_archinstall_language(default='English'):
- languages = Translation.get_all_names()
+ languages = Translation.get_available_lang()
language = Menu(_('Select Archinstall language'), languages, default_option=default).run()
return language