statable 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codegen/__init__.py +38 -0
- codegen/c_code_generator.py +1752 -0
- codegen/code_merger.py +371 -0
- codegen/code_templates.py +509 -0
- codegen/config.py +167 -0
- codegen/enum_generator.py +377 -0
- codegen/event_queue_generator.py +303 -0
- codegen/interrupt_generator.py +345 -0
- codegen/naming_convention.py +171 -0
- codegen/osal_generator.py +282 -0
- codegen/role_function_generator.py +1244 -0
- codegen/sample_data.py +269 -0
- codegen/state_actions_generator.py +395 -0
- codegen/struct_generator.py +721 -0
- codegen/timer_generator.py +299 -0
- codegen/transition_generator.py +907 -0
- codegen/type_mapper.py +69 -0
- codegen/validate/__init__.py +38 -0
- codegen/validate/change_actions.py +90 -0
- codegen/validate/change_applier.py +416 -0
- codegen/validate/clipboard_manager.py +47 -0
- codegen/validate/data/__init__.py +30 -0
- codegen/validate/data/action_definitions.py +200 -0
- codegen/validate/data/keywords.py +46 -0
- codegen/validate/data/prompt_templates.py +176 -0
- codegen/validate/data/validation_rules.py +205 -0
- codegen/validate/items/__init__.py +30 -0
- codegen/validate/items/base_validator.py +25 -0
- codegen/validate/items/cell_validator.py +275 -0
- codegen/validate/items/custom_type_validator.py +75 -0
- codegen/validate/items/event_validator.py +78 -0
- codegen/validate/items/flag_validator.py +74 -0
- codegen/validate/items/interrupt_validator.py +75 -0
- codegen/validate/items/queue_validator.py +73 -0
- codegen/validate/items/role_function_validator.py +175 -0
- codegen/validate/items/state_validator.py +88 -0
- codegen/validate/items/timer_validator.py +120 -0
- codegen/validate/items/transition_validator.py +113 -0
- codegen/validate/items/variable_validator.py +132 -0
- codegen/validate/logger.py +52 -0
- codegen/validate/models.py +177 -0
- codegen/validate/prompt_generator.py +724 -0
- codegen/validate/response_parser.py +154 -0
- codegen/validate/response_validator.py +275 -0
- codegen/validate/validation_dialog.py +322 -0
- codegen/validate/validator.py +94 -0
- codegen/variable_generator.py +419 -0
- statable/__init__.py +71 -0
- statable/__main__.py +49 -0
- statable/cli.py +251 -0
- statable/global_defs.py +256 -0
- statable/mermaid_gen.py +144 -0
- statable/model.py +426 -0
- statable/parser.py +64 -0
- statable/sample_data.py +435 -0
- statable/shared/__init__.py +24 -0
- statable/shared/condition_library.py +63 -0
- statable/shared/literal_library.py +66 -0
- statable/shared/role_function_library.py +150 -0
- statable/state_machine.py +121 -0
- statable/xml_io.py +1164 -0
- statable-3.1.0.dist-info/METADATA +151 -0
- statable-3.1.0.dist-info/RECORD +117 -0
- statable-3.1.0.dist-info/WHEEL +5 -0
- statable-3.1.0.dist-info/entry_points.txt +2 -0
- statable-3.1.0.dist-info/top_level.txt +3 -0
- statable_gui/__init__.py +23 -0
- statable_gui/action_edit_dialog.py +214 -0
- statable_gui/code_generation_dialog.py +486 -0
- statable_gui/code_generation_settings_dialog.py +522 -0
- statable_gui/common_widgets.py +537 -0
- statable_gui/condition_builder_dialog.py +500 -0
- statable_gui/condition_edit_dialog.py +123 -0
- statable_gui/condition_template_dialog.py +58 -0
- statable_gui/config.py +21 -0
- statable_gui/dialogs.py +439 -0
- statable_gui/event_definition_dialog.py +605 -0
- statable_gui/event_delivery_settings_dialog.py +191 -0
- statable_gui/event_queue_dialog.py +245 -0
- statable_gui/global_defs.py +167 -0
- statable_gui/global_defs_dialog.py +796 -0
- statable_gui/i18n/__init__.py +118 -0
- statable_gui/interrupt_handler_edit_dialog.py +810 -0
- statable_gui/layer_settings_dialog.py +180 -0
- statable_gui/libcntrl/__init__.py +23 -0
- statable_gui/libcntrl/condition_library.py +13 -0
- statable_gui/libcntrl/literal_library.py +13 -0
- statable_gui/libcntrl/literal_management_dialog.py +185 -0
- statable_gui/libcntrl/role_function_edit_dialog.py +145 -0
- statable_gui/libcntrl/role_function_library.py +13 -0
- statable_gui/literal_definition_dialog.py +62 -0
- statable_gui/logger.py +83 -0
- statable_gui/main_window.py +1380 -0
- statable_gui/matrix_table.py +413 -0
- statable_gui/preference_keys.py +18 -0
- statable_gui/preferences.py +74 -0
- statable_gui/role_function_dialog.py +244 -0
- statable_gui/sample_data.py +11 -0
- statable_gui/state_actions_dialog.py +398 -0
- statable_gui/symbol_picker.py +170 -0
- statable_gui/traceball.py +37 -0
- statable_gui/transition_editor_direct/__init__.py +15 -0
- statable_gui/transition_editor_direct/actions_tab.py +856 -0
- statable_gui/transition_editor_direct/code_widget.py +344 -0
- statable_gui/transition_editor_direct/coverage_analyzer.py +163 -0
- statable_gui/transition_editor_direct/dialog.py +335 -0
- statable_gui/transition_editor_direct/draft.py +270 -0
- statable_gui/transition_editor_direct/edit_dialogs.py +160 -0
- statable_gui/transition_editor_direct/overview_tab.py +173 -0
- statable_gui/transition_editor_direct/palette_widget.py +233 -0
- statable_gui/transition_editor_direct/relations_edit_dialog.py +156 -0
- statable_gui/transition_editor_direct/relations_tab.py +230 -0
- statable_gui/transition_editor_direct/system_global_dialog.py +52 -0
- statable_gui/transition_editor_direct/transition_actions_dialog.py +109 -0
- statable_gui/transition_editor_direct/transitions_tab.py +620 -0
- statable_gui/validation_dialog.py +285 -0
- statable_gui/widgets.py +1315 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# statable_gui/i18n/__init__.py
|
|
2
|
+
"""Internationalization support for StaTable GUI.
|
|
3
|
+
|
|
4
|
+
Loads .qm translation files from this directory.
|
|
5
|
+
|
|
6
|
+
Supported languages:
|
|
7
|
+
en - English (default, no translation file needed)
|
|
8
|
+
ja - Japanese
|
|
9
|
+
zh_CN - Chinese (Simplified)
|
|
10
|
+
|
|
11
|
+
Usage in gui_main.py or statable_gui/main_window.py:
|
|
12
|
+
from statable_gui.i18n import install_translator
|
|
13
|
+
install_translator(app)
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Optional
|
|
19
|
+
|
|
20
|
+
from PySide6.QtCore import (
|
|
21
|
+
QTranslator,
|
|
22
|
+
QLocale,
|
|
23
|
+
QSettings,
|
|
24
|
+
QLibraryInfo,
|
|
25
|
+
)
|
|
26
|
+
from PySide6.QtWidgets import QApplication
|
|
27
|
+
|
|
28
|
+
I18N_DIR = Path(__file__).parent
|
|
29
|
+
DEFAULT_LANG = "en"
|
|
30
|
+
SUPPORTED_LANGUAGES = ["en", "zh_CN"]
|
|
31
|
+
LANG_DISPLAY = {
|
|
32
|
+
"en": "English",
|
|
33
|
+
"zh_CN": "\u7b80\u4f53\u4e2d\u6587",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def available_languages() -> list[str]:
|
|
38
|
+
"""Return list of supported language codes."""
|
|
39
|
+
return list(SUPPORTED_LANGUAGES)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _qm_path(lang: str) -> Path:
|
|
43
|
+
return I18N_DIR / f"statable_{lang}.qm"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def detect_system_language() -> str:
|
|
47
|
+
"""Return best-matching language for the current system locale."""
|
|
48
|
+
sys_lang = QLocale.system().name() # e.g. "ja_JP", "zh_CN"
|
|
49
|
+
for lang in SUPPORTED_LANGUAGES:
|
|
50
|
+
if lang == DEFAULT_LANG:
|
|
51
|
+
continue
|
|
52
|
+
short = lang.split("_")[0]
|
|
53
|
+
if sys_lang.startswith(lang) or sys_lang.startswith(short):
|
|
54
|
+
return lang
|
|
55
|
+
return DEFAULT_LANG
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def load_preferred_language() -> str:
|
|
59
|
+
"""Load user preference from QSettings, fallback to system."""
|
|
60
|
+
settings = QSettings("StaTable", "StaTable")
|
|
61
|
+
lang = settings.value("ui/language", "")
|
|
62
|
+
if lang and lang in SUPPORTED_LANGUAGES:
|
|
63
|
+
return lang
|
|
64
|
+
return detect_system_language()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def save_preferred_language(lang: str) -> None:
|
|
68
|
+
"""Persist user preference."""
|
|
69
|
+
if lang not in SUPPORTED_LANGUAGES:
|
|
70
|
+
return
|
|
71
|
+
settings = QSettings("StaTable", "StaTable")
|
|
72
|
+
settings.setValue("ui/language", lang)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def install_translator(app: QApplication,
|
|
76
|
+
lang: Optional[str] = None) -> Optional[QTranslator]:
|
|
77
|
+
"""Install translator for the given language.
|
|
78
|
+
|
|
79
|
+
Returns the installed QTranslator (kept alive by reference on app),
|
|
80
|
+
or None if no translation file was loaded (e.g. English).
|
|
81
|
+
"""
|
|
82
|
+
if lang is None:
|
|
83
|
+
lang = load_preferred_language()
|
|
84
|
+
if lang not in SUPPORTED_LANGUAGES or lang == DEFAULT_LANG:
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
qm = _qm_path(lang)
|
|
88
|
+
if not qm.exists():
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
translator = QTranslator()
|
|
92
|
+
if not translator.load(str(qm)):
|
|
93
|
+
return None
|
|
94
|
+
app.installTranslator(translator)
|
|
95
|
+
|
|
96
|
+
# Install Qt's own translations for built-in dialogs
|
|
97
|
+
qt_tr = QTranslator()
|
|
98
|
+
qt_path = QLibraryInfo.path(QLibraryInfo.TranslationsPath)
|
|
99
|
+
if qt_tr.load(f"qtbase_{lang}", qt_path):
|
|
100
|
+
app.installTranslator(qt_tr)
|
|
101
|
+
# keep reference alive
|
|
102
|
+
translator._qt_translator = qt_tr # noqa: SLF001
|
|
103
|
+
|
|
104
|
+
# keep reference so Python doesn't GC it
|
|
105
|
+
app._statable_translator = translator # noqa: SLF001
|
|
106
|
+
return translator
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
__all__ = [
|
|
110
|
+
"install_translator",
|
|
111
|
+
"available_languages",
|
|
112
|
+
"detect_system_language",
|
|
113
|
+
"load_preferred_language",
|
|
114
|
+
"save_preferred_language",
|
|
115
|
+
"DEFAULT_LANG",
|
|
116
|
+
"SUPPORTED_LANGUAGES",
|
|
117
|
+
"LANG_DISPLAY",
|
|
118
|
+
]
|