From 6a1780864c57d598446eb0c1d4faf7ea238c04d4 Mon Sep 17 00:00:00 2001 From: Jertzukka Date: Sun, 19 Nov 2023 01:31:40 +0200 Subject: Linux/FreeBSD/macOS: Implement language selection settings (#1253) * Implement Language selection into settings Initial commit to create a new tab in PreferencesNotebook for Language selection. By default, if nothing is chosen, it uses the current behaviour of using the language from system environment variables. If another language is chosen from the settings, it is saved into the Configuration.xml and this is used instead. * Fix SetStringSelection() assert issue on macOS * Add header include to fix build * Add current language pack, authors and way to use literal strings * Translations also for FreeBSD * Minimal GTK3 WX build on FreeBSD requires wxGraphicsContext * Get Preferences properly instead of workaround function * Use WrapSizer instead of BoxSizer for author line This forces long author lists to be put on a new line, reducing the need to increase window width. * Update Finnish translation * Borrow translation from IDM_LANGUAGE where it makes sense * Remove colon and thus unneeded function * Simplify Language tab layout * Reintroduce macOS specific fixes to Forms.cpp * cleanup --- src/Main/Forms/Forms.cpp | 82 ++- src/Main/Forms/Forms.h | 12 + src/Main/Forms/MainFrame.cpp | 11 + src/Main/Forms/MainFrame.h | 1 + src/Main/Forms/PreferencesDialog.cpp | 56 ++ src/Main/Forms/PreferencesDialog.h | 46 ++ src/Main/Forms/TrueCrypt.fbp | 1044 +++++++++++++++++++++++++--------- 7 files changed, 983 insertions(+), 269 deletions(-) (limited to 'src/Main/Forms') diff --git a/src/Main/Forms/Forms.cpp b/src/Main/Forms/Forms.cpp index 7afad90f..9ffad555 100644 --- a/src/Main/Forms/Forms.cpp +++ b/src/Main/Forms/Forms.cpp @@ -130,6 +130,10 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t MainMenuBar->Append( ToolsMenu, _("MENU_TOOLS") ); SettingsMenu = new wxMenu(); + wxMenuItem* LanguageMenuItem; + LanguageMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_LANGUAGE") ) , wxEmptyString, wxITEM_NORMAL ); + SettingsMenu->Append( LanguageMenuItem ); + HotkeysMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_HOTKEY_SETTINGS") ) , wxEmptyString, wxITEM_NORMAL ); SettingsMenu->Append( HotkeysMenuItem ); @@ -434,6 +438,7 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnManageSecurityTokenKeyfilesMenuItemSelected ), this, ManageSecurityTokenKeyfilesMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnCloseAllSecurityTokenSessionsMenuItemSelected ), this, CloseAllSecurityTokenSessionsMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnWipeCacheButtonClick ), this, WipeCachedPasswordsMenuItem->GetId()); + SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnLanguageMenuItemSelected ), this, LanguageMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnHotkeysMenuItemSelected ), this, HotkeysMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDefaultKeyfilesMenuItemSelected ), this, DefaultKeyfilesMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDefaultMountParametersMenuItemSelected ), this, DefaultMountParametersMenuItem->GetId()); @@ -444,7 +449,7 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t #else SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnPreferencesMenuItemSelected ), this, PreferencesMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnUserGuideMenuItemSelected ), this, UserGuideMenuItem->GetId()); -#endif +#endif HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnOnlineHelpMenuItemSelected ), this, OnlineHelpMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnBeginnersTutorialMenuItemSelected ), this, BeginnersTutorialMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnFaqMenuItemSelected ), this, FaqMenuItem->GetId()); @@ -2250,6 +2255,67 @@ PreferencesDialogBase::PreferencesDialogBase( wxWindow* parent, wxWindowID id, c HotkeysPage->Layout(); bSizer51->Fit( HotkeysPage ); PreferencesNotebook->AddPage( HotkeysPage, _("LINUX_HOTKEYS"), false ); + LanguagesPage = new wxPanel( PreferencesNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer170; + bSizer170 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer171; + bSizer171 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer173; + bSizer173 = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizer49; + sbSizer49 = new wxStaticBoxSizer( new wxStaticBox( LanguagesPage, wxID_ANY, _("LINUX_LANGUAGE") ), wxVERTICAL ); + + wxBoxSizer* bSizer174; + bSizer174 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText73 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("IDT_ACTIVE_LANG_PACK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText73->Wrap( -1 ); + bSizer174->Add( m_staticText73, 0, wxLEFT|wxTOP, 5 ); + + m_staticText74 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("CURRENT_LANGUAGE_PACK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText74->Wrap( -1 ); + bSizer174->Add( m_staticText74, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + + + sbSizer49->Add( bSizer174, 0, wxBOTTOM, 5 ); + + wxWrapSizer* wSizer1; + wSizer1 = new wxWrapSizer( wxHORIZONTAL, wxWRAPSIZER_DEFAULT_FLAGS ); + + m_staticText72 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("IDT_LANGPACK_AUTHORS"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText72->Wrap( -1 ); + wSizer1->Add( m_staticText72, 0, wxBOTTOM|wxLEFT, 5 ); + + m_staticText71 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("LANGUAGE_TRANSLATORS"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText71->Wrap( -1 ); + wSizer1->Add( m_staticText71, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + + + sbSizer49->Add( wSizer1, 0, 0, 5 ); + + LanguageListBox = new wxListBox( sbSizer49->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_SORT ); + sbSizer49->Add( LanguageListBox, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + + SysDefaultLangButton = new wxButton( sbSizer49->GetStaticBox(), wxID_ANY, _("LINUX_SELECT_SYS_DEFAULT_LANG"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer49->Add( SysDefaultLangButton, 0, wxALIGN_BOTTOM|wxALL|wxEXPAND, 5 ); + + + bSizer173->Add( sbSizer49, 1, wxALL|wxEXPAND, 5 ); + + + bSizer171->Add( bSizer173, 1, wxEXPAND, 5 ); + + + bSizer170->Add( bSizer171, 1, wxALL|wxEXPAND, 5 ); + + + LanguagesPage->SetSizer( bSizer170 ); + LanguagesPage->Layout(); + bSizer170->Fit( LanguagesPage ); + PreferencesNotebook->AddPage( LanguagesPage, _("LINUX_LANGUAGE"), false ); bSizer178->Add( PreferencesNotebook, 1, wxEXPAND | wxALL, 5 ); @@ -2280,6 +2346,7 @@ PreferencesDialogBase::PreferencesDialogBase( wxWindow* parent, wxWindowID id, c // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PreferencesDialogBase::OnClose ) ); + PreferencesNotebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( PreferencesDialogBase::OnPageChanged ), NULL, this ); DismountOnScreenSaverCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnScreenSaverCheckBoxClick ), NULL, this ); DismountOnPowerSavingCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnPowerSavingCheckBoxClick ), NULL, this ); ForceAutoDismountCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnForceAutoDismountCheckBoxClick ), NULL, this ); @@ -2292,6 +2359,7 @@ PreferencesDialogBase::PreferencesDialogBase( wxWindow* parent, wxWindowID id, c HotkeyListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( PreferencesDialogBase::OnHotkeyListItemSelected ), NULL, this ); AssignHotkeyButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnAssignHotkeyButtonClick ), NULL, this ); RemoveHotkeyButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnRemoveHotkeyButtonClick ), NULL, this ); + SysDefaultLangButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnSysDefaultLangButtonClick ), NULL, this ); OKButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnOKButtonClick ), NULL, this ); } @@ -2299,6 +2367,7 @@ PreferencesDialogBase::~PreferencesDialogBase() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PreferencesDialogBase::OnClose ) ); + PreferencesNotebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( PreferencesDialogBase::OnPageChanged ), NULL, this ); DismountOnScreenSaverCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnScreenSaverCheckBoxClick ), NULL, this ); DismountOnPowerSavingCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnPowerSavingCheckBoxClick ), NULL, this ); ForceAutoDismountCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnForceAutoDismountCheckBoxClick ), NULL, this ); @@ -2311,6 +2380,7 @@ PreferencesDialogBase::~PreferencesDialogBase() HotkeyListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( PreferencesDialogBase::OnHotkeyListItemSelected ), NULL, this ); AssignHotkeyButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnAssignHotkeyButtonClick ), NULL, this ); RemoveHotkeyButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnRemoveHotkeyButtonClick ), NULL, this ); + SysDefaultLangButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnSysDefaultLangButtonClick ), NULL, this ); OKButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnOKButtonClick ), NULL, this ); } @@ -2715,19 +2785,19 @@ KeyfilesPanelBase::KeyfilesPanelBase( wxWindow* parent, wxWindowID id, const wxP bSizer137 = new wxBoxSizer( wxHORIZONTAL ); AddFilesButton = new wxButton( this, wxID_ANY, _("IDC_KEYADD"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( AddFilesButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( AddFilesButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); AddDirectoryButton = new wxButton( this, wxID_ANY, _("IDC_ADD_KEYFILE_PATH"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( AddDirectoryButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( AddDirectoryButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); AddSecurityTokenSignatureButton = new wxButton( this, wxID_ANY, _("IDC_TOKEN_FILES_ADD"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( AddSecurityTokenSignatureButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( AddSecurityTokenSignatureButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); RemoveButton = new wxButton( this, wxID_ANY, _("IDC_KEYREMOVE"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( RemoveButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( RemoveButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); RemoveAllButton = new wxButton( this, wxID_ANY, _("IDC_KEYREMOVEALL"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( RemoveAllButton, 0, wxEXPAND|wxALL, 5 ); + bSizer137->Add( RemoveAllButton, 0, wxALL|wxEXPAND, 5 ); bSizer21->Add( bSizer137, 0, wxEXPAND, 5 ); diff --git a/src/Main/Forms/Forms.h b/src/Main/Forms/Forms.h index 96a03c79..70a8c230 100644 --- a/src/Main/Forms/Forms.h +++ b/src/Main/Forms/Forms.h @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include "international.h" @@ -116,6 +118,7 @@ namespace VeraCrypt virtual void OnManageSecurityTokenKeyfilesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnCloseAllSecurityTokenSessionsMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnWipeCacheButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnLanguageMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnHotkeysMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDefaultKeyfilesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDefaultMountParametersMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } @@ -613,11 +616,17 @@ namespace VeraCrypt wxButton* RemoveHotkeyButton; wxCheckBox* BeepAfterHotkeyMountDismountCheckBox; wxCheckBox* DisplayMessageAfterHotkeyDismountCheckBox; + wxStaticText* m_staticText73; + wxStaticText* m_staticText74; + wxStaticText* m_staticText72; + wxStaticText* m_staticText71; + wxButton* SysDefaultLangButton; wxButton* OKButton; wxButton* CancelButton; // Virtual event handlers, override them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnPageChanged( wxNotebookEvent& event ) { event.Skip(); } virtual void OnDismountOnScreenSaverCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnDismountOnPowerSavingCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnForceAutoDismountCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } @@ -630,6 +639,7 @@ namespace VeraCrypt virtual void OnHotkeyListItemSelected( wxListEvent& event ) { event.Skip(); } virtual void OnAssignHotkeyButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnRemoveHotkeyButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSysDefaultLangButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } @@ -638,6 +648,8 @@ namespace VeraCrypt wxPanel* DefaultKeyfilesPage; wxPanel* SecurityTokensPage; wxPanel* HotkeysPage; + wxPanel* LanguagesPage; + wxListBox* LanguageListBox; PreferencesDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("IDD_PREFERENCES_DLG"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp index de1c99a4..07b876ac 100644 --- a/src/Main/Forms/MainFrame.cpp +++ b/src/Main/Forms/MainFrame.cpp @@ -1068,6 +1068,17 @@ namespace VeraCrypt dialog.ShowModal(); } + void MainFrame::OnLanguageMenuItemSelected (wxCommandEvent& event) + { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif + PreferencesDialog dialog (this); + dialog.SelectPage (dialog.LanguagesPage); + dialog.ShowModal(); + } + void MainFrame::OnLegalNoticesMenuItemSelected (wxCommandEvent& event) { #ifdef TC_MACOSX diff --git a/src/Main/Forms/MainFrame.h b/src/Main/Forms/MainFrame.h index 5372adbb..ab70eae3 100644 --- a/src/Main/Forms/MainFrame.h +++ b/src/Main/Forms/MainFrame.h @@ -128,6 +128,7 @@ namespace VeraCrypt void OnHiddenVolumeProtectionTriggered (shared_ptr protectedVolume); void OnHotkey (wxKeyEvent& event); void OnHotkeysMenuItemSelected (wxCommandEvent& event); + void OnLanguageMenuItemSelected (wxCommandEvent& event); void OnLegalNoticesMenuItemSelected (wxCommandEvent& event); void OnListChanged (); void OnListItemActivated (wxListEvent& event); diff --git a/src/Main/Forms/PreferencesDialog.cpp b/src/Main/Forms/PreferencesDialog.cpp index 91204389..90a668e6 100644 --- a/src/Main/Forms/PreferencesDialog.cpp +++ b/src/Main/Forms/PreferencesDialog.cpp @@ -14,6 +14,9 @@ #include #ifdef TC_WINDOWS #include +#else +#include +#include #endif #include "Common/SecurityToken.h" #include "Main/Main.h" @@ -68,6 +71,30 @@ namespace VeraCrypt } Pkcs5PrfChoice->Select (prfInitialIndex); + // Language for non-Windows +#ifndef TC_WINDOWS +#if defined (TC_MACOSX) + wxDir languagesFolder(StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/"); +#else + wxDir languagesFolder("/usr/share/veracrypt/languages/"); +#endif + wxArrayString langArray; + LanguageListBox->Append("System default"); + LanguageListBox->Append("English"); + + size_t langCount; + langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, wxEmptyString, wxDIR_FILES); + for (size_t i = 0; i < langCount; ++i) { + wxFileName filename(langArray[i]); + wxString langId = filename.GetName().AfterLast('.'); + wxString langNative = langEntries[langId]; + if (!langNative.empty()) { + LanguageListBox->Append(langNative); + } + } +#endif + + // Keyfiles TC_CHECK_BOX_VALIDATOR (UseKeyfiles); @@ -238,6 +265,15 @@ namespace VeraCrypt } } + void PreferencesDialog::OnSysDefaultLangButtonClick (wxCommandEvent& event) + { + // SetStringSelection()'s Assert currently broken in sorted ListBoxes on macOS, workaround: + int itemIndex = LanguageListBox->FindString("System default", true); + if (itemIndex != wxNOT_FOUND) { + LanguageListBox->SetSelection(itemIndex); + } + } + void PreferencesDialog::OnAssignHotkeyButtonClick (wxCommandEvent& event) { #ifdef TC_WINDOWS @@ -355,6 +391,13 @@ namespace VeraCrypt AssignHotkeyButton->Enable (false); } + // Fixes an issue where going through PreferencesNotebook tabs would unintentionally select the first entry + // in the LanguageListBox and thus cause a language change on OKButton press. + void PreferencesDialog::OnPageChanged(wxBookCtrlEvent &event) + { + LanguageListBox->DeselectAll(); + } + void PreferencesDialog::OnOKButtonClick (wxCommandEvent& event) { #ifdef TC_WINDOWS @@ -388,6 +431,19 @@ namespace VeraCrypt bool securityTokenModuleChanged = (Preferences.SecurityTokenModule != wstring (Pkcs11ModulePathTextCtrl->GetValue())); Preferences.SecurityTokenModule = wstring (Pkcs11ModulePathTextCtrl->GetValue()); + if (LanguageListBox->GetSelection() != wxNOT_FOUND) { + wxString langToFind = LanguageListBox->GetString(LanguageListBox->GetSelection()); + for (const auto &each: langEntries) { + if (each.second == langToFind) { + Preferences.Language = each.first; +#ifdef DEBUG + cout << "Lang set to: " << each.first << endl; +#endif + } + } + Gui->ShowInfo (LangString["LINUX_RESTART_FOR_LANGUAGE_CHANGE"]); + } + Gui->SetPreferences (Preferences); try diff --git a/src/Main/Forms/PreferencesDialog.h b/src/Main/Forms/PreferencesDialog.h index 0cd1482a..50e8489e 100644 --- a/src/Main/Forms/PreferencesDialog.h +++ b/src/Main/Forms/PreferencesDialog.h @@ -40,9 +40,11 @@ namespace VeraCrypt void OnNoHardwareCryptoCheckBoxClick (wxCommandEvent& event); void OnNoKernelCryptoCheckBoxClick (wxCommandEvent& event); void OnOKButtonClick (wxCommandEvent& event); + void OnPageChanged (wxBookCtrlEvent& event); void OnPreserveTimestampsCheckBoxClick (wxCommandEvent& event); void OnRemoveHotkeyButtonClick (wxCommandEvent& event); void OnSelectPkcs11ModuleButtonClick (wxCommandEvent& event); + void OnSysDefaultLangButtonClick (wxCommandEvent& event); void OnTimer (); void UpdateHotkeyButtons(); @@ -58,6 +60,50 @@ namespace VeraCrypt UserPreferences Preferences; bool RestoreValidatorBell; HotkeyList UnregisteredHotkeys; + map langEntries = { + {"system", L"System default"}, + {"ar", L"العربية"}, + {"be", L"Беларуская"}, + {"bg", L"Български"}, + {"ca", L"Català"}, + {"co", L"Corsu"}, + {"cs", L"Čeština"}, + {"da", L"Dansk"}, + {"de", L"Deutsch"}, + {"el", L"Ελληνικά"}, + {"en", L"English"}, + {"es", L"Español"}, + {"et", L"Eesti"}, + {"eu", L"Euskara"}, + {"fa", L"فارسي"}, + {"fi", L"Suomi"}, + {"fr", L"Français"}, + {"he", L"עברית"}, + {"hu", L"Magyar"}, + {"id", L"Bahasa Indonesia"}, + {"it", L"Italiano"}, + {"ja", L"日本語"}, + {"ka", L"ქართული"}, + {"ko", L"한국어"}, + {"lv", L"Latviešu"}, + {"nl", L"Nederlands"}, + {"nn", L"Norsk Nynorsk"}, + {"pl", L"Polski"}, + {"ro", L"Română"}, + {"ru", L"Русский"}, + {"pt-br", L"Português-Brasil"}, + {"sk", L"Slovenčina"}, + {"sl", L"Slovenščina"}, + {"sv", L"Svenska"}, + {"th", L"ภาษาไทย"}, + {"tr", L"Türkçe"}, + {"uk", L"Українська"}, + {"uz", L"Ўзбекча"}, + {"vi", L"Tiếng Việt"}, + {"zh-cn", L"简体中文"}, + {"zh-hk", L"繁體中文(香港)"}, + {"zh-tw", L"繁體中文"} + }; }; } diff --git a/src/Main/Forms/TrueCrypt.fbp b/src/Main/Forms/TrueCrypt.fbp index 498b6f83..0b40a99e 100644 --- a/src/Main/Forms/TrueCrypt.fbp +++ b/src/Main/Forms/TrueCrypt.fbp @@ -461,6 +461,20 @@ MENU_SETTINGS SettingsMenu protected + + + 0 + 1 + + wxID_ANY + wxITEM_NORMAL + IDM_LANGUAGE + LanguageMenuItem + none + + + OnLanguageMenuItemSelected + 0 @@ -10864,6 +10878,7 @@ + OnPageChanged LINUX_PREF_TAB_SECURITY @@ -14872,106 +14887,11 @@ - - - - 5 - wxALL|wxEXPAND - 0 - - - bSizer182 - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 1 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_OK - IDOK - - 0 - - 0 - - - 0 - - 1 - OKButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnOKButtonClick - - - - 5 - wxALL - 0 - + + + LINUX_LANGUAGE + 0 + 1 1 1 @@ -14980,34 +14900,25 @@ - 0 - 1 0 1 1 - - 0 0 - Dock 0 Left 1 1 - 0 0 - wxID_CANCEL - IDCANCEL - - 0 + wxID_ANY 0 @@ -15015,147 +14926,754 @@ 0 1 - CancelButton + LanguagesPage 1 - protected + public 1 - - Resizable 1 - - + ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - RandomPoolEnrichmentDialogBase - - - wxDEFAULT_DIALOG_STYLE - - IDD_RANDOM_POOL_ENRICHMENT - - 0 - - - - OnMouseMotion - - - MainSizer - wxVERTICAL - protected - - 5 - wxEXPAND|wxALL - 1 - - - bSizer144 - wxVERTICAL - none - - 5 - wxEXPAND - 0 - - - bSizer145 - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - IDT_PRF - 0 - - 0 - - - 0 - - 1 - m_staticText49 - 1 - - - none - 1 - - Resizable + wxTAB_TRAVERSAL + + + bSizer170 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + + bSizer171 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizer173 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + wxID_ANY + LINUX_LANGUAGE + + sbSizer49 + wxVERTICAL + 1 + none + + 5 + wxBOTTOM + 0 + + + bSizer174 + wxHORIZONTAL + none + + 5 + wxLEFT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + IDT_ACTIVE_LANG_PACK + 0 + + 0 + + + 0 + + 1 + m_staticText73 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + CURRENT_LANGUAGE_PACK + 0 + + 0 + + + 0 + + 1 + m_staticText74 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + + 0 + + wxWRAPSIZER_DEFAULT_FLAGS + + wSizer1 + wxHORIZONTAL + none + + 5 + wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + IDT_LANGPACK_AUTHORS + 0 + + 0 + + + 0 + + 1 + m_staticText72 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + LANGUAGE_TRANSLATORS + 0 + + 0 + + + 0 + + 1 + m_staticText71 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,-1 + 1 + LanguageListBox + 1 + + + public + 1 + + Resizable + 1 + + wxLB_SINGLE|wxLB_SORT + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_BOTTOM|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + LINUX_SELECT_SYS_DEFAULT_LANG + + 0 + + 0 + + + 0 + + 1 + SysDefaultLangButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSysDefaultLangButtonClick + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + bSizer182 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_OK + IDOK + + 0 + + 0 + + + 0 + + 1 + OKButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOKButtonClick + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_CANCEL + IDCANCEL + + 0 + + 0 + + + 0 + + 1 + CancelButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + RandomPoolEnrichmentDialogBase + + + wxDEFAULT_DIALOG_STYLE + + IDD_RANDOM_POOL_ENRICHMENT + + 0 + + + + OnMouseMotion + + + MainSizer + wxVERTICAL + protected + + 5 + wxEXPAND|wxALL + 1 + + + bSizer144 + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + bSizer145 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + IDT_PRF + 0 + + 0 + + + 0 + + 1 + m_staticText49 + 1 + + + none + 1 + + Resizable 1 @@ -17270,7 +17788,7 @@ none 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP 0 1 @@ -17344,7 +17862,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP 0 1 @@ -17418,7 +17936,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP 0 1 @@ -17492,7 +18010,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP 0 1 @@ -17566,7 +18084,7 @@ 5 - wxEXPAND|wxALL + wxALL|wxEXPAND 0 1 @@ -22209,44 +22727,44 @@ wxTAB_TRAVERSAL - + bSizer98 wxVERTICAL none - + 5 wxEXPAND 0 - + bSizer99 wxVERTICAL none - + 5 wxEXPAND|wxTOP|wxBOTTOM 0 - + 0 protected 0 - + 5 wxEXPAND 0 - + bSizer100 wxHORIZONTAL none - + 5 wxALL 0 - + 1 1 1 @@ -22307,11 +22825,11 @@ OnVolumeSizeTextChanged - + 5 wxALL 0 - + 1 1 1 @@ -22374,17 +22892,17 @@ - + 5 wxEXPAND|wxTOP|wxBOTTOM 0 - + 0 protected 0 - + 5 wxALL|wxEXPAND 0 @@ -22463,7 +22981,7 @@ 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -22520,21 +23038,21 @@ -1 - + 5 wxEXPAND|wxTOP|wxBOTTOM 0 - + 0 protected 0 - + 5 wxALL|wxEXPAND 0 - + 1 1 1 -- cgit v1.2.3