diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index cae51df2c2..327b43e98f 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -269,12 +269,17 @@ def _update_lang_text(self) -> None: The options for the global menu are generated with a static text; each entry of the menu needs to be updated with the new translation """ + from archinstall.tui.ui.components import TApp, _translate_bindings + new_options = self._get_menu_options() for o in new_options: if o.key is not None: self._item_group.find_by_key(o.key).text = o.text + if TApp.app is not None: + _translate_bindings(TApp.app) + async def _locale_selection(self, preset: LocaleConfiguration) -> LocaleConfiguration | None: locale_config = await LocaleMenu(preset).show() return locale_config diff --git a/archinstall/locales/base.pot b/archinstall/locales/base.pot index 34ed316db0..756d29e4a2 100644 --- a/archinstall/locales/base.pot +++ b/archinstall/locales/base.pot @@ -1709,6 +1709,123 @@ msgstr "" msgid "Exit search mode" msgstr "" +msgid "General" +msgstr "" + +msgid "Navigation" +msgstr "" + +msgid "Selection" +msgstr "" + +msgid "Search" +msgstr "" + +msgid "Down" +msgstr "" + +msgid "Up" +msgstr "" + +msgid "Confirm" +msgstr "" + +msgid "Focus right" +msgstr "" + +msgid "Focus left" +msgstr "" + +msgid "Toggle" +msgstr "" + +msgid "Show/Hide help" +msgstr "" + +msgid "Quit" +msgstr "" + +msgid "First" +msgstr "" + +msgid "Last" +msgstr "" + +msgid "Select" +msgstr "" + +msgid "Page Up" +msgstr "" + +msgid "Page Down" +msgstr "" + +msgid "Page up" +msgstr "" + +msgid "Page down" +msgstr "" + +msgid "Page Left" +msgstr "" + +msgid "Page Right" +msgstr "" + +msgid "Cursor up" +msgstr "" + +msgid "Cursor down" +msgstr "" + +msgid "Cursor right" +msgstr "" + +msgid "Cursor left" +msgstr "" + +msgid "Top" +msgstr "" + +msgid "Bottom" +msgstr "" + +msgid "Home" +msgstr "" + +msgid "End" +msgstr "" + +msgid "Toggle option" +msgstr "" + +msgid "Scroll Up" +msgstr "" + +msgid "Scroll Down" +msgstr "" + +msgid "Scroll Left" +msgstr "" + +msgid "Scroll Right" +msgstr "" + +msgid "Scroll Home" +msgstr "" + +msgid "Scroll End" +msgstr "" + +msgid "Focus Next" +msgstr "" + +msgid "Focus Previous" +msgstr "" + +msgid "Copy selected text" +msgstr "" + msgid "" "labwc needs access to your seat (collection of hardware devices i.e. " "keyboard, mouse, etc)" diff --git a/archinstall/locales/uk/LC_MESSAGES/base.mo b/archinstall/locales/uk/LC_MESSAGES/base.mo index 6d6f7558c3..ad1301397a 100644 Binary files a/archinstall/locales/uk/LC_MESSAGES/base.mo and b/archinstall/locales/uk/LC_MESSAGES/base.mo differ diff --git a/archinstall/locales/uk/LC_MESSAGES/base.po b/archinstall/locales/uk/LC_MESSAGES/base.po index b88fd2901e..5ad4bcb37b 100644 --- a/archinstall/locales/uk/LC_MESSAGES/base.po +++ b/archinstall/locales/uk/LC_MESSAGES/base.po @@ -1663,6 +1663,123 @@ msgstr "Запустити режим пошуку" msgid "Exit search mode" msgstr "Вийти з режиму пошуку" +msgid "General" +msgstr "Загальне" + +msgid "Navigation" +msgstr "Навігація" + +msgid "Selection" +msgstr "Вибір" + +msgid "Search" +msgstr "Пошук" + +msgid "Down" +msgstr "Вниз" + +msgid "Up" +msgstr "Вгору" + +msgid "Confirm" +msgstr "Підтвердити" + +msgid "Focus right" +msgstr "Фокус вправо" + +msgid "Focus left" +msgstr "Фокус вліво" + +msgid "Toggle" +msgstr "Перемкнути" + +msgid "Show/Hide help" +msgstr "Показати/Сховати довідку" + +msgid "Quit" +msgstr "Вийти" + +msgid "First" +msgstr "На початок" + +msgid "Last" +msgstr "В кінець" + +msgid "Select" +msgstr "Обрати" + +msgid "Page Up" +msgstr "Сторінка вгору" + +msgid "Page Down" +msgstr "Сторінка вниз" + +msgid "Page up" +msgstr "Сторінка вгору" + +msgid "Page down" +msgstr "Сторінка вниз" + +msgid "Page Left" +msgstr "Сторінка вліво" + +msgid "Page Right" +msgstr "Сторінка вправо" + +msgid "Cursor up" +msgstr "Курсор вгору" + +msgid "Cursor down" +msgstr "Курсор вниз" + +msgid "Cursor right" +msgstr "Курсор вправо" + +msgid "Cursor left" +msgstr "Курсор вліво" + +msgid "Top" +msgstr "На початок" + +msgid "Bottom" +msgstr "В кінець" + +msgid "Home" +msgstr "Початок" + +msgid "End" +msgstr "Кінець" + +msgid "Toggle option" +msgstr "Перемкнути опцію" + +msgid "Scroll Up" +msgstr "Прокрутка вгору" + +msgid "Scroll Down" +msgstr "Прокрутка вниз" + +msgid "Scroll Left" +msgstr "Прокрутка вліво" + +msgid "Scroll Right" +msgstr "Прокрутка вправо" + +msgid "Scroll Home" +msgstr "Прокрутка на початок" + +msgid "Scroll End" +msgstr "Прокрутка в кінець" + +msgid "Focus Next" +msgstr "Фокус на наступний" + +msgid "Focus Previous" +msgstr "Фокус на попередній" + +msgid "Copy selected text" +msgstr "Копіювати виділений текст" + msgid "labwc needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)" msgstr "labwc потребує доступ до вашого місця (набору апаратних пристроїв, таких як клавіатура, миша тощо)" diff --git a/archinstall/tui/help.py b/archinstall/tui/help.py index 2a1ab106ba..e09d993a8c 100644 --- a/archinstall/tui/help.py +++ b/archinstall/tui/help.py @@ -97,7 +97,7 @@ def get_help_text() -> str: max_key_width = max([help.get_key_width() for help in help_texts]) for help_group in help_texts: - help_output += f'{help_group.group_id.value}\n' + help_output += f'{tr(help_group.group_id.value)}\n' divider_len = max_desc_width + max_key_width help_output += '-' * divider_len + '\n' diff --git a/archinstall/tui/ui/components.py b/archinstall/tui/ui/components.py index 475f7b1795..72cce32c86 100644 --- a/archinstall/tui/ui/components.py +++ b/archinstall/tui/ui/components.py @@ -1,7 +1,7 @@ import sys from abc import ABC, abstractmethod from collections.abc import Awaitable, Callable -from dataclasses import dataclass +from dataclasses import dataclass, replace from enum import Enum, auto from typing import Any, ClassVar, Literal, TypeVar, cast, override @@ -27,6 +27,13 @@ ValueT = TypeVar('ValueT') +def _translate_bindings(widget: Any) -> None: + if widget._merged_bindings is None: + return + for key, bindings in widget._merged_bindings.key_to_bindings.items(): + widget._bindings.key_to_bindings[key] = [replace(b, description=tr(b.description)) if b.description else b for b in bindings] + + class BaseScreen(Screen[Result[ValueT]]): BINDINGS: ClassVar = [ Binding('escape', 'cancel_operation', 'Cancel', show=True), @@ -97,6 +104,7 @@ def compose(self) -> ComposeResult: yield Footer() def on_mount(self) -> None: + _translate_bindings(self) if self._data_callback: self._exec_callback() else: @@ -129,6 +137,10 @@ class _OptionList(OptionList): Binding('k', 'cursor_up', 'Up', show=False), ] + @override + def on_mount(self) -> None: + _translate_bindings(self) + class OptionListScreen(BaseScreen[ValueT]): """ @@ -271,6 +283,7 @@ def compose(self) -> ComposeResult: yield Footer() def on_mount(self) -> None: + _translate_bindings(self) self._update_options(self._options) self.query_one(OptionList).focus() @@ -355,6 +368,10 @@ class _SelectionList(SelectionList[ValueT]): Binding('k', 'cursor_up', 'Up', show=False), ] + @override + def on_mount(self) -> None: + _translate_bindings(self) + class SelectListScreen(BaseScreen[ValueT]): """ @@ -499,6 +516,7 @@ def on_input_submitted(self, event: Input.Submitted) -> None: self._handle_search_action() def on_mount(self) -> None: + _translate_bindings(self) self._update_options(self._options) self.query_one(SelectionList).focus() @@ -660,6 +678,7 @@ def compose(self) -> ComposeResult: yield Footer() def on_mount(self) -> None: + _translate_bindings(self) self._update_selection() def action_focus_right(self) -> None: @@ -815,6 +834,7 @@ def compose(self) -> ComposeResult: yield Footer() def on_mount(self) -> None: + _translate_bindings(self) input_field = self.query_one('#main_input', Input) input_field.focus() @@ -854,6 +874,10 @@ class _DataTable(DataTable[ValueT]): Binding('k', 'cursor_up', 'Up', show=False), ] + @override + def on_mount(self) -> None: + _translate_bindings(self) + class TableSelectionScreen(BaseScreen[ValueT]): BINDINGS: ClassVar = [ @@ -974,6 +998,7 @@ def compose(self) -> ComposeResult: yield Footer() def on_mount(self) -> None: + _translate_bindings(self) self._display_header(True) data_table = self.query_one(DataTable) data_table.cell_padding = 2 @@ -1229,6 +1254,7 @@ def action_trigger_help(self) -> None: _ = self.screen.mount(HelpPanel()) def on_mount(self) -> None: + _translate_bindings(self) self._run_worker() @work