Application will pick translation dictionaries based on the system default language
on first start of Slic3r. Updated help menu (removed reference to the upstream manual) Fixed some OpenGL assert due to glOrtho being called with zero Z span.
This commit is contained in:
parent
1d788f9ce9
commit
ed8430bc9b
6 changed files with 47 additions and 31 deletions
|
@ -1062,7 +1062,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
||||||
// Public
|
// Public
|
||||||
|
|
||||||
ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
||||||
: DPIDialog(parent, wxID_ANY, _(name().ToStdString()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
: DPIDialog(parent, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(name().ToStdString()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
, p(new priv(this))
|
, p(new priv(this))
|
||||||
{
|
{
|
||||||
this->SetFont(wxGetApp().normal_font());
|
this->SetFont(wxGetApp().normal_font());
|
||||||
|
|
|
@ -3612,7 +3612,8 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: calculate a tighter value for depth will improve z-fighting
|
// FIXME: calculate a tighter value for depth will improve z-fighting
|
||||||
float depth = 5.0f * (float)bbox.max_size();
|
// Set at least some minimum depth in case the bounding box is empty to avoid an OpenGL driver error.
|
||||||
|
float depth = std::max(1.f, 5.0f * (float)bbox.max_size());
|
||||||
m_camera.apply_ortho_projection(-w2, w2, -h2, h2, -depth, depth);
|
m_camera.apply_ortho_projection(-w2, w2, -h2, h2, -depth, depth);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -104,7 +104,6 @@ const std::string& shortkey_alt_prefix()
|
||||||
bool config_wizard_startup(bool app_config_exists)
|
bool config_wizard_startup(bool app_config_exists)
|
||||||
{
|
{
|
||||||
if (!app_config_exists || wxGetApp().preset_bundle->printers.size() <= 1) {
|
if (!app_config_exists || wxGetApp().preset_bundle->printers.size() <= 1) {
|
||||||
wxGetApp().switch_language();
|
|
||||||
config_wizard(ConfigWizard::RR_DATA_EMPTY);
|
config_wizard(ConfigWizard::RR_DATA_EMPTY);
|
||||||
return true;
|
return true;
|
||||||
} else if (get_app_config()->legacy_datadir()) {
|
} else if (get_app_config()->legacy_datadir()) {
|
||||||
|
|
|
@ -579,34 +579,48 @@ bool GUI_App::select_language()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load language saved at application config
|
// Load gettext translation files and activate them at the start of the application,
|
||||||
|
// based on the "translation_language" key stored in the application config.
|
||||||
bool GUI_App::load_language()
|
bool GUI_App::load_language()
|
||||||
{
|
{
|
||||||
wxString language = wxEmptyString;
|
wxString language = wxEmptyString;
|
||||||
if (app_config->has("translation_language"))
|
if (app_config->has("translation_language"))
|
||||||
language = app_config->get("translation_language");
|
language = app_config->get("translation_language");
|
||||||
|
|
||||||
if (language.IsEmpty())
|
if (language.IsEmpty()) {
|
||||||
return false;
|
int lang = wxLocale::GetSystemLanguage();
|
||||||
|
if (lang != wxLANGUAGE_UNKNOWN) {
|
||||||
|
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
|
||||||
|
if (info != nullptr)
|
||||||
|
language = info->CanonicalName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxLanguageInfo *info = nullptr;
|
||||||
|
if (! language.IsEmpty()) {
|
||||||
const auto langs = get_installed_languages();
|
const auto langs = get_installed_languages();
|
||||||
for (const wxLanguageInfo *info : langs)
|
for (const wxLanguageInfo *this_info : langs)
|
||||||
{
|
if (this_info->CanonicalName == language) {
|
||||||
if (info->CanonicalName == language)
|
info = this_info;
|
||||||
{
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_wxLocale = new wxLocale;
|
m_wxLocale = new wxLocale;
|
||||||
|
if (info == nullptr) {
|
||||||
|
m_wxLocale->Init(wxLANGUAGE_DEFAULT);
|
||||||
|
m_imgui->set_language("en");
|
||||||
|
} else {
|
||||||
m_wxLocale->Init(info->Language);
|
m_wxLocale->Init(info->Language);
|
||||||
m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir()));
|
m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir()));
|
||||||
m_wxLocale->AddCatalog("Slic3rPE");
|
m_wxLocale->AddCatalog("Slic3rPE");
|
||||||
|
m_imgui->set_language(into_u8(info->CanonicalName));
|
||||||
|
}
|
||||||
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
||||||
wxSetlocale(LC_NUMERIC, "C");
|
wxSetlocale(LC_NUMERIC, "C");
|
||||||
Preset::update_suffix_modified();
|
Preset::update_suffix_modified();
|
||||||
m_imgui->set_language(into_u8(info->CanonicalName));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save language at application config
|
// save language at application config
|
||||||
void GUI_App::save_language()
|
void GUI_App::save_language()
|
||||||
|
|
|
@ -19,7 +19,7 @@ class wxMenuItem;
|
||||||
class wxMenuBar;
|
class wxMenuBar;
|
||||||
class wxTopLevelWindow;
|
class wxTopLevelWindow;
|
||||||
class wxNotebook;
|
class wxNotebook;
|
||||||
class wxLanguageInfo;
|
struct wxLanguageInfo;
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
class AppConfig;
|
class AppConfig;
|
||||||
|
@ -126,10 +126,9 @@ public:
|
||||||
void update_ui_from_settings();
|
void update_ui_from_settings();
|
||||||
|
|
||||||
bool switch_language();
|
bool switch_language();
|
||||||
bool select_language();
|
// Load gettext translation files and activate them at the start of the application,
|
||||||
|
// based on the "translation_language" key stored in the application config.
|
||||||
bool load_language();
|
bool load_language();
|
||||||
void save_language();
|
|
||||||
std::vector<const wxLanguageInfo*> get_installed_languages();
|
|
||||||
|
|
||||||
Tab* get_tab(Preset::Type type);
|
Tab* get_tab(Preset::Type type);
|
||||||
ConfigOptionMode get_mode();
|
ConfigOptionMode get_mode();
|
||||||
|
@ -177,6 +176,9 @@ private:
|
||||||
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
||||||
void window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
|
void window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
|
||||||
void window_pos_sanitize(wxTopLevelWindow* window);
|
void window_pos_sanitize(wxTopLevelWindow* window);
|
||||||
|
bool select_language();
|
||||||
|
void save_language();
|
||||||
|
std::vector<const wxLanguageInfo*> get_installed_languages();
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
void associate_3mf_files();
|
void associate_3mf_files();
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
|
|
|
@ -554,10 +554,10 @@ void MainFrame::init_menubar()
|
||||||
//# $versioncheck->Enable(wxTheApp->have_version_check);
|
//# $versioncheck->Enable(wxTheApp->have_version_check);
|
||||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Website")), SLIC3R_APP_NAME),
|
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Website")), SLIC3R_APP_NAME),
|
||||||
wxString::Format(_(L("Open the %s website in your browser")), SLIC3R_APP_NAME),
|
wxString::Format(_(L("Open the %s website in your browser")), SLIC3R_APP_NAME),
|
||||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://slic3r.org/"); });
|
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("https://www.prusa3d.com/slic3r-prusa-edition/"); });
|
||||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Manual")), SLIC3R_APP_NAME),
|
// append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("%s &Manual")), SLIC3R_APP_NAME),
|
||||||
wxString::Format(_(L("Open the %s manual in your browser")), SLIC3R_APP_NAME),
|
// wxString::Format(_(L("Open the %s manual in your browser")), SLIC3R_APP_NAME),
|
||||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://manual.slic3r.org/"); });
|
// [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://manual.slic3r.org/"); });
|
||||||
helpMenu->AppendSeparator();
|
helpMenu->AppendSeparator();
|
||||||
append_menu_item(helpMenu, wxID_ANY, _(L("System &Info")), _(L("Show system information")),
|
append_menu_item(helpMenu, wxID_ANY, _(L("System &Info")), _(L("Show system information")),
|
||||||
[this](wxCommandEvent&) { wxGetApp().system_info(); });
|
[this](wxCommandEvent&) { wxGetApp().system_info(); });
|
||||||
|
|
Loading…
Reference in a new issue