lang: Added German translation, improved language handling

This commit is contained in:
WerWolv
2021-03-03 22:26:17 +01:00
parent 188723e888
commit 4a908a314f
23 changed files with 539 additions and 54 deletions

View File

@@ -7,7 +7,7 @@
namespace hex {
ViewBookmarks::ViewBookmarks() : View("hex.view.bookmarks.name"_lang) {
ViewBookmarks::ViewBookmarks() : View("hex.view.bookmarks.name") {
View::subscribeEvent(Events::AddBookmark, [](auto userData) {
auto bookmark = std::any_cast<ImHexApi::Bookmarks::Entry>(userData);
bookmark.comment.resize(0xF'FFFF);
@@ -44,7 +44,7 @@ namespace hex {
}
void ViewBookmarks::drawContent() {
if (ImGui::Begin("hex.view.bookmarks.name"_lang, &this->getWindowOpenState())) {
if (ImGui::Begin(View::toWindowName("hex.view.bookmarks.name").c_str(), &this->getWindowOpenState())) {
if (ImGui::BeginChild("##scrolling")) {
auto &bookmarks = ImHexApi::Bookmarks::getEntries();

View File

@@ -4,7 +4,7 @@
namespace hex {
ViewCommandPalette::ViewCommandPalette() : View("hex.view.command_palette.name"_lang) {
ViewCommandPalette::ViewCommandPalette() : View("hex.view.command_palette.name") {
this->m_commandBuffer.resize(1024, 0x00);
}

View File

@@ -10,7 +10,7 @@ namespace hex {
using NumberDisplayStyle = ContentRegistry::DataInspector::NumberDisplayStyle;
ViewDataInspector::ViewDataInspector() : View("hex.view.data_inspector.name"_lang) {
ViewDataInspector::ViewDataInspector() : View("hex.view.data_inspector.name") {
View::subscribeEvent(Events::RegionSelected, [this](auto userData) {
auto region = std::any_cast<Region>(userData);
@@ -55,7 +55,7 @@ namespace hex {
}
if (ImGui::Begin("hex.view.data_inspector.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.data_inspector.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {

View File

@@ -6,7 +6,7 @@
namespace hex {
ViewDataProcessor::ViewDataProcessor() : View("hex.view.data_processor.name"_lang) {
ViewDataProcessor::ViewDataProcessor() : View("hex.view.data_processor.name") {
imnodes::Initialize();
imnodes::PushAttributeFlag(imnodes::AttributeFlags_EnableLinkDetachWithDragClick);
imnodes::PushAttributeFlag(imnodes::AttributeFlags_EnableLinkCreationOnSnap);
@@ -128,7 +128,7 @@ namespace hex {
}
void ViewDataProcessor::drawContent() {
if (ImGui::Begin("hex.view.data_processor.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.data_processor.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::IsMouseReleased(ImGuiMouseButton_Right) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) {
imnodes::ClearNodeSelection();

View File

@@ -12,7 +12,7 @@ using namespace std::literals::string_literals;
namespace hex {
ViewDisassembler::ViewDisassembler() : View("hex.view.disassembler.name"_lang) {
ViewDisassembler::ViewDisassembler() : View("hex.view.disassembler.name") {
View::subscribeEvent(Events::DataChanged, [this](auto){
this->disassemble();
});
@@ -100,7 +100,7 @@ namespace hex {
void ViewDisassembler::drawContent() {
if (ImGui::Begin("hex.view.disassembler.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.disassembler.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {

View File

@@ -9,7 +9,7 @@
namespace hex {
ViewHashes::ViewHashes() : View("hex.view.hashes.name"_lang) {
ViewHashes::ViewHashes() : View("hex.view.hashes.name") {
View::subscribeEvent(Events::DataChanged, [this](auto) {
this->m_shouldInvalidate = true;
});
@@ -38,7 +38,7 @@ namespace hex {
}
void ViewHashes::drawContent() {
if (ImGui::Begin("hex.view.hashes.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.hashes.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
auto provider = SharedData::currentProvider;

View File

@@ -4,7 +4,7 @@
namespace hex {
ViewHelp::ViewHelp() : View("hex.view.help.about.name"_lang) {
ViewHelp::ViewHelp() : View("hex.view.help.about.name") {
}
ViewHelp::~ViewHelp() {
@@ -29,7 +29,7 @@ namespace hex {
void ViewHelp::drawAboutPopup() {
if (ImGui::BeginPopupModal("hex.view.help.about.name"_lang, &this->m_aboutWindowOpen, ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginPopupModal(View::toWindowName("hex.view.about.name").c_str(), &this->m_aboutWindowOpen, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("ImHex Hex Editor v%s by WerWolv -", IMHEX_VERSION);
#if defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH)
ImGui::SameLine();
@@ -97,7 +97,7 @@ namespace hex {
if (!this->m_patternHelpWindowOpen) return;
ImGui::SetNextWindowSizeConstraints(ImVec2(450, 300), ImVec2(2000, 1000));
if (ImGui::Begin("Pattern Language Cheat Sheet", &this->m_patternHelpWindowOpen)) {
if (ImGui::Begin(View::toWindowName("hex.view.help.pattern_cheat_sheet").c_str(), &this->m_patternHelpWindowOpen)) {
ImGui::Text("ImHex Pattern Language Cheat Sheet");
ImGui::Separator();
ImGui::NewLine();
@@ -239,7 +239,7 @@ namespace hex {
if (!this->m_mathHelpWindowOpen) return;
ImGui::SetNextWindowSizeConstraints(ImVec2(450, 300), ImVec2(2000, 1000));
if (ImGui::Begin("Calculator Cheat Sheet", &this->m_mathHelpWindowOpen)) {
if (ImGui::Begin(View::toWindowName("hex.view.help.calc_cheat_sheet").c_str(), &this->m_mathHelpWindowOpen)) {
ImGui::Text("ImHex Math Evaluator Cheat Sheet");
ImGui::Separator();
ImGui::NewLine();
@@ -322,7 +322,7 @@ namespace hex {
void ViewHelp::drawMenu() {
if (ImGui::BeginMenu("hex.menu.help"_lang)) {
if (ImGui::MenuItem("hex.view.help.about.name"_lang, "")) {
View::doLater([] { ImGui::OpenPopup("hex.view.help.about.name"_lang); });
View::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.view.about.name").c_str()); });
this->m_aboutWindowOpen = true;
this->getWindowOpenState() = true;
}

View File

@@ -159,7 +159,7 @@ namespace hex {
if (ProjectFile::hasUnsavedChanges()) {
glfwSetWindowShouldClose(window, GLFW_FALSE);
View::doLater([] { ImGui::OpenPopup("hex.view.hexeditor.save_changes"_lang); });
View::doLater([] { ImGui::OpenPopup("hex.view.hexeditor.save_changes.title"_lang); });
}
});
@@ -195,10 +195,10 @@ namespace hex {
size_t dataSize = (provider == nullptr || !provider->isReadable()) ? 0x00 : provider->getSize();
this->m_memoryEditor.DrawWindow("hex.view.hexeditor.name"_lang, &this->getWindowOpenState(), this, dataSize, dataSize == 0 ? 0x00 : provider->getBaseAddress());
this->m_memoryEditor.DrawWindow(View::toWindowName("hex.view.hexeditor.name").c_str(), &this->getWindowOpenState(), this, dataSize, dataSize == 0 ? 0x00 : provider->getBaseAddress());
if (dataSize != 0x00) {
if (ImGui::Begin("hex.view.hexeditor.name"_lang)) {
if (ImGui::Begin(View::toWindowName("hex.view.hexeditor.name").c_str())) {
if (ImGui::IsMouseReleased(ImGuiMouseButton_Right) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows))
ImGui::OpenPopup("hex.menu.edit"_lang);
@@ -275,7 +275,7 @@ namespace hex {
ImGui::TextUnformatted("hex.view.hexeditor.save_changes.desc"_lang);
ImGui::NewLine();
confirmButtons("Yes", "No", [] { View::postEvent(Events::CloseImHex); }, [] { ImGui::CloseCurrentPopup(); });
confirmButtons("hex.common.yes"_lang, "hex.common.no"_lang, [] { View::postEvent(Events::CloseImHex); }, [] { ImGui::CloseCurrentPopup(); });
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
ImGui::CloseCurrentPopup();

View File

@@ -18,7 +18,7 @@
namespace hex {
ViewInformation::ViewInformation() : View("hex.view.information.name"_lang) {
ViewInformation::ViewInformation() : View("hex.view.information.name") {
View::subscribeEvent(Events::DataChanged, [this](auto) {
this->m_dataValid = false;
this->m_highestBlockEntropy = 0;
@@ -133,7 +133,7 @@ namespace hex {
}
void ViewInformation::drawContent() {
if (ImGui::Begin("hex.view.information.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.information.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
auto provider = SharedData::currentProvider;

View File

@@ -11,7 +11,7 @@ using namespace std::literals::string_literals;
namespace hex {
ViewPatches::ViewPatches() : View("hex.view.patches.name"_lang) {
ViewPatches::ViewPatches() : View("hex.view.patches.name") {
View::subscribeEvent(Events::ProjectFileStore, [](auto) {
auto provider = SharedData::currentProvider;
if (provider != nullptr)
@@ -31,7 +31,7 @@ namespace hex {
}
void ViewPatches::drawContent() {
if (ImGui::Begin("hex.view.patches.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.patches.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {

View File

@@ -76,7 +76,7 @@ namespace hex {
}
ViewPattern::ViewPattern(std::vector<lang::PatternData*> &patternData) : View("hex.view.pattern.name"_lang), m_patternData(patternData) {
ViewPattern::ViewPattern(std::vector<lang::PatternData*> &patternData) : View("hex.view.pattern.name"), m_patternData(patternData) {
this->m_patternLanguageRuntime = new lang::PatternLanguage();
this->m_textEditor.SetLanguageDefinition(PatternLanguage());
@@ -220,7 +220,7 @@ namespace hex {
}
void ViewPattern::drawContent() {
if (ImGui::Begin("hex.view.pattern.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_None | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
if (ImGui::Begin(View::toWindowName("hex.view.pattern.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_None | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isAvailable()) {

View File

@@ -6,7 +6,7 @@
namespace hex {
ViewPatternData::ViewPatternData(std::vector<lang::PatternData*> &patternData)
: View("hex.view.pattern_data.name"_lang), m_patternData(patternData) {
: View("hex.view.pattern_data.name"), m_patternData(patternData) {
this->subscribeEvent(Events::PatternChanged, [this](auto data) {
this->m_sortedPatternData.clear();
@@ -49,7 +49,7 @@ namespace hex {
}
void ViewPatternData::drawContent() {
if (ImGui::Begin("hex.view.pattern_data.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.pattern_data.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {

View File

@@ -4,7 +4,7 @@
namespace hex {
ViewSettings::ViewSettings() : View("hex.view.settings.name"_lang) {
ViewSettings::ViewSettings() : View("hex.view.settings.name") {
View::subscribeEvent(Events::OpenWindow, [this](auto name) {
if (std::any_cast<const char*>(name) == std::string("hex.view.settings.name")) {
View::doLater([]{ ImGui::OpenPopup("hex.view.settings.name"_lang); });
@@ -21,7 +21,7 @@ namespace hex {
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX));
if (ImGui::BeginPopupModal("hex.view.settings.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginPopupModal(View::toWindowName("hex.view.settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) {
for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) {
ImGui::TextUnformatted(LangEntry(category));
ImGui::Separator();
@@ -40,7 +40,7 @@ namespace hex {
void ViewSettings::drawMenu() {
if (ImGui::BeginMenu("hex.menu.help"_lang)) {
if (ImGui::MenuItem("hex.view.settings.name"_lang)) {
View::doLater([]{ ImGui::OpenPopup("hex.view.settings.name"_lang); });
View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.view.settings.name").c_str()); });
this->getWindowOpenState() = true;
}
ImGui::EndMenu();

View File

@@ -13,7 +13,7 @@ using namespace std::literals::string_literals;
namespace hex {
ViewStrings::ViewStrings() : View("hex.view.strings.name"_lang) {
ViewStrings::ViewStrings() : View("hex.view.strings.name") {
View::subscribeEvent(Events::DataChanged, [this](auto){
this->m_foundStrings.clear();
});
@@ -89,7 +89,7 @@ namespace hex {
auto provider = SharedData::currentProvider;
if (ImGui::Begin("hex.view.strings.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.strings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (provider != nullptr && provider->isReadable()) {
ImGui::Disabled([this]{
if (ImGui::InputInt("hex.view.strings.min_length"_lang, &this->m_minimumLength, 1, 0))

View File

@@ -4,12 +4,12 @@
namespace hex {
ViewTools::ViewTools() : View("hex.view.tools.name"_lang) { }
ViewTools::ViewTools() : View("hex.view.tools.name") { }
ViewTools::~ViewTools() { }
void ViewTools::drawContent() {
if (ImGui::Begin("hex.view.tools.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.tools.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
for (const auto& [name, function] : ContentRegistry::Tools::getEntries()) {
if (ImGui::CollapsingHeader(LangEntry(name))) {
function();

View File

@@ -10,7 +10,7 @@
namespace hex {
ViewYara::ViewYara() : View("hex.view.yara.name"_lang) {
ViewYara::ViewYara() : View("hex.view.yara.name") {
yr_initialize();
this->reloadRules();
@@ -21,7 +21,7 @@ namespace hex {
}
void ViewYara::drawContent() {
if (ImGui::Begin("hex.view.yara.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin(View::toWindowName("hex.view.yara.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (!this->m_matching && !this->m_errorMessage.empty()) {
View::showErrorPopup("hex.view.yara.error"_lang + this->m_errorMessage.data());
@@ -32,7 +32,7 @@ namespace hex {
ImGui::Separator();
if (this->m_rules.empty()) {
ImGui::TextColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "No YARA rules found. Put them in the 'yara' folder next to the ImHex executable");
ImGui::TextColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "%s", static_cast<const char*>("hex.view.yara.no_rules"_lang));
if (ImGui::Button("hex.view.yara.reload"_lang)) this->reloadRules();
} else {

View File

@@ -32,7 +32,7 @@ namespace hex {
void ImHexSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler *handler, void *, const char* line) {
for (auto &view : ContentRegistry::Views::getEntries()) {
std::string format = std::string(view->getName()) + "=%d";
std::string format = std::string(view->getUnlocalizedName()) + "=%d";
sscanf(line, format.c_str(), &view->getWindowOpenState());
}
}
@@ -293,7 +293,7 @@ namespace hex {
if (ImGui::BeginMenu("hex.menu.view"_lang)) {
for (auto &view : ContentRegistry::Views::getEntries()) {
if (view->hasViewMenuItemEntry())
ImGui::MenuItem((std::string(view->getName()) + " " + "hex.menu.view"_lang).c_str(), "", &view->getWindowOpenState());
ImGui::MenuItem((LangEntry(view->getUnlocalizedName()) + " " + "hex.menu.view"_lang).c_str(), "", &view->getWindowOpenState());
}
ImGui::EndMenu();
}
@@ -512,11 +512,11 @@ namespace hex {
ImGui::DockBuilderSplitNode(splitWindowId, ImGuiDir_Right, 0.3, &inspectorId, &hexEditorId);
for (auto &view : ContentRegistry::Views::getEntries())
ImGui::DockBuilderDockWindow(view->getUnlocalizedName().data(), utilitiesId);
ImGui::DockBuilderDockWindow(view->getName().data(), utilitiesId);
ImGui::DockBuilderDockWindow("hex.view.hexeditor.name"_lang, hexEditorId);
ImGui::DockBuilderDockWindow("hex.view.data_inspector.name"_lang, inspectorId);
ImGui::DockBuilderDockWindow("hex.view.pattern_data.name"_lang, patternDataId);
ImGui::DockBuilderDockWindow("hex.view.hexeditor.name", hexEditorId);
ImGui::DockBuilderDockWindow("hex.view.data_inspector.name", inspectorId);
ImGui::DockBuilderDockWindow("hex.view.pattern_data.name", patternDataId);
ImGui::DockBuilderFinish(dockId);
}