diff options
-rw-r--r-- | src/Common/Dlgcode.c | 17 | ||||
-rw-r--r-- | src/Common/Language.c | 4 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 20 | ||||
-rw-r--r-- | src/Mount/Mount.c | 29 |
4 files changed, 54 insertions, 16 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index dc727ee9..e858c3b4 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -2421,8 +2421,21 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine) SetPreferredLangId (ConfigReadString ("Language", "", langId, sizeof (langId)));
if (langId[0] == 0)
- DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_LANGUAGE), NULL,
- (DLGPROC) LanguageDlgProc, (LPARAM) 1);
+ {
+ if (IsNonInstallMode ())
+ {
+ // only support automatic use of a language file in portable mode
+ // this is achieved by placing a unique language XML file in the same
+ // place as portable VeraCrypt binaries.
+ DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_LANGUAGE), NULL,
+ (DLGPROC) LanguageDlgProc, (LPARAM) 1);
+ }
+ else
+ {
+ // when installed, force using English as default language
+ SetPreferredLangId ("en");
+ }
+ }
LoadLanguageFile ();
diff --git a/src/Common/Language.c b/src/Common/Language.c index fb20a6fb..e6abd38d 100644 --- a/src/Common/Language.c +++ b/src/Common/Language.c @@ -35,10 +35,10 @@ BOOL LocalizationActive;
int LocalizationSerialNo;
-wchar_t UnknownString[1024];
+wchar_t UnknownString[1024] = {0};
static char *LanguageFileBuffer = NULL;
static HANDLE LanguageFileFindHandle = INVALID_HANDLE_VALUE;
-static char PreferredLangId[6];
+static char PreferredLangId[6] = {0};
static char *LanguageResource = NULL;
static DWORD LanguageResourceSize = 0;
static char *HeaderResource[2] = {NULL, NULL};
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 2ebc70ca..d520a635 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -743,8 +743,21 @@ static void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, if (bOnlyCheckModified)
{
char langid[6] = {0};
- StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
- ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
+ if (!IsNonInstallMode ())
+ {
+ ConfigReadString ("Language", "", langid, sizeof (langid));
+ // when installed, if no preferred language set by user, English is selected default
+ if (langid [0] == 0)
+ StringCbCopyA (langid, sizeof(langid), "en");
+
+ if (pbSettingsModified && strcmp (langid, GetPreferredLangId ()))
+ *pbSettingsModified = TRUE;
+ }
+ else
+ {
+ StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
+ ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
+ }
}
if (hwndDlg != NULL)
@@ -785,8 +798,7 @@ static void SaveSettings (HWND hwndDlg) ConfigWriteInt ("SaveVolumeHistory", bHistory);
ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
- if (GetPreferredLangId () != NULL)
- ConfigWriteString ("Language", GetPreferredLangId ());
+ ConfigWriteString ("Language", GetPreferredLangId ());
ConfigWriteEnd (hwndDlg);
}
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 01c5108d..0d8cace2 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -776,9 +776,23 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* ConfigReadCompareInt ("DefaultTrueCryptMode", FALSE, &DefaultVolumeTrueCryptMode, bOnlyCheckModified, pbSettingsModified);
if (bOnlyCheckModified)
- {
- StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
- ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
+ {
+ if (!IsNonInstallMode ())
+ {
+ ConfigReadString ("Language", "", langid, sizeof (langid));
+ // when installed, if no preferred language set by user, English is set default
+ //
+ if (langid [0] == 0)
+ StringCbCopyA (langid, sizeof(langid), "en");
+
+ if (pbSettingsModified && strcmp (langid, GetPreferredLangId ()))
+ *pbSettingsModified = TRUE;
+ }
+ else
+ {
+ StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
+ ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
+ }
}
if (DefaultVolumePkcs5 < 0 || DefaultVolumePkcs5 > LAST_PRF_ID)
@@ -881,8 +895,7 @@ void SaveSettings (HWND hwndDlg) ConfigWriteInt ("DisplayMsgBoxOnHotkeyDismount", bDisplayBalloonOnSuccessfulHkDismount);
// Language
- if (GetPreferredLangId () != NULL)
- ConfigWriteString ("Language", GetPreferredLangId ());
+ ConfigWriteString ("Language", GetPreferredLangId ());
// PKCS#11 Library Path
ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
@@ -4111,11 +4124,11 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa goto stop;
}
- if (GetPreferredLangId () && strcmp (GetPreferredLangId (), "en") != 0)
+ if (strcmp (GetPreferredLangId (), "en") != 0)
{
// Language pack
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\Language.%s.xml", appDir, GetPreferredLangId ());
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\Language.%s.xml", dstDir, GetPreferredLangId ());
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\Language.%hs.xml", appDir, GetPreferredLangId ());
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\Language.%hs.xml", dstDir, GetPreferredLangId ());
TCCopyFileW (srcPath, dstPath);
}
|