From 0dc14aa87635c81818c993e23c2315ee626f43d0 Mon Sep 17 00:00:00 2001 From: Ru Date: Tue, 28 Jul 2026 23:11:05 +0300 Subject: [PATCH] feat(plugin): expose orca.host.app_language() for plugin localization Plugins have no way to localize their own dialogs: the UI language lives in OrcaSlicer.conf, which the plugin audit hook deny-lists because the file sits next to cloud secrets. Add a read-only host accessor that returns just the language code (current_language_code_safe), so plugins can match the app language without touching the config file. --- src/slic3r/plugin/host/PluginHostApp.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/slic3r/plugin/host/PluginHostApp.cpp b/src/slic3r/plugin/host/PluginHostApp.cpp index a17f160bb7..75acd4cc7b 100644 --- a/src/slic3r/plugin/host/PluginHostApp.cpp +++ b/src/slic3r/plugin/host/PluginHostApp.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -55,6 +56,15 @@ void host_bindings::register_app(py::module_& host) return current_plater()->model(); }, py::return_value_policy::reference); host.def("preset_bundle", ¤t_preset_bundle, py::return_value_policy::reference); + // UI language of the running app ("en_US", "ru_RU", ...), so plugins can + // localize their own dialogs. The app config file that stores this value + // is deny-listed by the audit hook (it sits next to cloud secrets), so a + // read-only accessor is the supported way to get just the language. + host.def("app_language", []() -> std::string { + if (wxTheApp == nullptr) + throw std::runtime_error("OrcaSlicer application is not initialized"); + return GUI::into_u8(GUI::wxGetApp().current_language_code_safe()); + }); } } // namespace Slic3r