From 854f85f013c1d351fb62f8a7f3a443d834867a7e Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 24 May 2026 21:34:24 +0900 Subject: [PATCH] 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. --- src/Main/Forms/PreferencesDialog.cpp | 14 +++++++++++++- src/Main/Resources.cpp | 13 +++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Main/Forms/PreferencesDialog.cpp b/src/Main/Forms/PreferencesDialog.cpp index 9481f7f7..9c20a886 100644 --- a/src/Main/Forms/PreferencesDialog.cpp +++ b/src/Main/Forms/PreferencesDialog.cpp @@ -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"); diff --git a/src/Main/Resources.cpp b/src/Main/Resources.cpp index 729144fc..ff1192d9 100644 --- a/src/Main/Resources.cpp +++ b/src/Main/Resources.cpp @@ -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 #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;