Added output of app and user path to textualapp.py

This commit is contained in:
2026-11-21 15:04:01 +01:00
parent 0a3856b091
commit 0e8875e878
4 changed files with 21 additions and 8 deletions
+16 -5
View File
@@ -4,16 +4,18 @@ A textual app to showcase the use of the Ki18n class.
from __future__ import annotations
from pathlib import Path
import pathlib
from textual import work
from textual.app import App, ComposeResult
from textual.widgets import Footer, Header, Log
# set to the real folder where ki18n lives
from ki18n.ki18n import Ki18n, i18n
from ki18n import paths
from ki18n.ki18n import Ki18n, i18n, SystemLocale
from ki18n.help_screen import HelpScreen
from ki18n.language_select_screen import LanguageSelectScreen
from ki18n.paths import bundle_root
class TextualApp(App):
@@ -50,10 +52,19 @@ class TextualApp(App):
self.push_screen(HelpScreen())
def log_all(self) -> None:
locale = i18n.get_locale()
log = self.query_one(Log)
local_path = paths.bundle_root().absolute()
log.write_line(i18n.t("root_path",root=str(local_path)))
dir_name = pathlib.PurePath(local_path).name
log.write_line(i18n.t("user_path",user=str(paths.data_dir(dir_name).absolute())))
log.write_line("\n")
log.write_line(i18n.t("default_and_available"))
# default = i18n.get_default_language()
log.write_line(i18n.t("lang_default", default_language=i18n.get_default_language()))
available = i18n.get_available_languages()
out = "".join(f"{v}, " for v in available.values()).rstrip(', ')
@@ -81,8 +92,8 @@ class TextualApp(App):
if __name__ == "__main__":
manager = Ki18n(
default_language="en",
project_root=Path(__file__).resolve().parent,
# default_language="en",
# project_root=Path(__file__).resolve().parent,
)
app = TextualApp()