1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

Windows: reorganize localized documentation, each in a dedicated folder. Adapt installers and documentation URL logic.

Now we have 3 folders under html directory:en, ru, zh-cn. Similar separation exist in online version:
https://veracrypt.fr/en
https://veracrypt.fr/ru
https://veracrypt.fr/zh-cn
This commit is contained in:
Mounir IDRASSI
2025-04-27 23:33:08 +09:00
parent 7c13d21d96
commit 07b53541e0
446 changed files with 1282 additions and 14438 deletions

View File

@@ -11211,6 +11211,19 @@ std::wstring GetWindowsEdition ()
extern wchar_t InstallationPath[TC_MAX_PATH];
#endif
// Check if given language has a corresponding translated documentation
BOOL HasTranslatedDocumentation(const char* language)
{
// hardcoded list of languages for which a translated documentation exists
const char* supportedLanguages[] = { "en", "ru", "zh-cn"};
for (int i = 0; i < sizeof(supportedLanguages) / sizeof(supportedLanguages[0]); i++)
{
if (strcmp(language, supportedLanguages[i]) == 0)
return TRUE;
}
return FALSE;
}
void Applink (const char *dest)
{
wchar_t url [MAX_URL_LENGTH] = {0};
@@ -11218,6 +11231,19 @@ void Applink (const char *dest)
wchar_t installDir[TC_MAX_PATH] = {0};
BOOL buildUrl = TRUE;
INT_PTR r;
wchar_t currentLanguage[8];
if (strcmp (GetPreferredLangId(), "en") == 0
|| strlen(GetPreferredLangId()) == 0
|| !HasTranslatedDocumentation(GetPreferredLangId()))
{
// set currentLanguage to "en"
StringCbCopyW(currentLanguage, sizeof(currentLanguage), L"en");
}
else
{
// set currentLanguage to return value of GetPreferredLangId()
StringCbPrintfW(currentLanguage, sizeof(currentLanguage), L"%S", GetPreferredLangId());
}
ArrowWaitCursor ();
@@ -11262,7 +11288,7 @@ void Applink (const char *dest)
}
else if (strcmp(dest, "onlinehelp") == 0)
{
StringCbCopyW (url, sizeof (url),L"https://www.veracrypt.fr/en/Documentation.html");
StringCbPrintfW (url, sizeof (url),L"https://www.veracrypt.fr/%s/Documentation.html", currentLanguage);
buildUrl = FALSE;
}
else if (strcmp(dest, "keyfiles") == 0)
@@ -11374,18 +11400,32 @@ void Applink (const char *dest)
#ifdef SETUP
if (IsInternetConnected())
{
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/%s/%s", currentLanguage, page);
buildUrl = FALSE;
}
else
#endif
if (buildUrl)
{
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
// first check that directory of translated documentation exists
BOOL bFallbackToEnglish = FALSE;
if (wcscmp(currentLanguage, L"en") != 0)
{
std::wstring pageFullPath = installDir;
pageFullPath += L"docs\\html\\";
pageFullPath += currentLanguage;
if (!FileExists(pageFullPath.c_str()))
{
// fallback to English
bFallbackToEnglish = TRUE;
}
}
if (bFallbackToEnglish)
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
else
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/%s/%s", installDir, currentLanguage, page);
CorrectURL (url);
}
#else
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
CorrectURL (url);
#endif
}
if (IsAdmin ())
@@ -11401,13 +11441,15 @@ void Applink (const char *dest)
if (S_OK == UrlUnescapeW (pageFileName, pageFileName, &cchUnescaped, URL_UNESCAPE_INPLACE))
{
std::wstring pageFullPath = installDir;
pageFullPath += L"docs\\html\\en\\";
pageFullPath += L"docs\\html\\";
pageFullPath += currentLanguage;
pageFullPath += L"\\";
pageFullPath += pageFileName;
if (!FileExists (pageFullPath.c_str()))
{
// fallback to online resources
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/%s/%s", currentLanguage, page);
SafeOpenURL (url);
openDone = 1;
}
@@ -11426,7 +11468,7 @@ void Applink (const char *dest)
if (((r == ERROR_FILE_NOT_FOUND) || (r == ERROR_PATH_NOT_FOUND)) && buildUrl)
{
// fallback to online resources
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/%s/%s", currentLanguage, page);
ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1156,6 +1156,14 @@ err:
FindClose (h);
}
// remove legacy folder "docs\en\ru" if present in installation directory
{
wchar_t folder[TC_MAX_PATH];
// since we've done SetCurrentDirectory(szDestDir), a relative path will be resolved correctly
StringCbCopyW(folder, sizeof(folder), L"docs\\html\\en\\ru");
StatRemoveDirectory(folder);
}
// remove language XML files from previous version if any
h = FindFirstFile (L"Language*.xml", &f);

View File

@@ -2634,6 +2634,14 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller)
FindClose (h);
}
// remove legacy folder "docs\en\ru" if present in installation directory
{
wchar_t folder[TC_MAX_PATH];
// since we've done SetCurrentDirectory(szDestDir), a relative path will be resolved correctly
StringCbCopyW(folder, sizeof(folder), L"docs\\html\\en\\ru");
StatRemoveDirectory(folder);
}
// remove language XML files from previous version if any
h = FindFirstFile (L"Language*.xml", &f);