aboutsummaryrefslogtreecommitdiff
path: root/core/src/UI/UI_DatabaseView.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-06-11 13:35:35 -0700
committerrtk0c <[email protected]>2021-06-11 13:35:35 -0700
commit8f7daa9bd100345d7e23639604c9a3a50ce6448b (patch)
tree4b0c4934f29dfca933e1e955a8af2e61c2719ca1 /core/src/UI/UI_DatabaseView.cpp
parent222cfec6ad882196d8927f73e30d905daae89556 (diff)
Convert runtime-loaded l10n to string literals chosen at compile time
Diffstat (limited to 'core/src/UI/UI_DatabaseView.cpp')
-rw-r--r--core/src/UI/UI_DatabaseView.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/core/src/UI/UI_DatabaseView.cpp b/core/src/UI/UI_DatabaseView.cpp
index bd0efa5..caf81d8 100644
--- a/core/src/UI/UI_DatabaseView.cpp
+++ b/core/src/UI/UI_DatabaseView.cpp
@@ -3,7 +3,7 @@
#include "Model/Filter.hpp"
#include "Model/GlobalStates.hpp"
#include "Model/Project.hpp"
-#include "UI/Localization.hpp"
+#include "Utils/I18n.hpp"
#include "Utils/ScopeGuard.hpp"
#include "Utils/Time.hpp"
@@ -210,7 +210,6 @@ public:
void Display()
{
bool dummy = true;
- auto ls = LocaleStrings::Instance.get();
if (ImGui::Button(ICON_FA_ARROW_LEFT, mCurrentPageNumber == 0)) {
SetPage(mCurrentPageNumber - 1);
@@ -226,7 +225,7 @@ public:
}
ImGui::SameLine();
- if (ImGui::Button(ls->Edit.Get(), mSelectRow == -1)) {
+ if (ImGui::Button(ICON_FA_EDIT " " I18N_TEXT("Edit", L10N_EDIT), mSelectRow == -1)) {
ImGui::OpenPopup(mEditDialogTitle);
}
if (ImGui::BeginPopupModal(mEditDialogTitle, &dummy, ImGuiWindowFlags_AlwaysAutoResize)) {
@@ -237,12 +236,12 @@ public:
}
ImGui::SameLine();
- if (ImGui::Button(ls->Add.Get())) {
+ if (ImGui::Button(ICON_FA_PLUS " " I18N_TEXT("Add", L10N_ADD))) {
// TODO
}
ImGui::SameLine();
- if (ImGui::Button(ls->Delete.Get(), mSelectRow == -1)) {
+ if (ImGui::Button(ICON_FA_TRASH " " I18N_TEXT("Delete", L10N_DELETE), mSelectRow == -1)) {
// TODO
}
@@ -252,7 +251,7 @@ public:
ImGui::NextColumn();
if (mSelectRow == -1) {
- ImGui::TextWrapped("%s", ls->SelectOrderToShowAssociatedDeliveries.Get());
+ ImGui::TextWrapped("%s", I18N_TEXT("Select an entry to show associated deliveries", L10N_DATABASE_MESSAGE_NO_ORDER_SELECTED));
} else {
DisplayDeliveriesTable();
}
@@ -284,15 +283,14 @@ private:
void DisplayMainTable()
{
- auto ls = LocaleStrings::Instance.get();
if (ImGui::BeginTable("DataTable", kColumnCount, ImGuiTableFlags_Borders | ImGuiTableFlags_ScrollX)) {
- if constexpr (kHasCustomer) ImGui::TableSetupColumn(ls->DatabaseCustomerColumn.Get());
- if constexpr (kHasDeadline) ImGui::TableSetupColumn(ls->DatabaseDeadlineColumn.Get());
- if constexpr (kHasFactory) ImGui::TableSetupColumn(ls->DatabaseFactoryColumn.Get());
- if constexpr (kHasOrderTime) ImGui::TableSetupColumn(ls->DatabaseOrderTimeColumn.Get());
- if constexpr (kHasCompletionTime) ImGui::TableSetupColumn(ls->DatabaseCompletionTimeColumn.Get());
- if constexpr (kHasItems) ImGui::TableSetupColumn(ls->DatabaseItemsColumn.Get());
+ if constexpr (kHasCustomer) ImGui::TableSetupColumn(I18N_TEXT("Customer", L10N_DATABASE_COLUMN_CUSTOMER));
+ if constexpr (kHasDeadline) ImGui::TableSetupColumn(I18N_TEXT("Deadline", L10N_DATABASE_COLUMN_DEADLINE));
+ if constexpr (kHasFactory) ImGui::TableSetupColumn(I18N_TEXT("Factory", L10N_DATABASE_COLUMN_FACTORY));
+ if constexpr (kHasOrderTime) ImGui::TableSetupColumn(I18N_TEXT("Order time", L10N_DATABASE_COLUMN_ORDER_TIME));
+ if constexpr (kHasCompletionTime) ImGui::TableSetupColumn(I18N_TEXT("Completion time", L10N_DATABASE_COLUMN_COMPLETION_TIME));
+ if constexpr (kHasItems) ImGui::TableSetupColumn(I18N_TEXT("Items", L10N_DATABASE_COLUMN_ITEMS));
ImGui::TableHeadersRow();
if (mActiveFilter) {
@@ -327,8 +325,6 @@ private:
void DisplayEntry(T& entry, int rowIdx, int entryIdx)
{
- auto ls = LocaleStrings::Instance.get();
-
ImGui::PushID(rowIdx);
ImGui::TableNextRow();
@@ -359,7 +355,7 @@ private:
if constexpr (kHasCompletionTime) {
ImGui::TableNextColumn();
if (entry.DeliveryTime.empty()) {
- ImGui::TextUnformatted(ls->NotDelivered.Get());
+ ImGui::TextUnformatted(I18N_TEXT("Not delivered", L10N_DATABASE_MESSAGE_NOT_DELIVERED));
} else {
ImGui::TextUnformatted(entry.DeliveryTime.c_str());
}
@@ -383,12 +379,11 @@ private:
void DisplayDeliveriesTable()
{
- auto ls = LocaleStrings::Instance.get();
if (ImGui::BeginTable("DeliveriesTable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_ScrollX)) {
- ImGui::TableSetupColumn(ls->DatabaseShipmentTimeColumn.Get());
- ImGui::TableSetupColumn(ls->DatabaseArrivalTimeColumn.Get());
- ImGui::TableSetupColumn(ls->DatabaseItemsColumn.Get());
+ ImGui::TableSetupColumn(I18N_TEXT("Shipment time", L10N_DATABASE_COLUMN_SHIPMENT_TIME));
+ ImGui::TableSetupColumn(I18N_TEXT("Arrival time", L10N_DATABASE_COLUMN_ARRIVAL_TIME));
+ ImGui::TableSetupColumn(I18N_TEXT("Items", L10N_DATABASE_COLUMN_ITEMS));
ImGui::TableHeadersRow();
auto& entry = (*mCurrentPage)[mSelectRow];
@@ -601,8 +596,7 @@ class SalesTableView : public GenericTableView<SaleEntry>
public:
SalesTableView()
{
- auto ls = LocaleStrings::Instance.get();
- mEditDialogTitle = ls->EditSaleEntryDialogTitle.Get();
+ mEditDialogTitle = I18N_TEXT("Edit sales entry", L10N_DATABASE_SALES_VIEW_EDIT_DIALOG_TITLE);
}
#pragma clang diagnostic push
@@ -626,8 +620,7 @@ class PurchasesTableView : public GenericTableView<PurchaseEntry>
public:
PurchasesTableView()
{
- auto ls = LocaleStrings::Instance.get();
- mEditDialogTitle = ls->EditPurchaseEntryDialogTitle.Get();
+ mEditDialogTitle = I18N_TEXT("Edit purchase entry", L10N_DATABASE_PURCHASES_VIEW_EDIT_DIALOG_TITLE);
}
#pragma clang diagnostic push
@@ -649,7 +642,6 @@ public:
void UI::DatabaseViewTab()
{
- auto ls = LocaleStrings::Instance.get();
auto& gs = GlobalStates::GetInstance();
static Project* currentProject = nullptr;
@@ -663,11 +655,11 @@ void UI::DatabaseViewTab()
}
if (ImGui::BeginTabBar("DatabaseViewTabs")) {
- if (ImGui::BeginTabItem(ls->SalesViewTab.Get())) {
+ if (ImGui::BeginTabItem(I18N_TEXT("Sales", L10N_DATABASE_SALES_VIEW_TAB_NAME))) {
sales.Display();
ImGui::EndTabItem();
}
- if (ImGui::BeginTabItem(ls->PurchasesViewTab.Get())) {
+ if (ImGui::BeginTabItem(I18N_TEXT("Purchases", L10N_DATABASE_PURCHASES_VIEW_TAB_NAME))) {
purchases.Display();
ImGui::EndTabItem();
}