refactor: Rename and update localization system

This commit is contained in:
WerWolv
2023-11-21 14:38:01 +01:00
parent c89a870fe9
commit 909f4b7fe8
76 changed files with 334 additions and 316 deletions

View File

@@ -6,7 +6,7 @@
#include <implot.h>
#include <hex/api/imhex_api.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/providers/provider.hpp>
#include <hex/providers/buffered_reader.hpp>

View File

@@ -4,7 +4,7 @@
#include <hex/ui/imgui_imhex_extensions.h>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/http_requests.hpp>
#include <functional>

View File

@@ -2,7 +2,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <wolv/utils/string.hpp>

View File

@@ -2,7 +2,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/imhex_api.hpp>
#include <functional>

View File

@@ -2,7 +2,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <string>

View File

@@ -2,7 +2,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>

View File

@@ -2,7 +2,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <wolv/hash/uuid.hpp>

View File

@@ -3,7 +3,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/imhex_api.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <string>

View File

@@ -2,7 +2,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <string>

View File

@@ -1,7 +1,7 @@
#pragma once
#include <hex/providers/provider.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
namespace hex::plugin::builtin {

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/event_manager.hpp>
#include <wolv/net/socket_server.hpp>

View File

@@ -1,6 +1,6 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>
@@ -64,7 +64,7 @@ namespace hex::plugin::builtin {
continue;
std::vector<std::string> names;
std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return LangEntry(name); });
std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return Lang(name); });
if (auto combined = wolv::util::combineStrings(names, " -> "); hex::containsIgnoreCase(combined, input) && !combined.contains(ContentRegistry::Interface::impl::SeparatorValue) && !combined.contains(ContentRegistry::Interface::impl::SubMenuValue)) {
result.emplace_back(ContentRegistry::CommandPaletteCommands::impl::QueryResult {

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/ui/imgui_imhex_extensions.h>
#include <hex/data_processor/node.hpp>

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/crypto.hpp>
#include <hex/data_processor/node.hpp>

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/data_processor/node.hpp>
#include <ranges>

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/data_processor/node.hpp>
#include <hex/ui/imgui_imhex_extensions.h>

View File

@@ -1,6 +1,6 @@
#include <hex/api/event_manager.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp>

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/crypto.hpp>
#include <hex/ui/imgui_imhex_extensions.h>

View File

@@ -221,7 +221,7 @@ namespace hex::plugin::builtin {
void drawExportLanguageMenu() {
for (const auto &formatter : ContentRegistry::DataFormatter::impl::getEntries()) {
if (ImGui::MenuItem(LangEntry(formatter.unlocalizedName), nullptr, false, ImHexApi::Provider::get()->getActualSize() > 0)) {
if (ImGui::MenuItem(Lang(formatter.unlocalizedName), nullptr, false, ImHexApi::Provider::get()->getActualSize() > 0)) {
fs::openFileBrowser(fs::DialogMode::Save, {}, [&formatter](const auto &path) {
TaskManager::createTask("Exporting data", TaskManager::NoProgress, [&formatter, path](auto&){
auto provider = ImHexApi::Provider::get();
@@ -351,7 +351,7 @@ namespace hex::plugin::builtin {
/* Open Other */
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.open_other"}, 1150, [] {
for (const auto &unlocalizedProviderName : ContentRegistry::Provider::impl::getEntries()) {
if (ImGui::MenuItem(LangEntry(unlocalizedProviderName)))
if (ImGui::MenuItem(Lang(unlocalizedProviderName)))
ImHexApi::Provider::createProvider(unlocalizedProviderName);
}
}, noRunningTasks);
@@ -477,7 +477,7 @@ namespace hex::plugin::builtin {
if (view->hasViewMenuItemEntry()) {
auto &state = view->getWindowOpenState();
if (ImGui::MenuItem(LangEntry(view->getUnlocalizedName()), "", &state))
if (ImGui::MenuItem(Lang(view->getUnlocalizedName()), "", &state))
view->setWindowJustOpened(state);
}
}

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/helpers/http_requests.hpp>

View File

@@ -4,7 +4,7 @@
#include <wolv/utils/string.hpp>
#include <hex/api/project_file_manager.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/providers/provider.hpp>

View File

@@ -3,7 +3,7 @@
#include "content/providers/disk_provider.hpp"
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/utils.hpp>

View File

@@ -3,7 +3,7 @@
#include <cstring>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/api/task_manager.hpp>

View File

@@ -9,7 +9,7 @@
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/crypto.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <nlohmann/json.hpp>

View File

@@ -3,7 +3,7 @@
#include <cstring>
#include <hex/api/imhex_api.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>

View File

@@ -5,7 +5,7 @@
#include <cstring>
#include <hex/api/imhex_api.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/event_manager.hpp>
#include <wolv/io/file.hpp>
@@ -116,14 +116,14 @@ namespace hex::plugin::builtin {
[[nodiscard]] std::string MemoryFileProvider::getName() const {
if (this->m_name.empty())
return LangEntry("hex.builtin.provider.mem_file.unsaved");
return Lang("hex.builtin.provider.mem_file.unsaved");
else
return this->m_name;
}
std::vector<MemoryFileProvider::MenuEntry> MemoryFileProvider::getMenuEntries() {
return {
MenuEntry { LangEntry("hex.builtin.provider.mem_file.rename"), [this] { this->renameFile(); } }
MenuEntry { Lang("hex.builtin.provider.mem_file.rename"), [this] { this->renameFile(); } }
};
}

View File

@@ -1,7 +1,7 @@
#include "content/providers/motorola_srec_provider.hpp"
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>

View File

@@ -198,7 +198,7 @@ namespace hex::plugin::builtin::recent {
break;
}
if (!isProject)
ImGui::SetItemTooltip("%s", LangEntry(recentEntry.type).get().c_str());
ImGui::SetItemTooltip("%s", Lang(recentEntry.type).get().c_str());
// Detect right click on recent provider
std::string popupID = hex::format("RecentEntryMenu.{}", recentEntry.getHash());

View File

@@ -1,6 +1,6 @@
#include <hex/api/imhex_api.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/theme_manager.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/api/event_manager.hpp>
@@ -358,7 +358,7 @@ namespace hex::plugin::builtin {
std::vector<std::string> languageNames;
std::vector<nlohmann::json> languageCodes;
for (auto &[languageCode, languageName] : LangEntry::getSupportedLanguages()) {
for (auto &[languageCode, languageName] : LocalizationManager::getSupportedLanguages()) {
languageNames.emplace_back(languageName);
languageCodes.emplace_back(languageCode);
}
@@ -431,7 +431,7 @@ namespace hex::plugin::builtin {
EventManager::subscribe<EventImHexStartupFinished>([]{
for (const auto &[name, experiment] : ContentRegistry::Experiments::impl::getExperiments()) {
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.experiments", "", experiment.unlocalizedName, false)
.setTooltip(LangEntry(experiment.unlocalizedDescription))
.setTooltip(Lang(experiment.unlocalizedDescription))
.setChangedCallback([name](Widgets::Widget &widget) {
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);

View File

@@ -1,5 +1,5 @@
#include <hex/helpers/utils.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <content/tools_entries.hpp>

View File

@@ -1,6 +1,6 @@
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>

View File

@@ -1,4 +1,4 @@
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>

View File

@@ -4,7 +4,7 @@
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <algorithm>

View File

@@ -1,5 +1,5 @@
#include <hex/helpers/utils.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <llvm/Demangle/Demangle.h>

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/http_requests.hpp>
#include <hex/ui/view.hpp>

View File

@@ -1,7 +1,7 @@
#include <hex/helpers/http_requests.hpp>
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/fs.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <algorithm>
#include <random>

View File

@@ -1,5 +1,5 @@
#include <hex/helpers/fs.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <algorithm>
#include <random>

View File

@@ -6,7 +6,7 @@
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/literals.hpp>
#include <hex/helpers/fs.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <algorithm>
#include <random>

View File

@@ -1,5 +1,5 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/ui/imgui_imhex_extensions.h>

View File

@@ -1,4 +1,4 @@
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/imhex_api.hpp>
#include <hex/providers/provider.hpp>
#include <hex/ui/imgui_imhex_extensions.h>

View File

@@ -1,5 +1,5 @@
#include <hex/helpers/utils.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <content/tools_entries.hpp>

View File

@@ -1,5 +1,5 @@
#include <hex/helpers/fmt.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <imgui.h>

View File

@@ -1,6 +1,6 @@
#include <hex/helpers/http_requests.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>

View File

@@ -1,4 +1,4 @@
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/ui/imgui_imhex_extensions.h>
#include <wolv/net/socket_client.hpp>

View File

@@ -1,7 +1,7 @@
#include <hex/api/content_registry.hpp>
#include <hex/helpers/http_requests.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>

View File

@@ -1,6 +1,6 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <content/tools_entries.hpp>

View File

@@ -1,6 +1,6 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/imhex_api.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>
#include <hex/helpers/utils.hpp>
@@ -45,7 +45,7 @@ namespace hex::plugin::builtin {
// Task exception popup
for (const auto &task : TaskManager::getRunningTasks()) {
if (task->hadException()) {
PopupError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, LangEntry(task->getUnlocalizedName()), task->getExceptionMessage()));
PopupError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, Lang(task->getUnlocalizedName()), task->getExceptionMessage()));
task->clearException();
break;
}
@@ -98,7 +98,7 @@ namespace hex::plugin::builtin {
ImGui::InvisibleButton("FrontTask", ImVec2(widgetEnd.x - widgetStart.x, ImGui::GetCurrentWindow()->MenuBarHeight()));
ImGui::SetCursorPos(widgetEnd);
ImGuiExt::InfoTooltip(LangEntry(frontTask->getUnlocalizedName()).get().c_str());
ImGuiExt::InfoTooltip(Lang(frontTask->getUnlocalizedName()).get().c_str());
if (ImGui::BeginPopupContextItem("FrontTask", ImGuiPopupFlags_MouseButtonLeft)) {
for (const auto &task : tasks) {
@@ -106,7 +106,7 @@ namespace hex::plugin::builtin {
continue;
ImGui::PushID(&task);
ImGuiExt::TextFormatted("{}", LangEntry(task->getUnlocalizedName()));
ImGuiExt::TextFormatted("{}", Lang(task->getUnlocalizedName()));
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();

View File

@@ -487,7 +487,7 @@ namespace hex::plugin::builtin {
if (ImGui::BeginTabBar("about_tab_bar")) {
// Draw all tabs
for (const auto &[unlocalizedName, function] : Tabs) {
if (ImGui::BeginTabItem(LangEntry(unlocalizedName))) {
if (ImGui::BeginTabItem(Lang(unlocalizedName))) {
ImGui::NewLine();
if (ImGui::BeginChild(1)) {

View File

@@ -111,7 +111,7 @@ namespace hex::plugin::builtin {
ImGui::BeginDisabled(!achievement.isUnlocked());
// Draw achievement name
ImGui::TextUnformatted(LangEntry(achievement.getUnlocalizedName()));
ImGui::TextUnformatted(Lang(achievement.getUnlocalizedName()));
// Draw progress bar if achievement has progress
if (auto requiredProgress = achievement.getRequiredProgress(); requiredProgress > 1) {
@@ -125,7 +125,7 @@ namespace hex::plugin::builtin {
ImGui::Separator();
separator = true;
ImGuiExt::TextFormattedColored(ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_AchievementUnlocked), "[ {} ]", LangEntry("hex.builtin.view.achievements.click"));
ImGuiExt::TextFormattedColored(ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_AchievementUnlocked), "[ {} ]", Lang("hex.builtin.view.achievements.click"));
}
// Draw achievement description if available
@@ -135,7 +135,7 @@ namespace hex::plugin::builtin {
else
ImGui::NewLine();
ImGuiExt::TextFormattedWrapped("{}", LangEntry(desc));
ImGuiExt::TextFormattedWrapped("{}", Lang(desc));
}
ImGui::EndDisabled();
}
@@ -338,7 +338,7 @@ namespace hex::plugin::builtin {
}
// Draw the achievement category
if (ImGui::BeginTabItem(LangEntry(categoryName), nullptr, flags)) {
if (ImGui::BeginTabItem(Lang(categoryName), nullptr, flags)) {
auto drawList = ImGui::GetWindowDrawList();
const auto cursorPos = ImGui::GetCursorPos();
@@ -427,7 +427,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
// Draw name of achievement
ImGuiExt::TextFormattedWrapped("{}", LangEntry(this->m_currAchievement->getUnlocalizedName()));
ImGuiExt::TextFormattedWrapped("{}", Lang(this->m_currAchievement->getUnlocalizedName()));
// Handle clicking on the popup
if (ImGui::IsWindowHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {

View File

@@ -154,7 +154,7 @@ namespace hex::plugin::builtin {
if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) {
if (match != MatchType::PerfectMatch)
results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete });
results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete });
else {
auto matchedCommand = input.substr(command.length());
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
@@ -166,7 +166,7 @@ namespace hex::plugin::builtin {
if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) {
if (match != MatchType::PerfectMatch)
results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete });
results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete });
else {
auto matchedCommand = input.substr(command.length() + 1);
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });

View File

@@ -243,7 +243,7 @@ namespace hex::plugin::builtin {
ImGui::BeginDisabled(grayedOut);
// Render inspector row name
ImGui::TextUnformatted(LangEntry(unlocalizedName));
ImGui::TextUnformatted(Lang(unlocalizedName));
ImGui::TableNextColumn();
if (!editing) {

View File

@@ -82,7 +82,7 @@ namespace hex::plugin::builtin {
}
private:
std::string m_name = LangEntry(this->getUnlocalizedName());
std::string m_name = Lang(this->getUnlocalizedName());
int m_type = 0;
std::variant<i128, long double, std::vector<u8>> m_value;
@@ -152,7 +152,7 @@ namespace hex::plugin::builtin {
}
private:
std::string m_name = LangEntry(this->getUnlocalizedName());
std::string m_name = Lang(this->getUnlocalizedName());
int m_type = 0;
std::variant<i128, long double, std::vector<u8>> m_value;
@@ -300,7 +300,7 @@ namespace hex::plugin::builtin {
void load(const nlohmann::json &j) override {
this->m_dataProcessor->loadNodes(this->m_workspace, j.at("nodes"));
this->m_name = LangEntry(this->getUnlocalizedTitle()).get();
this->m_name = Lang(this->getUnlocalizedTitle()).get();
this->m_requiresAttributeUpdate = true;
}
@@ -579,7 +579,7 @@ namespace hex::plugin::builtin {
nlohmann::json nodeJson = nlohmann::json::parse(file.readString());
// Add the loaded node to the list of custom nodes
this->m_customNodes.push_back(CustomNode { LangEntry(nodeJson.at("name")), nodeJson });
this->m_customNodes.push_back(CustomNode { Lang(nodeJson.at("name")), nodeJson });
} catch (nlohmann::json::exception &e) {
log::warn("Failed to load custom node '{}': {}", entry.path().string(), e.what());
}
@@ -646,13 +646,13 @@ namespace hex::plugin::builtin {
ImGui::Separator();
} else if (unlocalizedCategory.empty()) {
// Draw the node if it has no category
if (ImGui::MenuItem(LangEntry(unlocalizedName))) {
if (ImGui::MenuItem(Lang(unlocalizedName))) {
node = function();
}
} else {
// Draw the node inside its sub menu if it has a category
if (ImGui::BeginMenu(LangEntry(unlocalizedCategory))) {
if (ImGui::MenuItem(LangEntry(unlocalizedName))) {
if (ImGui::BeginMenu(Lang(unlocalizedCategory))) {
if (ImGui::MenuItem(Lang(unlocalizedName))) {
node = function();
}
ImGui::EndMenu();
@@ -758,7 +758,7 @@ namespace hex::plugin::builtin {
// Draw the node's title bar
ImNodes::BeginNodeTitleBar();
{
ImGui::TextUnformatted(LangEntry(node.getUnlocalizedTitle()));
ImGui::TextUnformatted(Lang(node.getUnlocalizedTitle()));
}
ImNodes::EndNodeTitleBar();
@@ -799,7 +799,7 @@ namespace hex::plugin::builtin {
defaultValue.resize(sizeof(i128));
auto value = i64(*reinterpret_cast<i128*>(defaultValue.data()));
if (ImGui::InputScalar(LangEntry(attribute.getUnlocalizedName()), ImGuiDataType_S64, &value)) {
if (ImGui::InputScalar(Lang(attribute.getUnlocalizedName()), ImGuiDataType_S64, &value)) {
std::fill(defaultValue.begin(), defaultValue.end(), 0x00);
i128 writeValue = value;
@@ -809,7 +809,7 @@ namespace hex::plugin::builtin {
defaultValue.resize(sizeof(long double));
auto value = double(*reinterpret_cast<long double*>(defaultValue.data()));
if (ImGui::InputScalar(LangEntry(attribute.getUnlocalizedName()), ImGuiDataType_Double, &value)) {
if (ImGui::InputScalar(Lang(attribute.getUnlocalizedName()), ImGuiDataType_Double, &value)) {
std::fill(defaultValue.begin(), defaultValue.end(), 0x00);
long double writeValue = value;
@@ -819,13 +819,13 @@ namespace hex::plugin::builtin {
ImGui::PopItemWidth();
} else {
ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName()));
ImGui::TextUnformatted(Lang(attribute.getUnlocalizedName()));
}
ImNodes::EndInputAttribute();
} else if (attribute.getIOType() == dp::Attribute::IOType::Out) {
ImNodes::BeginOutputAttribute(attribute.getId(), ImNodesPinShape(pinShape + 1));
ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName()));
ImGui::TextUnformatted(Lang(attribute.getUnlocalizedName()));
ImNodes::EndOutputAttribute();
}
}

View File

@@ -135,10 +135,10 @@ namespace hex::plugin::builtin {
this->m_selectedHash = hashes.front().get();
}
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, this->m_selectedHash != nullptr ? LangEntry(this->m_selectedHash->getUnlocalizedName()) : "")) {
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, this->m_selectedHash != nullptr ? Lang(this->m_selectedHash->getUnlocalizedName()) : "")) {
for (const auto &hash : hashes) {
if (ImGui::Selectable(LangEntry(hash->getUnlocalizedName()), this->m_selectedHash == hash.get())) {
if (ImGui::Selectable(Lang(hash->getUnlocalizedName()), this->m_selectedHash == hash.get())) {
this->m_selectedHash = hash.get();
this->m_newHashName.clear();
}
@@ -148,7 +148,7 @@ namespace hex::plugin::builtin {
}
if (this->m_newHashName.empty() && this->m_selectedHash != nullptr)
this->m_newHashName = hex::format("{} {}", LangEntry(this->m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
this->m_newHashName = hex::format("{} {}", Lang(this->m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvail().x, 200_scaled), true)) {
if (this->m_selectedHash != nullptr) {
@@ -206,7 +206,7 @@ namespace hex::plugin::builtin {
ImGui::PopStyleColor(3);
ImGui::TableNextColumn();
ImGuiExt::TextFormatted("{}", LangEntry(function.getType()->getUnlocalizedName()));
ImGuiExt::TextFormatted("{}", Lang(function.getType()->getUnlocalizedName()));
ImGui::TableNextColumn();
std::string result;

View File

@@ -1168,7 +1168,7 @@ namespace hex::plugin::builtin {
bool enabled = ImHexApi::HexEditor::isSelectionValid();
for (const auto &[unlocalizedName, callback] : ContentRegistry::DataFormatter::impl::getEntries()) {
if (ImGui::MenuItem(LangEntry(unlocalizedName), nullptr, false, enabled)) {
if (ImGui::MenuItem(Lang(unlocalizedName), nullptr, false, enabled)) {
ImGui::SetClipboardText(
callback(
provider,

View File

@@ -46,12 +46,12 @@ namespace hex::plugin::builtin {
continue;
// For each category, create a new tab
if (ImGui::BeginTabItem(LangEntry(category.unlocalizedName))) {
if (ImGui::BeginTabItem(Lang(category.unlocalizedName))) {
if (ImGui::BeginChild("scrolling")) {
// Draw the category description
if (!category.unlocalizedDescription.empty()) {
ImGuiExt::TextFormattedWrapped("{}", LangEntry(category.unlocalizedDescription));
ImGuiExt::TextFormattedWrapped("{}", Lang(category.unlocalizedDescription));
ImGui::NewLine();
}
@@ -62,17 +62,17 @@ namespace hex::plugin::builtin {
if (subCategory.entries.empty())
continue;
ImGuiExt::BeginSubWindow(LangEntry(subCategory.unlocalizedName));
ImGuiExt::BeginSubWindow(Lang(subCategory.unlocalizedName));
{
for (auto &setting : subCategory.entries) {
ImGui::BeginDisabled(!setting.widget->isEnabled());
ImGui::PushItemWidth(-200_scaled);
bool settingChanged = setting.widget->draw(LangEntry(setting.unlocalizedName));
bool settingChanged = setting.widget->draw(Lang(setting.unlocalizedName));
ImGui::PopItemWidth();
ImGui::EndDisabled();
if (auto tooltip = setting.widget->getTooltip(); tooltip.has_value() && ImGui::IsItemHovered())
ImGuiExt::InfoTooltip(LangEntry(tooltip.value()));
ImGuiExt::InfoTooltip(Lang(tooltip.value()));
auto &widget = setting.widget;

View File

@@ -82,7 +82,7 @@ namespace hex::plugin::builtin {
}
void ViewStore::drawTab(hex::plugin::builtin::StoreCategory &category) {
if (ImGui::BeginTabItem(LangEntry(category.unlocalizedName))) {
if (ImGui::BeginTabItem(Lang(category.unlocalizedName))) {
if (ImGui::BeginTable("##pattern_language", 4, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("hex.builtin.view.store.row.name"_lang, ImGuiTableColumnFlags_WidthFixed);

View File

@@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
if (detached) continue;
// Draw the tool
if (ImGui::CollapsingHeader(LangEntry(name))) {
if (ImGui::CollapsingHeader(Lang(name))) {
function();
ImGui::NewLine();
} else {

View File

@@ -2,7 +2,7 @@
#include <hex/helpers/http_requests.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/plugin_manager.hpp>
#include <hex/api/theme_manager.hpp>
#include <hex/api/layout_manager.hpp>
@@ -196,7 +196,7 @@ namespace hex::plugin::builtin {
ImGuiExt::BeginSubWindow("hex.builtin.welcome.start.open_other"_lang, ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_AutoResizeX);
for (const auto &unlocalizedProviderName : ContentRegistry::Provider::impl::getEntries()) {
if (ImGuiExt::Hyperlink(LangEntry(unlocalizedProviderName))) {
if (ImGuiExt::Hyperlink(Lang(unlocalizedProviderName))) {
ImHexApi::Provider::createProvider(unlocalizedProviderName);
otherProvidersVisible = false;
}
@@ -454,8 +454,8 @@ namespace hex::plugin::builtin {
{
auto language = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "en-US").get<std::string>();
if (language != LangEntry::getSelectedLanguage())
LangEntry::loadLanguage(language);
if (language != LocalizationManager::getSelectedLanguage())
LocalizationManager::loadLanguage(language);
}
{

View File

@@ -1,7 +1,7 @@
#include <ui/hex_editor.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/encoding_file.hpp>
#include <hex/helpers/utils.hpp>
@@ -816,10 +816,10 @@ namespace hex::plugin::builtin::ui {
ImGui::SameLine(0, 2_scaled);
ImGui::PushItemWidth((ImGui::GetContentRegionAvail().x / 3) * 2);
if (ImGui::BeginCombo("##visualizer", LangEntry(this->m_currDataVisualizer->getUnlocalizedName()))) {
if (ImGui::BeginCombo("##visualizer", Lang(this->m_currDataVisualizer->getUnlocalizedName()))) {
for (const auto &visualizer : visualizers) {
if (ImGui::Selectable(LangEntry(visualizer->getUnlocalizedName()))) {
if (ImGui::Selectable(Lang(visualizer->getUnlocalizedName()))) {
this->m_currDataVisualizer = visualizer;
this->m_encodingLineStartAddresses.clear();

View File

@@ -21,7 +21,7 @@
#include <hex/api/imhex_api.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp>
#include <content/helpers/math_evaluator.hpp>

View File

@@ -1,7 +1,7 @@
#include <hex/plugin.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/logger.hpp>
#include <hex/ui/imgui_imhex_extensions.h>

View File

@@ -2,7 +2,7 @@
#include <hex/api/imhex_api.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/popup.hpp>

View File

@@ -1,7 +1,7 @@
#pragma once
#include <hex/providers/provider.hpp>
#include <hex/api/localization.hpp>
#include <hex/api/localization_manager.hpp>
#include <windows.h>