Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions archinstall/lib/global_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from archinstall.lib.packages.packages import list_available_packages, select_additional_packages
from archinstall.lib.pacman.config import PacmanConfig
from archinstall.lib.translationhandler import Language, tr, translation_handler
from archinstall.tui.ui.components import tui
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup


Expand Down Expand Up @@ -275,6 +276,8 @@ def _update_lang_text(self) -> None:
if o.key is not None:
self._item_group.find_by_key(o.key).text = o.text

tui.translate_bindings()

async def _locale_selection(self, preset: LocaleConfiguration) -> LocaleConfiguration | None:
locale_config = await LocaleMenu(preset).show()
return locale_config
Expand Down
117 changes: 117 additions & 0 deletions archinstall/locales/base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Binary file modified archinstall/locales/uk/LC_MESSAGES/base.mo
Binary file not shown.
117 changes: 117 additions & 0 deletions archinstall/locales/uk/LC_MESSAGES/base.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 потребує доступ до вашого місця (набору апаратних пристроїв, таких як клавіатура, миша тощо)"

Expand Down
40 changes: 38 additions & 2 deletions archinstall/tui/ui/components.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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

from textual import work
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.binding import Binding, BindingsMap
from textual.containers import Center, Horizontal, ScrollableContainer, Vertical
from textual.events import Key
from textual.geometry import Offset
Expand All @@ -27,6 +27,18 @@
ValueT = TypeVar('ValueT')


def _translate_bindings(source: BindingsMap | None, target: BindingsMap) -> None:
"""Translate binding descriptions from source to target.

Uses source (original, immutable class-level cache) to avoid
double-translation on repeated calls (e.g. language switch).
"""
if source is None:
return
for key, bindings in source.key_to_bindings.items():
target.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),
Expand Down Expand Up @@ -97,6 +109,7 @@ def compose(self) -> ComposeResult:
yield Footer()

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
if self._data_callback:
self._exec_callback()
else:
Expand Down Expand Up @@ -129,6 +142,10 @@ class _OptionList(OptionList):
Binding('k', 'cursor_up', 'Up', show=False),
]

@override
def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)


class OptionListScreen(BaseScreen[ValueT]):
"""
Expand Down Expand Up @@ -271,6 +288,7 @@ def compose(self) -> ComposeResult:
yield Footer()

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
self._update_options(self._options)
self.query_one(OptionList).focus()

Expand Down Expand Up @@ -356,6 +374,10 @@ class _SelectionList(SelectionList[ValueT]):
Binding('space', 'select', 'Toggle', show=True),
]

@override
def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)


class SelectListScreen(BaseScreen[ValueT]):
"""
Expand Down Expand Up @@ -500,6 +522,7 @@ def on_input_submitted(self, event: Input.Submitted) -> None:
self._handle_search_action()

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
self._update_options(self._options)
self.query_one(SelectionList).focus()

Expand Down Expand Up @@ -670,6 +693,7 @@ def compose(self) -> ComposeResult:
yield Footer()

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
self._update_selection()

def action_focus_right(self) -> None:
Expand Down Expand Up @@ -825,6 +849,7 @@ def compose(self) -> ComposeResult:
yield Footer()

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
input_field = self.query_one('#main_input', Input)
input_field.focus()

Expand Down Expand Up @@ -872,6 +897,10 @@ class _DataTable(DataTable[ValueT]):
Binding('enter', 'select_cursor', 'Confirm', show=True),
]

@override
def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)


class TableSelectionScreen(BaseScreen[ValueT]):
BINDINGS: ClassVar = [
Expand Down Expand Up @@ -992,6 +1021,7 @@ def compose(self) -> ComposeResult:
yield Footer()

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
self._display_header(True)
data_table = self.query_one(DataTable)
data_table.cell_padding = 2
Expand Down Expand Up @@ -1245,6 +1275,7 @@ def action_trigger_help(self) -> None:
_ = self.screen.mount(HelpPanel())

def on_mount(self) -> None:
_translate_bindings(self._merged_bindings, self._bindings)
self._run_worker()

@work
Expand Down Expand Up @@ -1291,5 +1322,10 @@ def exit(self, result: Any) -> None:
assert TApp.app
TApp.app.exit(result)

def translate_bindings(self) -> None:
"""Re-translate app-level binding descriptions after language change."""
if TApp.app is not None:
_translate_bindings(TApp.app._merged_bindings, TApp.app._bindings)


tui = TApp()
Loading