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
|
||||
|
||||
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))
|
||||
{
|
||||
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
|
||||
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);
|
||||
|
||||
break;
|
||||
|
|
|
@ -104,7 +104,6 @@ const std::string& shortkey_alt_prefix()
|
|||
bool config_wizard_startup(bool app_config_exists)
|
||||
{
|
||||
if (!app_config_exists || wxGetApp().preset_bundle->printers.size() <= 1) {
|
||||
wxGetApp().switch_language();
|
||||
config_wizard(ConfigWizard::RR_DATA_EMPTY);
|
||||
return true;
|
||||
} else if (get_app_config()->legacy_datadir()) {
|
||||
|
|
|
@ -579,33 +579,47 @@ bool GUI_App::select_language()
|
|||
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()
|
||||
{
|
||||
wxString language = wxEmptyString;
|
||||
if (app_config->has("translation_language"))
|
||||
language = app_config->get("translation_language");
|
||||
|
||||
if (language.IsEmpty())
|
||||
return false;
|
||||
|
||||
const auto langs = get_installed_languages();
|
||||
for (const wxLanguageInfo *info : langs)
|
||||
{
|
||||
if (info->CanonicalName == language)
|
||||
{
|
||||
m_wxLocale = new wxLocale;
|
||||
m_wxLocale->Init(info->Language);
|
||||
m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir()));
|
||||
m_wxLocale->AddCatalog("Slic3rPE");
|
||||
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
||||
wxSetlocale(LC_NUMERIC, "C");
|
||||
Preset::update_suffix_modified();
|
||||
m_imgui->set_language(into_u8(info->CanonicalName));
|
||||
return true;
|
||||
if (language.IsEmpty()) {
|
||||
int lang = wxLocale::GetSystemLanguage();
|
||||
if (lang != wxLANGUAGE_UNKNOWN) {
|
||||
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
|
||||
if (info != nullptr)
|
||||
language = info->CanonicalName;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
const wxLanguageInfo *info = nullptr;
|
||||
if (! language.IsEmpty()) {
|
||||
const auto langs = get_installed_languages();
|
||||
for (const wxLanguageInfo *this_info : langs)
|
||||
if (this_info->CanonicalName == language) {
|
||||
info = this_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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->AddCatalogLookupPathPrefix(from_u8(localization_dir()));
|
||||
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.
|
||||
wxSetlocale(LC_NUMERIC, "C");
|
||||
Preset::update_suffix_modified();
|
||||
return true;
|
||||
}
|
||||
|
||||
// save language at application config
|
||||
|
|
|
@ -19,7 +19,7 @@ class wxMenuItem;
|
|||
class wxMenuBar;
|
||||
class wxTopLevelWindow;
|
||||
class wxNotebook;
|
||||
class wxLanguageInfo;
|
||||
struct wxLanguageInfo;
|
||||
|
||||
namespace Slic3r {
|
||||
class AppConfig;
|
||||
|
@ -126,10 +126,9 @@ public:
|
|||
void update_ui_from_settings();
|
||||
|
||||
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();
|
||||
void save_language();
|
||||
std::vector<const wxLanguageInfo*> get_installed_languages();
|
||||
|
||||
Tab* get_tab(Preset::Type type);
|
||||
ConfigOptionMode get_mode();
|
||||
|
@ -177,8 +176,11 @@ private:
|
|||
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_sanitize(wxTopLevelWindow* window);
|
||||
bool select_language();
|
||||
void save_language();
|
||||
std::vector<const wxLanguageInfo*> get_installed_languages();
|
||||
#ifdef __WXMSW__
|
||||
void associate_3mf_files();
|
||||
void associate_3mf_files();
|
||||
#endif // __WXMSW__
|
||||
};
|
||||
DECLARE_APP(GUI_App)
|
||||
|
|
|
@ -554,10 +554,10 @@ void MainFrame::init_menubar()
|
|||
//# $versioncheck->Enable(wxTheApp->have_version_check);
|
||||
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),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://slic3r.org/"); });
|
||||
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),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://manual.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),
|
||||
// wxString::Format(_(L("Open the %s manual in your browser")), SLIC3R_APP_NAME),
|
||||
// [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://manual.slic3r.org/"); });
|
||||
helpMenu->AppendSeparator();
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L("System &Info")), _(L("Show system information")),
|
||||
[this](wxCommandEvent&) { wxGetApp().system_info(); });
|
||||
|
|
Loading…
Reference in a new issue