mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-10-08 06:26:39 +00:00
i18n(oci): refine Slovak manager wording
This commit is contained in:
@@ -8,7 +8,7 @@ import sys
|
||||
import textwrap
|
||||
import threading
|
||||
|
||||
from .i18n import BASE_DIR
|
||||
from .i18n import BASE_DIR, translate
|
||||
|
||||
MG = "\033[1;35m"
|
||||
GN = "\033[1;92m"
|
||||
@@ -101,6 +101,7 @@ def ask_yes_no(text: str, default_yes: bool = True) -> bool:
|
||||
width = 74
|
||||
lines = sum(max(1, len(textwrap.wrap(line, width - 6) or [''])) for line in text.splitlines() or [''])
|
||||
widget = ['whiptail', '--backtitle', 'ProxMenux', '--title', 'ProxMenux',
|
||||
'--yes-button', translate('Yes'), '--no-button', translate('No'),
|
||||
'--yesno', text, str(min(lines + 8, 20)), str(width)]
|
||||
if not default_yes:
|
||||
widget.insert(1, '--defaultno')
|
||||
|
||||
@@ -192,9 +192,10 @@ class DialogUI:
|
||||
# dialog draws on the terminal and writes the selection to stderr.
|
||||
back_widget = ['--extra-button', '--extra-label', translate('Back')] if self.back_enabled and any(
|
||||
flag in widget for flag in ('--inputbox', '--passwordbox', '--yesno', '--menu', '--checklist')) else []
|
||||
confirmation_labels = ['--yes-label', translate('Yes'), '--no-label', translate('No')] if '--yesno' in widget else []
|
||||
result = subprocess.run(
|
||||
["dialog", "--no-collapse", "--cancel-label", translate('Cancel'), "--backtitle", self.backtitle, "--title", title or self.title,
|
||||
*back_widget, *widget],
|
||||
*confirmation_labels, *back_widget, *widget],
|
||||
stdout=None, stderr=subprocess.PIPE, text=True, check=False, env=environment,
|
||||
)
|
||||
if result.returncode == 3 and back_widget:
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
"""OCI confirmation buttons use the active language catalog."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
from subprocess import CompletedProcess
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "src"))
|
||||
|
||||
from proxmenux_oci import console
|
||||
from proxmenux_oci.ui import DialogUI
|
||||
|
||||
|
||||
def slovak(text: str) -> str:
|
||||
return {"Yes": "Áno", "No": "Nie", "Cancel": "Zrušiť"}.get(text, text)
|
||||
|
||||
|
||||
class ConfirmationLabelTests(unittest.TestCase):
|
||||
def test_dialog_confirmation_uses_translated_yes_and_no_labels(self):
|
||||
with patch("proxmenux_oci.ui.translate", side_effect=slovak):
|
||||
with patch("proxmenux_oci.ui.subprocess.run", return_value=CompletedProcess([], 0, "", "")) as run:
|
||||
DialogUI().confirm("Continue?")
|
||||
command = run.call_args.args[0]
|
||||
self.assertEqual(command[command.index("--yes-label") + 1], "Áno")
|
||||
self.assertEqual(command[command.index("--no-label") + 1], "Nie")
|
||||
|
||||
def test_console_confirmation_uses_translated_yes_and_no_labels(self):
|
||||
with patch("proxmenux_oci.console.translate", side_effect=slovak):
|
||||
with patch("proxmenux_oci.console.shutil.which", return_value="/usr/bin/whiptail"):
|
||||
with patch("proxmenux_oci.console.subprocess.run", return_value=CompletedProcess([], 0)) as run:
|
||||
self.assertTrue(console.ask_yes_no("Continue?"))
|
||||
command = run.call_args.args[0]
|
||||
self.assertEqual(command[command.index("--yes-button") + 1], "Áno")
|
||||
self.assertEqual(command[command.index("--no-button") + 1], "Nie")
|
||||
@@ -0,0 +1,22 @@
|
||||
"""Regression checks for the Slovak wording in the OCI Manager journey."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SLOVAK = ROOT / "lang" / "sk.json"
|
||||
|
||||
|
||||
class SlovakOCIWordingTests(unittest.TestCase):
|
||||
def test_wizard_and_removal_copy_is_clear(self):
|
||||
text = json.loads(SLOVAK.read_text(encoding="utf-8"))
|
||||
self.assertEqual(text["Start with Proxmox"], "Spúšťať spolu so spustením Proxmoxu")
|
||||
self.assertEqual(text["Start"], "Spustenie")
|
||||
self.assertEqual(text["Starting"], "Spúšťanie")
|
||||
self.assertEqual(text["Containers that are removed:"], "Kontajnery, ktoré sa odstránia:")
|
||||
self.assertEqual(text["The application was removed"], "Aplikácia bola odstránená")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user