From 45520691438859cf86ef286ac270a3f2b9f8feaf Mon Sep 17 00:00:00 2001 From: cjee21 <77721854+cjee21@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:41:08 +0800 Subject: [PATCH] Windows GUI: Quick temp fix for translations after update --- Source/GUI/VCL/GUI_Main.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Source/GUI/VCL/GUI_Main.cpp b/Source/GUI/VCL/GUI_Main.cpp index 029030f62..f4e839b04 100644 --- a/Source/GUI/VCL/GUI_Main.cpp +++ b/Source/GUI/VCL/GUI_Main.cpp @@ -47,6 +47,9 @@ TMainF *MainF; #include #include #include + +#include // To remove when "Quick temporary fix for translations after an update" is removed + using namespace MediaInfoNameSpace; using namespace ZenLib; //--------------------------------------------------------------------------- @@ -303,6 +306,34 @@ void __fastcall TMainF::GUI_Configure() delete PreferencesF; Prefs->Config_Load(); //Again... #endif //MEDIAINFOGUI_PREFS_NO + + //Quick temporary fix for translations after an update + //---------------------------------------------------------------------------------------------- + //Copies updated language files from install folder to appdata folder if appdata folder exists, + //overwriting existing files + //---------------------------------------------------------------------------------------------- + namespace fs = std::filesystem; + fs::path appdata_path = std::getenv("APPDATA"); + fs::path language_path = appdata_path / "MediaInfo\\Plugin\\Language"; + ZenLib::Ztring BaseFolder; + BaseFolder=Application->ExeName.c_str(); + fs::path language_source_path = BaseFolder.substr(0, BaseFolder.rfind(__T("\\"))).c_str(); + language_source_path = language_source_path / "Plugin\\Language"; + if (fs::exists(language_path) && fs::is_directory(language_path)) { + try { + for (const auto& entry : fs::directory_iterator(language_source_path)) { + fs::path current = entry.path(); + fs::path target = language_path / current.filename(); + if (fs::is_regular_file(current)) { + fs::copy_file(current, target, fs::copy_options::overwrite_existing); + } + } + //ShowMessage("Success updating translations!"); + } catch (const fs::filesystem_error& e) { + ShowMessage("Error updating translations in %APPDATA%!"); + } + } + //---------------------------------------------------------------------------------------------- } // Removed, no more needed