99#include < libnick/system/environment.h>
1010#include " models/configuration.h"
1111
12+ #define CONFIG_FILE_KEY " config"
13+
1214using namespace Nickvision ::App;
1315using namespace Nickvision ::Application::Shared::Models;
1416using namespace Nickvision ::Events;
1517using namespace Nickvision ::Filesystem;
18+ using namespace Nickvision ::Localization;
1619using namespace Nickvision ::Notifications;
1720using namespace Nickvision ::System;
1821using namespace Nickvision ::Update;
@@ -44,15 +47,20 @@ namespace Nickvision::Application::Shared::Controllers
4447 m_appInfo.getDesigners ()[" DaPigGuy" ] = " https://github.com/DaPigGuy" ;
4548 m_appInfo.getArtists ()[_ (" David Lapshin" )] = " https://github.com/daudix" ;
4649 m_appInfo.setTranslatorCredits (_ (" translator-credits" ));
47- Localization::Gettext::init (m_appInfo.getEnglishShortName ());
50+ Gettext::init (m_appInfo.getEnglishShortName ());
51+ std::string translationLanguage{ m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY).getTranslationLanguage () };
52+ if (!translationLanguage.empty ())
53+ {
54+ Gettext::changeLanguage (translationLanguage);
55+ }
4856#ifdef _WIN32
4957 m_updater = std::make_shared<Updater>(m_appInfo.getSourceRepo ());
5058#endif
5159 }
5260
5361 Event<EventArgs>& MainWindowController::configurationSaved ()
5462 {
55- return m_dataFileManager.get <Configuration>(" config " ).saved ();
63+ return m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY ).saved ();
5664 }
5765
5866 Event<NotificationSentEventArgs>& MainWindowController::notificationSent ()
@@ -67,7 +75,7 @@ namespace Nickvision::Application::Shared::Controllers
6775
6876 Theme MainWindowController::getTheme ()
6977 {
70- return m_dataFileManager.get <Configuration>(" config " ).getTheme ();
78+ return m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY ).getTheme ();
7179 }
7280
7381 std::string MainWindowController::getDebugInformation (const std::string& extraInformation) const
@@ -91,7 +99,7 @@ namespace Nickvision::Application::Shared::Controllers
9199
92100 std::shared_ptr<PreferencesViewController> MainWindowController::createPreferencesViewController ()
93101 {
94- return std::make_shared<PreferencesViewController>(m_dataFileManager.get <Configuration>(" config " ));
102+ return std::make_shared<PreferencesViewController>(m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY ));
95103 }
96104
97105#ifdef _WIN32
@@ -108,11 +116,11 @@ namespace Nickvision::Application::Shared::Controllers
108116 return info;
109117 }
110118 // Load configuration
111- info.setWindowGeometry (m_dataFileManager.get <Configuration>(" config " ).getWindowGeometry ());
119+ info.setWindowGeometry (m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY ).getWindowGeometry ());
112120 // Load taskbar item
113121#ifdef _WIN32
114122 m_taskbar.connect (hwnd);
115- if (m_dataFileManager.get <Configuration>(" config " ).getAutomaticallyCheckForUpdates ())
123+ if (m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY ).getAutomaticallyCheckForUpdates ())
116124 {
117125 checkForUpdates (false );
118126 }
@@ -125,7 +133,7 @@ namespace Nickvision::Application::Shared::Controllers
125133
126134 void MainWindowController::shutdown (const WindowGeometry& geometry)
127135 {
128- Configuration& config{ m_dataFileManager.get <Configuration>(" config " ) };
136+ Configuration& config{ m_dataFileManager.get <Configuration>(CONFIG_FILE_KEY ) };
129137 config.setWindowGeometry (geometry);
130138 config.save ();
131139 }
0 commit comments