mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-13 10:51:12 +00:00
Translate the web dialogs and pages through the .po catalogs (#16363)
This commit is contained in:
@@ -84,9 +84,8 @@ void focus_webview(wxWebView* browser, bool page_ready)
|
||||
browser->RunScript("focusInput();");
|
||||
}
|
||||
|
||||
// Localized strings for the Speed Dial page, injected as a document-start user script. The page's
|
||||
// T() reads window.ORCA_UI_STRINGS, so these flow through the same .po pipeline as the rest of the
|
||||
// UI (the JS literals are only a fallback before the script runs / in the node vm test).
|
||||
// Localized strings for the Speed Dial page (see WebViewHostDialog::localized_strings). The page's own T()
|
||||
// reads them; its JS literals are only a fallback before the script runs / in the node vm test.
|
||||
// %% is a literal '%': T() collapses it after substituting %s. Keep the shortcut tokens out of the
|
||||
// translated text so the platform prefix (Alt+/⌥+, Ctrl+/⌘+) stays correct.
|
||||
nlohmann::json speed_dial_ui_strings()
|
||||
@@ -175,17 +174,7 @@ SpeedDialWebDialog::SpeedDialWebDialog(wxWindow* parent)
|
||||
|
||||
SpeedDialWebDialog::~SpeedDialWebDialog() { m_alive->store(false, std::memory_order_release); }
|
||||
|
||||
// Document-start hook: hand the page its translated strings before speeddial.js runs, so the first
|
||||
// paint is already localized. The table is built when the dialog is created; a live language switch
|
||||
// rebuilds the GUI (and with it this dialog), so the next open re-injects the new locale.
|
||||
void SpeedDialWebDialog::add_user_scripts()
|
||||
{
|
||||
if (wxWebView* wv = browser()) {
|
||||
const std::string js = "window.ORCA_UI_STRINGS = " +
|
||||
speed_dial_ui_strings().dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore) + ";";
|
||||
wv->AddUserScript(wxString::FromUTF8(js));
|
||||
}
|
||||
}
|
||||
nlohmann::json SpeedDialWebDialog::localized_strings() const { return speed_dial_ui_strings(); }
|
||||
|
||||
void SpeedDialWebDialog::request_show()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user