diff --git a/plugins/windows/CMakeLists.txt b/plugins/windows/CMakeLists.txt index 75b7f708e..b8750fda8 100644 --- a/plugins/windows/CMakeLists.txt +++ b/plugins/windows/CMakeLists.txt @@ -9,6 +9,8 @@ if (WIN32) source/plugin_windows.cpp source/views/view_tty_console.cpp + + source/lang/en_US.cpp ) # Add additional include directories here # diff --git a/plugins/windows/include/views/view_tty_console.hpp b/plugins/windows/include/views/view_tty_console.hpp index e6f5a018c..233898833 100644 --- a/plugins/windows/include/views/view_tty_console.hpp +++ b/plugins/windows/include/views/view_tty_console.hpp @@ -8,7 +8,7 @@ #include #include -namespace hex { +namespace hex::plugin::windows { namespace prv { class Provider; } diff --git a/plugins/windows/source/lang/en_US.cpp b/plugins/windows/source/lang/en_US.cpp new file mode 100644 index 000000000..dccc976c2 --- /dev/null +++ b/plugins/windows/source/lang/en_US.cpp @@ -0,0 +1,29 @@ +#include + +namespace hex::plugin::windows { + + void registerLanguageEnUS() { + ContentRegistry::Language::addLocalizations("en-US", { + { "hex.windows.view.tty_console.name", "TTY Console" }, + { "hex.windows.view.tty_console.config", "Configuration"}, + { "hex.windows.view.tty_console.port", "Port" }, + { "hex.windows.view.tty_console.reload", "Reload" }, + { "hex.windows.view.tty_console.baud", "Baud rate" }, + { "hex.windows.view.tty_console.num_bits", "Data bits" }, + { "hex.windows.view.tty_console.stop_bits", "Stop bits" }, + { "hex.windows.view.tty_console.parity_bits", "Parity bit" }, + { "hex.windows.view.tty_console.cts", "Use CTS flow control" }, + { "hex.windows.view.tty_console.connect", "Connect" }, + { "hex.windows.view.tty_console.disconnect", "Disconnect" }, + { "hex.windows.view.tty_console.connect_error", "Failed to connect to COM Port!" }, + { "hex.windows.view.tty_console.clear", "Clear" }, + { "hex.windows.view.tty_console.auto_scroll", "Auto scroll" }, + { "hex.windows.view.tty_console.console", "Console" }, + { "hex.windows.view.tty_console.send_etx", "Send ETX" }, + { "hex.windows.view.tty_console.send_eot", "Send EOT" }, + { "hex.windows.view.tty_console.send_sub", "Send SUB" } + + }); + } + +} \ No newline at end of file diff --git a/plugins/windows/source/plugin_windows.cpp b/plugins/windows/source/plugin_windows.cpp index b929fcc8c..f0f19a82f 100644 --- a/plugins/windows/source/plugin_windows.cpp +++ b/plugins/windows/source/plugin_windows.cpp @@ -4,8 +4,19 @@ #include "views/view_tty_console.hpp" -IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") { - ContentRegistry::Views::add(); +namespace hex::plugin::windows { + + void registerLanguageEnUS(); + +} + + +IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") { + using namespace hex::plugin::windows; + + ContentRegistry::Views::add(); + + registerLanguageEnUS(); } diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index 2f0ffe6ff..600e98a65 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -3,7 +3,7 @@ #include #include -namespace hex { +namespace hex::plugin::windows { ViewTTYConsole::ViewTTYConsole() : View("hex.windows.view.tty_console.name") { this->m_comPorts = getAvailablePorts(); @@ -19,7 +19,7 @@ namespace hex { void ViewTTYConsole::drawContent() { if (ImGui::Begin(View::toWindowName("hex.windows.view.tty_console.name").c_str(), &this->getWindowOpenState())) { - ImGui::TextUnformatted("Configuration"); + ImGui::TextUnformatted("hex.windows.view.tty_console.config"_lang); ImGui::Separator(); bool connected = this->m_portHandle != INVALID_HANDLE_VALUE; @@ -27,7 +27,7 @@ namespace hex { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, connected); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, connected ? 0.5F : 1.0F); - ImGui::Combo("Port", &this->m_selectedPort, [](void* data, int idx, const char** out_text) -> bool { + ImGui::Combo("hex.windows.view.tty_console.port"_lang, &this->m_selectedPort, [](void* data, int idx, const char** out_text) -> bool { auto &ports = *static_cast>*>(data); *out_text = ports[idx].first.c_str(); @@ -35,30 +35,30 @@ namespace hex { }, &this->m_comPorts, this->m_comPorts.size()); ImGui::SameLine(); - if (ImGui::Button("Reload")) + if (ImGui::Button("hex.windows.view.tty_console.reload"_lang)) this->m_comPorts = getAvailablePorts(); - ImGui::Combo("Baud rate", &this->m_selectedBaudRate, [](void* data, int idx, const char** out_text) -> bool { + ImGui::Combo("hex.windows.view.tty_console.baud"_lang, &this->m_selectedBaudRate, [](void* data, int idx, const char** out_text) -> bool { *out_text = ViewTTYConsole::BaudRates[idx]; return true; }, nullptr, ViewTTYConsole::BaudRates.size()); - ImGui::Combo("Data bits", &this->m_selectedNumBits, [](void* data, int idx, const char** out_text) -> bool { + ImGui::Combo("hex.windows.view.tty_console.num_bits"_lang, &this->m_selectedNumBits, [](void* data, int idx, const char** out_text) -> bool { *out_text = ViewTTYConsole::NumBits[idx]; return true; }, nullptr, ViewTTYConsole::NumBits.size()); - ImGui::Combo("Stop bits", &this->m_selectedStopBits, [](void* data, int idx, const char** out_text) -> bool { + ImGui::Combo("hex.windows.view.tty_console.stop_bits"_lang, &this->m_selectedStopBits, [](void* data, int idx, const char** out_text) -> bool { *out_text = ViewTTYConsole::StopBits[idx]; return true; }, nullptr, ViewTTYConsole::StopBits.size()); - ImGui::Combo("Parity bit", &this->m_selectedParityBits, [](void* data, int idx, const char** out_text) -> bool { + ImGui::Combo("hex.windows.view.tty_console.parity_bits"_lang, &this->m_selectedParityBits, [](void* data, int idx, const char** out_text) -> bool { *out_text = ViewTTYConsole::ParityBits[idx]; return true; }, nullptr, ViewTTYConsole::ParityBits.size()); - ImGui::Checkbox("CTS Flow control", &this->m_hasCTSFlowControl); + ImGui::Checkbox("hex.windows.view.tty_console.cts"_lang, &this->m_hasCTSFlowControl); ImGui::PopStyleVar(); ImGui::PopItemFlag(); @@ -66,17 +66,17 @@ namespace hex { ImGui::NewLine(); if (this->m_portHandle == INVALID_HANDLE_VALUE) { - if (ImGui::Button("Connect")) + if (ImGui::Button("hex.windows.view.tty_console.connect"_lang)) if (!this->connect()) - log::error("Connect error"); + View::showErrorPopup("hex.windows.view.tty_console.connect_error"_lang); } else { - if (ImGui::Button("Disconnect")) + if (ImGui::Button("hex.windows.view.tty_console.disconnect")) this->disconnect(); } ImGui::NewLine(); - if (ImGui::Button("Clear")) { + if (ImGui::Button("hex.windows.view.tty_console.clear"_lang)) { std::scoped_lock lock(this->m_receiveBufferMutex); this->m_receiveDataBuffer.clear(); @@ -85,10 +85,10 @@ namespace hex { ImGui::SameLine(); - ImGui::Checkbox("Auto Scroll", &this->m_shouldAutoScroll); + ImGui::Checkbox("hex.windows.view.tty_console.auto_scroll"_lang, &this->m_shouldAutoScroll); ImGui::NewLine(); - ImGui::TextUnformatted("Console"); + ImGui::TextUnformatted("hex.windows.view.tty_console.console"_lang); ImGui::Separator(); auto consoleSize = ImGui::GetContentRegionAvail(); @@ -136,15 +136,15 @@ namespace hex { if (ImGui::BeginPopup("ConsoleMenu")) { static std::vector buffer(2, 0x00); - if (ImGui::MenuItem("Send ETX", "CTRL + C")) { + if (ImGui::MenuItem("hex.windows.view.tty_console.send_etx"_lang, "CTRL + C")) { buffer[0] = 0x03; this->transmitData(buffer); } - if (ImGui::MenuItem("Send EOT", "CTRL + D")) { + if (ImGui::MenuItem("hex.windows.view.tty_console.send_eot"_lang, "CTRL + D")) { buffer[0] = 0x04; this->transmitData(buffer); } - if (ImGui::MenuItem("Send SUB", "CTRL + Z")) { + if (ImGui::MenuItem("hex.windows.view.tty_console.send_sub"_lang, "CTRL + Z")) { buffer[0] = 0x1A; this->transmitData(buffer); }