Load preferred language from settings

master
Ari Breitkreuz 6 years ago committed by Fabian Keßler
parent 6fa6d3c98e
commit debc454ca5
  1. 4
      src/control/Control.cpp
  2. 5
      src/control/Control.h
  3. 2
      src/control/settings/Settings.cpp
  4. 16
      src/control/settings/Settings.h

@ -88,6 +88,8 @@ Control::Control(GladeSearchpath* gladeSearchPath) {
this->settings = new Settings(std::move(name));
this->settings->load();
this->applyPreferredLanguage();
TextView::setDpi(settings->getDisplayDpi());
this->pageTypes = new PageTypeHandler(gladeSearchPath);
@ -2458,6 +2460,8 @@ void Control::closeDocument() {
this->undoRedoChanged();
}
void Control::applyPreferredLanguage() { setenv("LANGUAGE", this->settings->getPreferredLocale().c_str(), 1); }
auto Control::askToReplace(fs::path const& filepath) const -> bool {
if (fs::exists(filepath)) {
string msg = FS(FORMAT_STR("The file {1} already exists! Do you want to replace it?") %

@ -326,6 +326,11 @@ private:
*/
void closeDocument();
/**
* Applies the preferred language to the UI
*/
void applyPreferredLanguage();
RecentManager* recent;
UndoRedoHandler* undoRedo;
ZoomControl* zoom;

@ -845,6 +845,8 @@ void Settings::save() {
WRITE_BOOL_PROP(inputSystemTPCButton);
WRITE_BOOL_PROP(inputSystemDrawOutsideWindow);
WRITE_STRING_PROP(preferredLocale);
WRITE_BOOL_PROP(latexSettings.autoCheckDependencies);
// Inline WRITE_STRING_PROP(latexSettings.globalTemplatePath) since it
// breaks on Windows due to the native character representation being

@ -431,7 +431,6 @@ public:
*/
bool getTrySelectOnStrokeFiltered() const;
/**
* Set snap recognized shapes enabled
*/
@ -452,6 +451,16 @@ public:
*/
bool getRestoreLineWidthEnabled() const;
/**
* Set the preferred locale
*/
void setPreferredLocale(std::string const& locale) const;
/**
* Get the preferred locale
*/
std::string getPreferredLocale() const {
return "de_DE.UTF-8"; }
public:
// Custom settings
@ -882,4 +891,9 @@ private:
* "Transaction" running, do not save until the end is reached
*/
bool inTransaction{};
/** The preferred locale as its language code
* e.g. "en_US"
*/
std::string preferredLocale;
};

Loading…
Cancel
Save