diff options
author | Jertzukka <Jertzukka@gmail.com> | 2023-11-19 01:31:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 00:31:40 +0100 |
commit | 6a1780864c57d598446eb0c1d4faf7ea238c04d4 (patch) | |
tree | 83a17d40280a4b82be556c2aabb27d15034027fc /src | |
parent | 9247ce1bb90c44d19a0069fadb12c0c480ac9b4f (diff) | |
download | VeraCrypt-6a1780864c57d598446eb0c1d4faf7ea238c04d4.tar.gz VeraCrypt-6a1780864c57d598446eb0c1d4faf7ea238c04d4.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/Common/Language.xml | 3 | ||||
-rw-r--r-- | src/Main/Forms/Forms.cpp | 82 | ||||
-rw-r--r-- | src/Main/Forms/Forms.h | 12 | ||||
-rw-r--r-- | src/Main/Forms/MainFrame.cpp | 11 | ||||
-rw-r--r-- | src/Main/Forms/MainFrame.h | 1 | ||||
-rw-r--r-- | src/Main/Forms/PreferencesDialog.cpp | 56 | ||||
-rw-r--r-- | src/Main/Forms/PreferencesDialog.h | 46 | ||||
-rw-r--r-- | src/Main/Forms/TrueCrypt.fbp | 566 | ||||
-rw-r--r-- | src/Main/LanguageStrings.cpp | 7 | ||||
-rwxr-xr-x | src/Main/Main.make | 2 | ||||
-rw-r--r-- | src/Main/Resources.cpp | 84 | ||||
-rw-r--r-- | src/Main/UserPreferences.cpp | 4 | ||||
-rw-r--r-- | src/Main/UserPreferences.h | 2 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/Setup/Setup.c | 2 |
15 files changed, 810 insertions, 70 deletions
diff --git a/src/Common/Language.xml b/src/Common/Language.xml index 32930193..e3e96a1f 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1635,6 +1635,9 @@ <entry lang="en" key="IDC_LINK_KEYFILES_EXTENSIONS_WARNING">Important information on using third-party file extensions</entry> <entry lang="en" key="IDC_DISABLE_MEMORY_PROTECTION">Disable memory protection for Accessibility tools compatibility</entry> <entry lang="en" key="DISABLE_MEMORY_PROTECTION_WARNING">WARNING: Disabling memory protection significantly reduces security. Enable this option ONLY if you rely on Accessibility tools, like Screen Readers, to interact with VeraCrypt's UI.</entry> + <entry lang="en" key="LINUX_LANGUAGE">Language</entry> + <entry lang="en" key="LINUX_SELECT_SYS_DEFAULT_LANG">Select system's default language</entry> + <entry lang="en" key="LINUX_RESTART_FOR_LANGUAGE_CHANGE">For the language change to come into effect, VeraCrypt needs to be restarted.</entry> </localization> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="VeraCrypt"> 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 <wx/choice.h> #include <wx/gauge.h> #include <wx/spinctrl.h> +#include <wx/wrapsizer.h> +#include <wx/listbox.h> #include <wx/notebook.h> #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 <VolumeInfo> 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 <wx/dynlib.h> #ifdef TC_WINDOWS #include <wx/msw/registry.h> +#else +#include <wx/dir.h> +#include <wx/arrstr.h> #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<wxString, wstring> 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 @@ -468,6 +468,20 @@ <property name="help"></property> <property name="id">wxID_ANY</property> <property name="kind">wxITEM_NORMAL</property> + <property name="label">IDM_LANGUAGE</property> + <property name="name">LanguageMenuItem</property> + <property name="permission">none</property> + <property name="shortcut"></property> + <property name="unchecked_bitmap"></property> + <event name="OnMenuSelection">OnLanguageMenuItemSelected</event> + </object> + <object class="wxMenuItem" expanded="0"> + <property name="bitmap"></property> + <property name="checked">0</property> + <property name="enabled">1</property> + <property name="help"></property> + <property name="id">wxID_ANY</property> + <property name="kind">wxITEM_NORMAL</property> <property name="label">IDM_HOTKEY_SETTINGS</property> <property name="name">HotkeysMenuItem</property> <property name="permission">protected</property> @@ -10864,6 +10878,7 @@ <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> + <event name="OnNotebookPageChanged">OnPageChanged</event> <object class="notebookpage" expanded="0"> <property name="bitmap"></property> <property name="label">LINUX_PREF_TAB_SECURITY</property> @@ -14872,6 +14887,509 @@ </object> </object> </object> + <object class="notebookpage" expanded="0"> + <property name="bitmap"></property> + <property name="label">LINUX_LANGUAGE</property> + <property name="select">0</property> + <object class="wxPanel" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">LanguagesPage</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">public</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style">wxTAB_TRAVERSAL</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer170</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer171</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer173</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxStaticBoxSizer" expanded="0"> + <property name="id">wxID_ANY</property> + <property name="label">LINUX_LANGUAGE</property> + <property name="minimum_size"></property> + <property name="name">sbSizer49</property> + <property name="orient">wxVERTICAL</property> + <property name="parent">1</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxBOTTOM</property> + <property name="proportion">0</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer174</property> + <property name="orient">wxHORIZONTAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxLEFT|wxTOP</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">IDT_ACTIVE_LANG_PACK</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText73</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxLEFT|wxRIGHT|wxTOP</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">CURRENT_LANGUAGE_PACK</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText74</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag"></property> + <property name="proportion">0</property> + <object class="wxWrapSizer" expanded="0"> + <property name="flags">wxWRAPSIZER_DEFAULT_FLAGS</property> + <property name="minimum_size"></property> + <property name="name">wSizer1</property> + <property name="orient">wxHORIZONTAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxBOTTOM|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">IDT_LANGPACK_AUTHORS</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText72</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">LANGUAGE_TRANSLATORS</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText71</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property> + <property name="proportion">1</property> + <object class="wxListBox" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="choices"></property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size">-1,-1</property> + <property name="moveable">1</property> + <property name="name">LanguageListBox</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">public</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style">wxLB_SINGLE|wxLB_SORT</property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALIGN_BOTTOM|wxALL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="auth_needed">0</property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="bitmap"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="current"></property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="disabled"></property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="focus"></property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">LINUX_SELECT_SYS_DEFAULT_LANG</property> + <property name="margins"></property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">SysDefaultLangButton</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="position"></property> + <property name="pressed"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnSysDefaultLangButtonClick</event> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> </object> </object> <object class="sizeritem" expanded="0"> @@ -17270,7 +17788,7 @@ <property name="permission">none</property> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> @@ -17344,7 +17862,7 @@ </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> @@ -17418,7 +17936,7 @@ </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> @@ -17492,7 +18010,7 @@ </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> @@ -17566,7 +18084,7 @@ </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxALL</property> + <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> @@ -22209,44 +22727,44 @@ <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style">wxTAB_TRAVERSAL</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer98</property> <property name="orient">wxVERTICAL</property> <property name="permission">none</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">0</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer99</property> <property name="orient">wxVERTICAL</property> <property name="permission">none</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property> <property name="proportion">0</property> - <object class="spacer" expanded="1"> + <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">0</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer100</property> <property name="orient">wxHORIZONTAL</property> <property name="permission">none</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL</property> <property name="proportion">0</property> - <object class="wxTextCtrl" expanded="1"> + <object class="wxTextCtrl" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> @@ -22307,11 +22825,11 @@ <event name="OnText">OnVolumeSizeTextChanged</event> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL</property> <property name="proportion">0</property> - <object class="wxChoice" expanded="1"> + <object class="wxChoice" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> @@ -22374,17 +22892,17 @@ </object> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property> <property name="proportion">0</property> - <object class="spacer" expanded="1"> + <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> @@ -22463,7 +22981,7 @@ <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> - <object class="wxStaticText" expanded="1"> + <object class="wxStaticText" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> @@ -22520,21 +23038,21 @@ <property name="wrap">-1</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property> <property name="proportion">0</property> - <object class="spacer" expanded="1"> + <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> - <object class="wxStaticText" expanded="1"> + <object class="wxStaticText" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> diff --git a/src/Main/LanguageStrings.cpp b/src/Main/LanguageStrings.cpp index 71914ec7..0e13ebc7 100644 --- a/src/Main/LanguageStrings.cpp +++ b/src/Main/LanguageStrings.cpp @@ -56,12 +56,17 @@ namespace VeraCrypt Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; } - foreach (XmlNode node, XmlParser (Resources::GetLanguageXml()).GetNodes (L"entry")) + string translatedXml = Resources::GetLanguageXml(); + foreach (XmlNode node, XmlParser (translatedXml).GetNodes (L"entry")) { wxString text = node.InnerText; text.Replace (L"\\n", L"\n"); Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; } + + XmlNode node = XmlParser (translatedXml).GetNodes (L"language").front(); + Map["LANGUAGE_TRANSLATORS"] = wxString (node.Attributes[L"translators"]); + Map["CURRENT_LANGUAGE_PACK"] = wxString (node.Attributes[L"name"]); } LanguageStrings LangString; diff --git a/src/Main/Main.make b/src/Main/Main.make index 90b8b126..dd85f842 100755 --- a/src/Main/Main.make +++ b/src/Main/Main.make @@ -310,6 +310,8 @@ prepare: $(APPNAME) chmod +x $(BASE_DIR)/Setup/FreeBSD/usr/bin/$(APPNAME)-uninstall.sh cp $(BASE_DIR)/License.txt $(BASE_DIR)/Setup/FreeBSD/usr/share/doc/$(APPNAME)/License.txt cp -R $(BASE_DIR)/../doc/html/* "$(BASE_DIR)/Setup/FreeBSD/usr/share/doc/$(APPNAME)/HTML" + mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/veracrypt/languages + cp -r $(BASE_DIR)/../Translations/* $(BASE_DIR)/Setup/FreeBSD/usr/share/veracrypt/languages/ ifndef TC_NO_GUI mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/applications diff --git a/src/Main/Resources.cpp b/src/Main/Resources.cpp index 58030c1e..d8bab977 100644 --- a/src/Main/Resources.cpp +++ b/src/Main/Resources.cpp @@ -23,6 +23,7 @@ #include "Platform/File.h" #include "Platform/StringConverter.h" #include <stdio.h> +#include "UserPreferences.h" #endif namespace VeraCrypt @@ -46,7 +47,6 @@ namespace VeraCrypt } #endif // TC_WINDOWS - string Resources::GetLanguageXml () { #ifdef TC_WINDOWS @@ -68,53 +68,65 @@ namespace VeraCrypt #endif string filenamePost(".xml"); string filename = filenamePrefix + defaultLang + filenamePost; - if(const char* env_p = getenv("LANG")){ - string lang(env_p); + + UserPreferences Preferences; + Preferences.Load(); + wstring preferredLang = Preferences.Language; #ifdef DEBUG - std::cout << lang << std::endl; + std::cout << "Config language: " << preferredLang << std::endl; #endif - if ( lang.size() > 1 ){ - int found = lang.find("."); - if ( found > 1 ){ - string langTag = lang.substr (0,found); - string lowerLangTag(StringConverter::ToLower (langTag) ); - int foundUnderscore = lowerLangTag.find("_"); - if ( foundUnderscore > 0 ) { - lowerLangTag.replace(foundUnderscore,1,1,'-'); - filename = filenamePrefix + lowerLangTag + filenamePost; - FilesystemPath xml(filename); - if (! xml.IsFile()){ - string shortLangTag = lowerLangTag.substr(0,foundUnderscore); - filename = filenamePrefix + shortLangTag + filenamePost; + + if (preferredLang == L"system") { + if (const char *env_p = getenv("LANG")) { + string lang(env_p); +#ifdef DEBUG + std::cout << "env $LANG: " << lang << std::endl; +#endif + if (lang.size() > 1) { + int found = lang.find("."); + if (found > 1) { + string langTag = lang.substr(0, found); + string lowerLangTag(StringConverter::ToLower(langTag)); + int foundUnderscore = lowerLangTag.find("_"); + if (foundUnderscore > 0) { + lowerLangTag.replace(foundUnderscore, 1, 1, '-'); + filename = filenamePrefix + lowerLangTag + filenamePost; FilesystemPath xml(filename); - if (! xml.IsFile()){ + if (!xml.IsFile()) { + string shortLangTag = lowerLangTag.substr(0, foundUnderscore); + filename = filenamePrefix + shortLangTag + filenamePost; + FilesystemPath xml(filename); + if (!xml.IsFile()) { + filename = filenamePrefix + defaultLang + filenamePost; + } + } + } else { + filename = filenamePrefix + langTag + filenamePost; + FilesystemPath xml(filename); + if (!xml.IsFile()) { filename = filenamePrefix + defaultLang + filenamePost; } } - }else{ - filename = filenamePrefix + langTag + filenamePost; + } else { + string lowerLang(StringConverter::ToLower(lang)); + filename = filenamePrefix + lowerLang + filenamePost; FilesystemPath xml(filename); - if (! xml.IsFile()){ - filename = filenamePrefix + defaultLang + filenamePost; - } - } - }else{ - string lowerLang(StringConverter::ToLower (lang) ); - filename = filenamePrefix + lowerLang + filenamePost; - FilesystemPath xml(filename); - if (! xml.IsFile()){ - int foundUnderscore = lowerLang.find("_"); - if ( foundUnderscore > 0 ) { - lowerLang.replace(foundUnderscore,1,1,'-'); - filename = filenamePrefix + lowerLang + filenamePost; - FilesystemPath xml(filename); - if (! xml.IsFile()){ - filename = filenamePrefix + defaultLang + filenamePost; + if (!xml.IsFile()) { + int foundUnderscore = lowerLang.find("_"); + if (foundUnderscore > 0) { + lowerLang.replace(foundUnderscore, 1, 1, '-'); + filename = filenamePrefix + lowerLang + filenamePost; + FilesystemPath xml(filename); + if (!xml.IsFile()) { + filename = filenamePrefix + defaultLang + filenamePost; + } } } } } } + } else { + filename = filenamePrefix + preferredLang + filenamePost; } FilesystemPath xml(filename); if ( xml.IsFile() ){ diff --git a/src/Main/UserPreferences.cpp b/src/Main/UserPreferences.cpp index b5a1f42c..194cb6df 100644 --- a/src/Main/UserPreferences.cpp +++ b/src/Main/UserPreferences.cpp @@ -92,6 +92,7 @@ namespace VeraCrypt TC_CONFIG_SET (BackgroundTaskEnabled); if (configMap.count(L"FilesystemOptions") > 0) { SetValue (configMap[L"FilesystemOptions"], DefaultMountOptions.FilesystemOptions); configMap.erase (L"FilesystemOptions"); } TC_CONFIG_SET (ForceAutoDismount); + TC_CONFIG_SET (Language); TC_CONFIG_SET (LastSelectedSlotNumber); TC_CONFIG_SET (MaxVolumeIdleTime); TC_CONFIG_SET (MountDevicesOnLogon); @@ -214,6 +215,7 @@ namespace VeraCrypt TC_CONFIG_ADD (BackgroundTaskEnabled); formatter.AddEntry (L"FilesystemOptions", DefaultMountOptions.FilesystemOptions); TC_CONFIG_ADD (ForceAutoDismount); + TC_CONFIG_ADD (Language); TC_CONFIG_ADD (LastSelectedSlotNumber); TC_CONFIG_ADD (MaxVolumeIdleTime); TC_CONFIG_ADD (MountDevicesOnLogon); @@ -240,7 +242,7 @@ namespace VeraCrypt for (map<wxString, wxString>::const_iterator it = UnknownConfigMapEntries.begin(); it != UnknownConfigMapEntries.end(); ++it) { formatter.AddEntry(it->first.c_str(), it->second); - } + } XmlWriter writer (Application::GetConfigFilePath (GetPreferencesFileName(), true)); writer.WriteNode (formatter.XmlConfig); diff --git a/src/Main/UserPreferences.h b/src/Main/UserPreferences.h index 3f60b533..25621656 100644 --- a/src/Main/UserPreferences.h +++ b/src/Main/UserPreferences.h @@ -39,6 +39,7 @@ namespace VeraCrypt DismountOnScreenSaver (false), DisplayMessageAfterHotkeyDismount (false), ForceAutoDismount (true), + Language (L"system"), LastSelectedSlotNumber (0), MaxVolumeIdleTime (60), MountDevicesOnLogon (false), @@ -81,6 +82,7 @@ namespace VeraCrypt bool DismountOnScreenSaver; bool DisplayMessageAfterHotkeyDismount; bool ForceAutoDismount; + wstring Language; uint64 LastSelectedSlotNumber; int32 MaxVolumeIdleTime; bool MountDevicesOnLogon; diff --git a/src/Makefile b/src/Makefile index e8fb1e19..23ff8c48 100644 --- a/src/Makefile +++ b/src/Makefile @@ -507,7 +507,7 @@ WX_CONFIGURE_FLAGS += --disable-protocol --disable-protocols --disable-url --dis --disable-gif --disable-pcx --disable-tga --disable-iff --disable-gif --disable-pnm --disable-svg \ --without-expat --without-libtiff --without-libjpeg --without-libpng -without-regex --without-zlib -ifeq "$(PLATFORM)" "Linux" +ifneq (,$(filter Linux FreeBSD,$(PLATFORM))) WX_CONFIGURE_FLAGS += --disable-tooltips ifneq "$(origin WITHGTK3)" "command line" WX_CONFIGURE_FLAGS += --disable-graphics_ctx diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index fe25a412..6edc0ea9 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -2593,7 +2593,7 @@ static tLanguageEntry g_languagesEntries[] = { {L"Ўзбекча", IDR_LANG_UZ, LANG_UZBEK, "uz", NULL}, {L"Tiếng Việt", IDR_LANG_VI, LANG_VIETNAMESE, "vi", NULL}, {L"简体中文", IDR_LANG_ZHCN, LANG_CHINESE, "zh-cn", L"zh-CN"}, - {L"繁體中文", IDR_LANG_ZHHK, LANG_CHINESE, "zh-hk", L"zh-HK"}, + {L"繁體中文(香港)", IDR_LANG_ZHHK, LANG_CHINESE, "zh-hk", L"zh-HK"}, {L"繁體中文", IDR_LANG_ZHTW, LANG_CHINESE, "zh-tw", L"zh-TW"}, }; |