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
11 changes: 2 additions & 9 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sys
import time
import traceback
from typing import TYPE_CHECKING

from archinstall.lib.args import arch_config_handler
from archinstall.lib.disk.utils import disk_layouts
Expand All @@ -14,14 +13,9 @@
from .lib.output import FormattedOutput, debug, error, info, log, warn
from .lib.pacman import Pacman
from .lib.plugins import load_plugin, plugins
from .lib.translationhandler import DeferredTranslation, Language, translation_handler
from .lib.translationhandler import Language, tr, translation_handler
from .tui.curses_menu import Tui

if TYPE_CHECKING:
from collections.abc import Callable

_: Callable[[str], DeferredTranslation]


# @archinstall.plugin decorator hook to programmatically add
# plugins in runtime. Useful in profiles_bck and other things.
Expand Down Expand Up @@ -76,7 +70,7 @@ def main() -> int:
return 0

if os.getuid() != 0:
print(_("Archinstall requires root privileges to run. See --help for more."))
print(tr("Archinstall requires root privileges to run. See --help for more."))
return 1

_log_sys_info()
Expand Down Expand Up @@ -125,7 +119,6 @@ def run_as_a_module() -> None:


__all__ = [
"DeferredTranslation",
"FormattedOutput",
"Language",
"Pacman",
Expand Down
16 changes: 5 additions & 11 deletions archinstall/default_profiles/desktops/hyprland.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
from typing import TYPE_CHECKING, override
from typing import override

from archinstall.default_profiles.desktops import SeatAccess
from archinstall.default_profiles.profile import GreeterType, ProfileType
from archinstall.default_profiles.xorg import XorgProfile
from archinstall.lib.translationhandler import tr
from archinstall.tui.curses_menu import SelectMenu
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
from archinstall.tui.result import ResultType
from archinstall.tui.types import Alignment, FrameProperties

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation

_: Callable[[str], DeferredTranslation]


class HyprlandProfile(XorgProfile):
def __init__(self) -> None:
Expand Down Expand Up @@ -54,8 +48,8 @@ def services(self) -> list[str]:

def _ask_seat_access(self) -> None:
# need to activate seat service and add to seat group
header = str(_("Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)"))
header += "\n" + str(_("Choose an option to give Hyprland access to your hardware")) + "\n"
header = tr("Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)")
header += "\n" + tr("Choose an option to give Hyprland access to your hardware") + "\n"

items = [MenuItem(s.value, value=s) for s in SeatAccess]
group = MenuItemGroup(items, sort_items=True)
Expand All @@ -67,7 +61,7 @@ def _ask_seat_access(self) -> None:
group,
header=header,
allow_skip=False,
frame=FrameProperties.min(str(_("Seat access"))),
frame=FrameProperties.min(tr("Seat access")),
alignment=Alignment.CENTER,
).run()

Expand Down
16 changes: 5 additions & 11 deletions archinstall/default_profiles/desktops/labwc.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
from typing import TYPE_CHECKING, override
from typing import override

from archinstall.default_profiles.desktops import SeatAccess
from archinstall.default_profiles.profile import GreeterType, ProfileType
from archinstall.default_profiles.xorg import XorgProfile
from archinstall.lib.translationhandler import tr
from archinstall.tui.curses_menu import SelectMenu
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
from archinstall.tui.result import ResultType
from archinstall.tui.types import Alignment, FrameProperties

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation

_: Callable[[str], DeferredTranslation]


class LabwcProfile(XorgProfile):
def __init__(self) -> None:
Expand Down Expand Up @@ -51,8 +45,8 @@ def services(self) -> list[str]:

def _ask_seat_access(self) -> None:
# need to activate seat service and add to seat group
header = str(_("labwc needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)"))
header += "\n" + str(_("Choose an option to give labwc access to your hardware")) + "\n"
header = tr("labwc needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)")
header += "\n" + tr("Choose an option to give labwc access to your hardware") + "\n"

items = [MenuItem(s.value, value=s) for s in SeatAccess]
group = MenuItemGroup(items, sort_items=True)
Expand All @@ -64,7 +58,7 @@ def _ask_seat_access(self) -> None:
group,
header=header,
allow_skip=False,
frame=FrameProperties.min(str(_("Seat access"))),
frame=FrameProperties.min(tr("Seat access")),
alignment=Alignment.CENTER,
).run()

Expand Down
16 changes: 5 additions & 11 deletions archinstall/default_profiles/desktops/niri.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
from typing import TYPE_CHECKING, override
from typing import override

from archinstall.default_profiles.desktops import SeatAccess
from archinstall.default_profiles.profile import GreeterType, ProfileType
from archinstall.default_profiles.xorg import XorgProfile
from archinstall.lib.translationhandler import tr
from archinstall.tui.curses_menu import SelectMenu
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
from archinstall.tui.result import ResultType
from archinstall.tui.types import Alignment, FrameProperties

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation

_: Callable[[str], DeferredTranslation]


class NiriProfile(XorgProfile):
def __init__(self) -> None:
Expand Down Expand Up @@ -59,8 +53,8 @@ def services(self) -> list[str]:

def _ask_seat_access(self) -> None:
# need to activate seat service and add to seat group
header = str(_("niri needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)"))
header += "\n" + str(_("Choose an option to give niri access to your hardware")) + "\n"
header = tr("niri needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)")
header += "\n" + tr("Choose an option to give niri access to your hardware") + "\n"

items = [MenuItem(s.value, value=s) for s in SeatAccess]
group = MenuItemGroup(items, sort_items=True)
Expand All @@ -72,7 +66,7 @@ def _ask_seat_access(self) -> None:
group,
header=header,
allow_skip=False,
frame=FrameProperties.min(str(_("Seat access"))),
frame=FrameProperties.min(tr("Seat access")),
alignment=Alignment.CENTER,
).run()

Expand Down
16 changes: 5 additions & 11 deletions archinstall/default_profiles/desktops/sway.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
from typing import TYPE_CHECKING, override
from typing import override

from archinstall.default_profiles.desktops import SeatAccess
from archinstall.default_profiles.profile import GreeterType, ProfileType
from archinstall.default_profiles.xorg import XorgProfile
from archinstall.lib.translationhandler import tr
from archinstall.tui.curses_menu import SelectMenu
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
from archinstall.tui.result import ResultType
from archinstall.tui.types import Alignment, FrameProperties

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation

_: Callable[[str], DeferredTranslation]


class SwayProfile(XorgProfile):
def __init__(self) -> None:
Expand Down Expand Up @@ -61,8 +55,8 @@ def services(self) -> list[str]:

def _ask_seat_access(self) -> None:
# need to activate seat service and add to seat group
header = str(_("Sway needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)"))
header += "\n" + str(_("Choose an option to give Sway access to your hardware")) + "\n"
header = tr("Sway needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)")
header += "\n" + tr("Choose an option to give Sway access to your hardware") + "\n"

items = [MenuItem(s.value, value=s) for s in SeatAccess]
group = MenuItemGroup(items, sort_items=True)
Expand All @@ -74,7 +68,7 @@ def _ask_seat_access(self) -> None:
group,
header=header,
allow_skip=False,
frame=FrameProperties.min(str(_("Seat access"))),
frame=FrameProperties.min(tr("Seat access")),
alignment=Alignment.CENTER,
).run()

Expand Down
10 changes: 3 additions & 7 deletions archinstall/default_profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
from enum import Enum, auto
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation
from archinstall.lib.translationhandler import tr

if TYPE_CHECKING:
from ..lib.installer import Installer

_: Callable[[str], DeferredTranslation]


class ProfileType(Enum):
# top level default_profiles
Expand Down Expand Up @@ -200,7 +196,7 @@ def packages_text(self, include_sub_packages: bool = False) -> str:
if sub_profile.packages:
packages.update(sub_profile.packages)

text = str(_("Installed packages")) + ":\n"
text = tr("Installed packages") + ":\n"

for pkg in sorted(packages):
text += f"\t- {pkg}\n"
Expand Down
12 changes: 3 additions & 9 deletions archinstall/default_profiles/xorg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from typing import TYPE_CHECKING, override
from typing import override

from archinstall.default_profiles.profile import Profile, ProfileType

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation

_: Callable[[str], DeferredTranslation]
from archinstall.lib.translationhandler import tr


class XorgProfile(Profile):
Expand All @@ -26,7 +20,7 @@ def __init__(

@override
def preview_text(self) -> str:
text = str(_("Environment type: {}")).format(self.profile_type.value)
text = tr("Environment type: {}").format(self.profile_type.value)
if packages := self.packages_text():
text += f"\n{packages}"

Expand Down
17 changes: 5 additions & 12 deletions archinstall/lib/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dataclasses import dataclass, field
from importlib.metadata import version
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import Any
from urllib.request import Request, urlopen

from pydantic.dataclasses import dataclass as p_dataclass
Expand All @@ -25,17 +25,10 @@
from archinstall.lib.output import debug, error, warn
from archinstall.lib.plugins import load_plugin
from archinstall.lib.storage import storage
from archinstall.lib.translationhandler import Language, translation_handler
from archinstall.lib.translationhandler import Language, tr, translation_handler
from archinstall.lib.utils.util import get_password
from archinstall.tui.curses_menu import Tui

if TYPE_CHECKING:
from collections.abc import Callable

from archinstall.lib.translationhandler import DeferredTranslation

_: Callable[[str], DeferredTranslation]


@p_dataclass
class Arguments:
Expand Down Expand Up @@ -430,7 +423,7 @@ def _process_creds_data(self, creds_data: str) -> dict[str, Any] | None:
return json.loads(creds_data)
except ValueError as err:
if "Invalid password" in str(err):
error(str(_("Incorrect credentials file decryption password")))
error(tr("Incorrect credentials file decryption password"))
exit(1)
else:
debug(f"Error decrypting credentials file: {err}")
Expand All @@ -440,10 +433,10 @@ def _process_creds_data(self, creds_data: str) -> dict[str, Any] | None:

with Tui():
while True:
header = str(_("Incorrect password")) if incorrect_password else None
header = tr("Incorrect password") if incorrect_password else None

decryption_pwd = get_password(
text=str(_("Credentials file decryption password")),
text=tr("Credentials file decryption password"),
header=header,
allow_skip=False,
skip_confirmation=True,
Expand Down
Loading