feat: Allow setting language through the command line
This commit is contained in:
parent
26eec66f89
commit
7709f4e307
@ -548,7 +548,6 @@ namespace hex {
|
||||
void enableSystemThemeDetection(bool enabled) {
|
||||
s_systemThemeDetection = enabled;
|
||||
|
||||
EventSettingsChanged::post();
|
||||
EventOSThemeChanged::post();
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,13 @@ namespace hex {
|
||||
}
|
||||
|
||||
void loadLanguage(const std::string &language) {
|
||||
s_currStrings->clear();
|
||||
|
||||
auto &definitions = ContentRegistry::Language::impl::getLanguageDefinitions();
|
||||
|
||||
if (!definitions.contains(language))
|
||||
return;
|
||||
|
||||
s_currStrings->clear();
|
||||
|
||||
for (auto &definition : definitions[language])
|
||||
s_currStrings->insert(definition.getEntries().begin(), definition.getEntries().end());
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace {
|
||||
|
||||
// Draw the splash window while tasks are running
|
||||
if (!splashWindow.loop())
|
||||
ImHexApi::System::getInitArguments().insert({ "tasks-failed", {} });
|
||||
ImHexApi::System::impl::addInitArgument("tasks-failed");
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ namespace hex::plugin::builtin {
|
||||
void handleVersionCommand(const std::vector<std::string> &args);
|
||||
void handleHelpCommand(const std::vector<std::string> &args);
|
||||
void handlePluginsCommand(const std::vector<std::string> &args);
|
||||
void handleLanguageCommand(const std::vector<std::string> &args);
|
||||
|
||||
void handleOpenCommand(const std::vector<std::string> &args);
|
||||
|
||||
|
@ -130,6 +130,15 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void handleLanguageCommand(const std::vector<std::string> &args) {
|
||||
if (args.empty()) {
|
||||
hex::log::println("usage: imhex --language <language>");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ImHexApi::System::impl::addInitArgument("language", args[0]);
|
||||
}
|
||||
|
||||
void handleHashCommand(const std::vector<std::string> &args) {
|
||||
if (args.size() != 2) {
|
||||
hex::log::println("usage: imhex --hash <algorithm> <file>");
|
||||
|
@ -222,6 +222,12 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
});
|
||||
|
||||
EventImHexStartupFinished::subscribe([] {
|
||||
const auto &initArgs = ImHexApi::System::getInitArguments();
|
||||
if (auto it = initArgs.find("language"); it != initArgs.end())
|
||||
LocalizationManager::loadLanguage(it->second);
|
||||
});
|
||||
|
||||
fs::setFileBrowserErrorCallback([](const std::string& errMsg){
|
||||
#if defined(NFD_PORTAL)
|
||||
ui::PopupError::open(hex::format("hex.builtin.popup.error.file_dialog.portal"_lang, errMsg));
|
||||
|
@ -60,6 +60,7 @@ IMHEX_PLUGIN_SUBCOMMANDS() {
|
||||
{ "help", "Print help about this command", hex::plugin::builtin::handleHelpCommand },
|
||||
{ "version", "Print ImHex version", hex::plugin::builtin::handleVersionCommand },
|
||||
{ "plugins", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand },
|
||||
{ "language", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand },
|
||||
|
||||
{ "open", "Open files passed as argument. [default]", hex::plugin::builtin::handleOpenCommand },
|
||||
|
||||
@ -70,7 +71,7 @@ IMHEX_PLUGIN_SUBCOMMANDS() {
|
||||
{ "magic", "Identify file types", hex::plugin::builtin::handleMagicCommand },
|
||||
{ "pl", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand },
|
||||
{ "hexdump", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
||||
{ "hexdump", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
||||
{ "demangle", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
||||
};
|
||||
|
||||
IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
|
Loading…
Reference in New Issue
Block a user