X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fi18n_hook.cc;h=f6b9636227f4a33196cc7453c87708ce27a23674;hb=689fa55d1529ad88449ca464e9107c4dcc54d1cb;hp=bb185526e8c0e99db25f12e73870de35842e0e77;hpb=9c1bb2e5ca7c80c4e26b1b2e41159aa171360a94;p=dcpomatic.git diff --git a/src/wx/i18n_hook.cc b/src/wx/i18n_hook.cc index bb185526e..f6b963622 100644 --- a/src/wx/i18n_hook.cc +++ b/src/wx/i18n_hook.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,39 +18,49 @@ */ + #include "i18n_hook.h" #include "instant_i18n_dialog.h" #include "wx_util.h" #include "lib/cross.h" #include -#include -#include +#include + + +using std::map; +using std::string; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif -I18NHook::I18NHook (wxWindow* window) + +map I18NHook::_translations; + +I18NHook::I18NHook (wxWindow* window, wxString original) : _window (window) + , _original (original) { _window->Bind (wxEVT_MIDDLE_DOWN, bind(&I18NHook::handle, this, _1)); } + void I18NHook::handle (wxMouseEvent& ev) { - wxString const original = get_text (); - - InstantI18NDialog* d = new InstantI18NDialog (_window, get_text()); + auto d = new InstantI18NDialog (_window, get_text()); d->ShowModal(); set_text (d->get()); - _window->GetContainingSizer()->Layout(); - ev.Skip (); - - boost::filesystem::path file = "instant_i18n"; + d->Destroy (); - FILE* f = fopen_boost (file, "a"); - if (!f) { - error_dialog (_window, wxString::Format(_("Could not open translation file %s"), std_to_wx(file.string()).data())); - return; + auto w = _window; + while (w) { + if (w->GetContainingSizer()) { + w->GetContainingSizer()->Layout(); + } + w = w->GetParent(); } - fprintf (f, "%s\n", wx_to_std(original).c_str()); - fprintf (f, "%s\n", wx_to_std(get_text()).c_str()); - fclose (f); + + ev.Skip (); + + _translations[wx_to_std(_original)] = wx_to_std(get_text()); }