Linux: fix language loading when running as AppImage

Fixes #1624

The language file path was hardcoded to /usr/share/veracrypt/languages/
which doesn't exist inside an AppImage runtime. Language files are
actually located under $APPDIR/usr/share/veracrypt/languages/ when
running from an AppImage.

This affected both the language file loading in Resources.cpp and the
language enumeration in PreferencesDialog.cpp, causing the language
selection to show only "System default" and "English" regardless of
which translations were packaged in the AppImage.
This commit is contained in:
Mounir IDRASSI
2026-05-24 21:34:24 +09:00
parent fc2efd0b8f
commit 854f85f013
2 changed files with 24 additions and 3 deletions

View File

@@ -22,6 +22,9 @@
#include "Main/Main.h"
#include "Main/Application.h"
#include "Main/GraphicUserInterface.h"
#ifdef TC_LINUX
#include "Platform/Unix/Process.h"
#endif
#include "Volume/Cipher.h"
#include "PreferencesDialog.h"
@@ -132,7 +135,16 @@ namespace VeraCrypt
#if defined (TC_MACOSX)
wxDir languagesFolder(StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/");
#else
wxDir languagesFolder("/usr/share/veracrypt/languages/");
wxString languagesFolderPath("/usr/share/veracrypt/languages/");
#ifdef TC_LINUX
if (Process::IsRunningUnderAppImage (StringConverter::ToSingle (wstring (Application::GetExecutablePath()))))
{
const char* appDirEnv = getenv ("APPDIR");
if (appDirEnv)
languagesFolderPath = wxString::FromUTF8 (appDirEnv) + "/usr/share/veracrypt/languages/";
}
#endif
wxDir languagesFolder(languagesFolderPath);
#endif
wxArrayString langArray;
LanguageListBox->Append("System default");

View File

@@ -17,13 +17,14 @@
#ifdef TC_WINDOWS
#include "Main/resource.h"
#else
#ifdef TC_MACOSX
#include "Application.h"
#endif
#include "Platform/File.h"
#include "Platform/StringConverter.h"
#include <stdio.h>
#include "UserPreferences.h"
#if defined(TC_LINUX)
#include "Platform/Unix/Process.h"
#endif
#endif
namespace VeraCrypt
@@ -66,6 +67,14 @@ namespace VeraCrypt
string filenamePrefix = StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/Language.";
#else
string filenamePrefix("/usr/share/veracrypt/languages/Language.");
#if defined(TC_LINUX)
if (Process::IsRunningUnderAppImage (StringConverter::ToSingle (wstring (Application::GetExecutablePath()))))
{
const char* appDirEnv = getenv ("APPDIR");
if (appDirEnv)
filenamePrefix = string (appDirEnv) + "/usr/share/veracrypt/languages/Language.";
}
#endif
#endif
string filenamePost(".xml");
string filename = filenamePrefix + defaultLang + filenamePost;