mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Linux: Update local documentation logic to the new organization of folders under "docs/html"
This commit is contained in:
@@ -68,6 +68,19 @@ namespace VeraCrypt
|
||||
int GraphicUserInterface::g_customIdCmdA = 0;
|
||||
#endif
|
||||
|
||||
// Check if given language has a corresponding translated documentation
|
||||
static 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;
|
||||
}
|
||||
|
||||
GraphicUserInterface::GraphicUserInterface () :
|
||||
ActiveFrame (nullptr),
|
||||
BackgroundMode (false),
|
||||
@@ -1349,7 +1362,7 @@ namespace VeraCrypt
|
||||
#ifdef TC_RESOURCE_DIR
|
||||
htmlPath = StringConverter::ToWide (string (TC_TO_STRING (TC_RESOURCE_DIR)) + "/doc/HTML/");
|
||||
#elif defined (TC_WINDOWS)
|
||||
htmlPath += L"\\docs\\html\\en\\";
|
||||
htmlPath += L"\\docs\\html\\";
|
||||
#elif defined (TC_MACOSX)
|
||||
htmlPath += L"/../Resources/doc/HTML/";
|
||||
#elif defined (TC_UNIX)
|
||||
@@ -1365,17 +1378,24 @@ namespace VeraCrypt
|
||||
if (appDirEnv)
|
||||
{
|
||||
htmlPath = wxString::FromUTF8(appDirEnv);
|
||||
htmlPath += "/usr/share/doc/veracrypt/HTML/";
|
||||
htmlPath += L"/usr/share/doc/veracrypt/HTML/";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
localFile = false;
|
||||
#endif
|
||||
string preferredLang = LangString.GetPreferredLang();
|
||||
// Use preferred language only if it has translated documentation
|
||||
if (!HasTranslatedDocumentation (preferredLang))
|
||||
{
|
||||
preferredLang = "en";
|
||||
}
|
||||
wstring documentationLang = StringConverter::ToWide (preferredLang);
|
||||
if (localFile)
|
||||
{
|
||||
/* check if local file exists */
|
||||
wxFileName htmlFile = htmlPath + url;
|
||||
wxFileName htmlFile = htmlPath + documentationLang + L"/" + url;
|
||||
htmlFile.Normalize (
|
||||
wxPATH_NORM_ENV_VARS |
|
||||
wxPATH_NORM_DOTS |
|
||||
@@ -1385,11 +1405,32 @@ namespace VeraCrypt
|
||||
wxPATH_NORM_TILDE
|
||||
);
|
||||
localFile = htmlFile.FileExists();
|
||||
if (!localFile)
|
||||
{
|
||||
htmlFile = htmlPath + L"en/" + url;
|
||||
htmlFile.Normalize (
|
||||
wxPATH_NORM_ENV_VARS |
|
||||
wxPATH_NORM_DOTS |
|
||||
wxPATH_NORM_CASE |
|
||||
wxPATH_NORM_LONG |
|
||||
wxPATH_NORM_SHORTCUT |
|
||||
wxPATH_NORM_TILDE
|
||||
);
|
||||
localFile = htmlFile.FileExists();
|
||||
if (localFile)
|
||||
{
|
||||
htmlPath += L"en/";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlPath += documentationLang + L"/";
|
||||
}
|
||||
}
|
||||
|
||||
if (!localFile)
|
||||
{
|
||||
htmlPath = L"https://veracrypt.jp/en/";
|
||||
htmlPath = L"https://veracrypt.jp/" + documentationLang + L"/";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user