summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/Locale/zh_CN.h43
-rw-r--r--core/src/Model/Template/Template_RTTI.cpp5
-rw-r--r--core/src/Model/Workflow/Nodes/NumericNodes.cpp4
-rw-r--r--core/src/Model/Workflow/Value_RTTI.cpp33
-rw-r--r--core/src/Model/Workflow/Workflow_RTTI.cpp27
-rw-r--r--core/src/UI/UI_DatabaseView.cpp2
-rw-r--r--core/src/UI/UI_Workflows.cpp50
7 files changed, 106 insertions, 58 deletions
diff --git a/core/src/Locale/zh_CN.h b/core/src/Locale/zh_CN.h
index b01017f..367a9d1 100644
--- a/core/src/Locale/zh_CN.h
+++ b/core/src/Locale/zh_CN.h
@@ -52,7 +52,7 @@
/// 采购订单的下单时间
#define L10N_DATABASE_COLUMN_ORDER_TIME "下单时间"
/// 所有订单的“完成”时间。对于销售来说是实际交货时间,对于采购来说是收货时间。
-#define L10N_DATABASE_COLUMN_COMPLETION_TIME "交货时间"
+#define L10N_DATABASE_COLUMN_DELIVERY_TIME "交货时间"
/// 运输批次的发货时间,适用于采购和销售批次。
#define L10N_DATABASE_COLUMN_SHIPMENT_TIME "发货时间"
/// 运输批次的收获时间,适用于采购和销售批次。
@@ -82,6 +82,47 @@
#define L10N_RENAME_ASSET_DIALOG_TITLE "重命名资源"
#define L10N_TEMPLATE_INVALID_TYPE_ERROR "无效的模板类型"
+#define L10N_VALUE_NUMERIC "数值"
+#define L10N_VALUE_TEXT "文本"
+#define L10N_VALUE_DATE_TIME "时间戳"
+#define L10N_VALUE_ROW_ID "数据库表格行"
+#define L10N_VALUE_LIST "列表"
+#define L10N_VALUE_DICT "字典"
+#define L10N_VALUE_OBJECT "对象"
+#define L10N_VALUE_SALE_RECORD "销售记录"
+#define L10N_VALUE_PURCHASE_RECORD "采购记录"
+
+#define L10N_VALUE_PROPERTY_CUSTOMER "客户"
+#define L10N_VALUE_PROPERTY_DEADLINE "交货期限"
+#define L10N_VALUE_PROPERTY_FACTORY "工厂"
+#define L10N_VALUE_PROPERTY_ORDER_TIME "下单时间"
+#define L10N_VALUE_PROPERTY_DELIVERY_TIME "交货时间"
+
+#define L10N_WORKFLOW_KIND_INPUT "输入节点"
+#define L10N_WORKFLOW_KIND_TRANSFORM "计算节点"
+#define L10N_WORKFLOW_KIND_OUTPUT "输出节点"
+
+#define L10N_WORKFLOW_ADD "加法"
+#define L10N_WORKFLOW_SUB "减法"
+#define L10N_WORKFLOW_MUL "乘法"
+#define L10N_WORKFLOW_DIV "除法"
+#define L10N_WORKFLOW_EVAL "对表达式求值"
+#define L10N_WORKFLOW_FMT "格式化文本"
+#define L10N_WORKFLOW_INSTANTIATE_TEMPLATE "实例化文档"
+#define L10N_WORKFLOW_FORM_INPUT "表单输入"
+#define L10N_WORKFLOW_DB_INPUT "数据库输入"
+
+#define L10N_WORKFLOW_CATEGORY_NUMERIC "数字"
+#define L10N_WORKFLOW_CATEGORY_TEXT "文本"
+#define L10N_WORKFLOW_CATEGORY_DOCUMENT "文档"
+#define L10N_WORKFLOW_CATEGORY_USER_INPUT "用户输入"
+#define L10N_WORKFLOW_CATEGORY_SYS_INPUT "环境输入"
+#define L10N_WORKFLOW_CATEGORY_OUTPUT "输出"
+
+#define L10N_WORKFLOW_RTERROR_DIV_BY_0 "错误:除数为0"
+
+#define L10N_TEMPLATE_TABLE "表格模板"
+
#define L10N_TABLE_CELL_HORIZONTAL_ALIGNMENT "水平对齐"
#define L10N_TABLE_CELL_VERTICAL_ALIGNMENT "垂直对齐"
#define L10N_TABLE_CELL_ALIGN_LEFT "左对齐"
diff --git a/core/src/Model/Template/Template_RTTI.cpp b/core/src/Model/Template/Template_RTTI.cpp
index 1475e02..d1affe7 100644
--- a/core/src/Model/Template/Template_RTTI.cpp
+++ b/core/src/Model/Template/Template_RTTI.cpp
@@ -1,15 +1,16 @@
#include "Template.hpp"
#include "Model/Template/TableTemplate.hpp"
+#include "Utils/I18n.hpp"
const char* Template::FormatKind(Kind kind)
{
switch (kind) {
- case KD_Table: return "Table template";
+ case KD_Table: return I18N_TEXT("Table template", L10N_TEMPLATE_TABLE);
case InvalidKind: break;
}
- return "<invalid kind>";
+ return "";
}
std::unique_ptr<Template> Template::CreateByKind(Kind kind)
diff --git a/core/src/Model/Workflow/Nodes/NumericNodes.cpp b/core/src/Model/Workflow/Nodes/NumericNodes.cpp
index f0d28b1..3a81979 100644
--- a/core/src/Model/Workflow/Nodes/NumericNodes.cpp
+++ b/core/src/Model/Workflow/Nodes/NumericNodes.cpp
@@ -2,6 +2,7 @@
#include "Model/Workflow/Evaluation.hpp"
#include "Model/Workflow/Values/Basic.hpp"
+#include "Utils/I18n.hpp"
#include "Utils/Macros.hpp"
#include "Utils/RTTI.hpp"
@@ -64,8 +65,7 @@ void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx)
case Multiplication: res = lhs * rhs; break;
case Division: {
if (rhs == 0.0) {
- // TODO localize
- ctx.ReportError("Error: division by 0", *this);
+ ctx.ReportError(I18N_TEXT("Error: division by 0", L10N_WORKFLOW_RTERROR_DIV_BY_0), *this);
return;
}
res = lhs / rhs;
diff --git a/core/src/Model/Workflow/Value_RTTI.cpp b/core/src/Model/Workflow/Value_RTTI.cpp
index dfb1273..121fa14 100644
--- a/core/src/Model/Workflow/Value_RTTI.cpp
+++ b/core/src/Model/Workflow/Value_RTTI.cpp
@@ -5,6 +5,7 @@
#include "Model/Workflow/Values/Dictionary.hpp"
#include "Model/Workflow/Values/List.hpp"
#include "UI/UI.hpp"
+#include "Utils/I18n.hpp"
constexpr BaseValue::KindInfo kNumericInfo{
.PinIcon = ImGui::IconType::Circle,
@@ -69,20 +70,20 @@ const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind)
const char* BaseValue::Format(Kind kind)
{
switch (kind) {
- case KD_Numeric: return "Numeric";
- case KD_Text: return "Text";
- case KD_DateTime: return "Date/time";
- case KD_DatabaseRowId: return "Row id";
- case KD_List: return "List";
- case KD_Dictionary: return "Dictionary";
+ case KD_Numeric: return I18N_TEXT("Numeric", L10N_VALUE_NUMERIC);
+ case KD_Text: return I18N_TEXT("Text", L10N_VALUE_TEXT);
+ case KD_DateTime: return I18N_TEXT("Date/time", L10N_VALUE_DATE_TIME);
+ case KD_DatabaseRowId: return I18N_TEXT("Row id", L10N_VALUE_ROW_ID);
+ case KD_List: return I18N_TEXT("List", L10N_VALUE_LIST);
+ case KD_Dictionary: return I18N_TEXT("Dictionary", L10N_VALUE_DICT);
- case KD_BaseObject: return "Object";
- case KD_SaleDatabaseRow: return "Sale record";
- case KD_PurchaseDatabaseRow: return "Purchase record";
+ case KD_BaseObject: return I18N_TEXT("Object", L10N_VALUE_OBJECT);
+ case KD_SaleDatabaseRow: return I18N_TEXT("Sale record", L10N_VALUE_SALE_RECORD);
+ case KD_PurchaseDatabaseRow: return I18N_TEXT("Purchase record", L10N_VALUE_PURCHASE_RECORD);
case InvalidKind: break;
}
- return "<invalid kind>";
+ return "";
}
std::unique_ptr<BaseValue> BaseValue::CreateByKind(BaseValue::Kind kind)
@@ -116,16 +117,16 @@ const BaseObjectDescription kEmptyObjectInfo{
const BaseObjectDescription kSaleDbRowObject{
.Properties = {
{
- .Name = "Customer",
+ .Name = I18N_TEXT("Customer", L10N_VALUE_PROPERTY_CUSTOMER),
.Kind = BaseValue::KD_Text,
.Mutatable = false,
},
{
- .Name = "Deadline",
+ .Name = I18N_TEXT("Deadline", L10N_VALUE_PROPERTY_DEADLINE),
.Kind = BaseValue::KD_DateTime,
},
{
- .Name = "Completion time",
+ .Name = I18N_TEXT("Delivery time", L10N_VALUE_PROPERTY_DELIVERY_TIME),
.Kind = BaseValue::KD_DateTime,
},
},
@@ -134,16 +135,16 @@ const BaseObjectDescription kSaleDbRowObject{
const BaseObjectDescription kPurchaseDbRowObject{
.Properties = {
{
- .Name = "Factory",
+ .Name = I18N_TEXT("Factory", L10N_VALUE_PROPERTY_FACTORY),
.Kind = BaseValue::KD_Text,
.Mutatable = false,
},
{
- .Name = "Order time",
+ .Name = I18N_TEXT("Order time", L10N_VALUE_PROPERTY_ORDER_TIME),
.Kind = BaseValue::KD_DateTime,
},
{
- .Name = "Arrival time",
+ .Name = I18N_TEXT("Delivery time", L10N_VALUE_PROPERTY_DELIVERY_TIME),
.Kind = BaseValue::KD_DateTime,
},
},
diff --git a/core/src/Model/Workflow/Workflow_RTTI.cpp b/core/src/Model/Workflow/Workflow_RTTI.cpp
index 10659d0..579fb3b 100644
--- a/core/src/Model/Workflow/Workflow_RTTI.cpp
+++ b/core/src/Model/Workflow/Workflow_RTTI.cpp
@@ -4,6 +4,7 @@
#include "Model/Workflow/Nodes/NumericNodes.hpp"
#include "Model/Workflow/Nodes/TextNodes.hpp"
#include "Model/Workflow/Nodes/UserInputNodes.hpp"
+#include "Utils/I18n.hpp"
#include "Utils/Macros.hpp"
#include <memory>
@@ -11,27 +12,27 @@
const char* WorkflowNode::FormatKind(Kind kind)
{
switch (kind) {
- case KD_NumericAddition: return "NumericOperation (addition)";
- case KD_NumericSubtraction: return "NumericOperation (subtraction)";
- case KD_NumericMultiplication: return "NumericOperation (multiplication)";
- case KD_NumericDivision: return "NumericOperation (division)";
- case KD_NumericExpression: return "NumericExpression";
- case KD_TextFormatting: return "TextFormatting";
- case KD_DocumentTemplateExpansion: return "DocumentTemplateExpansion";
- case KD_FormInput: return "FormInput";
- case KD_DatabaseRowsInput: return "DatabaseRowsInput";
+ case KD_NumericAddition: return I18N_TEXT("Add", L10N_WORKFLOW_ADD);
+ case KD_NumericSubtraction: return I18N_TEXT("Subtract", L10N_WORKFLOW_SUB);
+ case KD_NumericMultiplication: return I18N_TEXT("Multiply", L10N_WORKFLOW_MUL);
+ case KD_NumericDivision: return I18N_TEXT("Divide", L10N_WORKFLOW_DIV);
+ case KD_NumericExpression: return I18N_TEXT("Evaluate expression", L10N_WORKFLOW_EVAL);
+ case KD_TextFormatting: return I18N_TEXT("Format text", L10N_WORKFLOW_FMT);
+ case KD_DocumentTemplateExpansion: return I18N_TEXT("Expand template", L10N_WORKFLOW_INSTANTIATE_TEMPLATE);
+ case KD_FormInput: return I18N_TEXT("Form input", L10N_WORKFLOW_FORM_INPUT);
+ case KD_DatabaseRowsInput: return I18N_TEXT("Database input", L10N_WORKFLOW_DB_INPUT);
case InvalidKind: break;
}
- return "<invalid kind>";
+ return "";
}
const char* WorkflowNode::FormatType(Type type)
{
switch (type) {
- case InputType: return "input";
- case TransformType: return "transform";
- case OutputType: return "output";
+ case InputType: return I18N_TEXT("Input", L10N_WORKFLOW_KIND_INPUT);
+ case TransformType: return I18N_TEXT("Transform", L10N_WORKFLOW_KIND_TRANSFORM);
+ case OutputType: return I18N_TEXT("Output", L10N_WORKFLOW_KIND_OUTPUT);
}
return "";
}
diff --git a/core/src/UI/UI_DatabaseView.cpp b/core/src/UI/UI_DatabaseView.cpp
index 40f29ca..96ef1d7 100644
--- a/core/src/UI/UI_DatabaseView.cpp
+++ b/core/src/UI/UI_DatabaseView.cpp
@@ -289,7 +289,7 @@ private:
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 (kHasCompletionTime) ImGui::TableSetupColumn(I18N_TEXT("Completion time", L10N_DATABASE_COLUMN_DELIVERY_TIME));
if constexpr (kHasItems) ImGui::TableSetupColumn(I18N_TEXT("Items", L10N_DATABASE_COLUMN_ITEMS));
ImGui::TableHeadersRow();
diff --git a/core/src/UI/UI_Workflows.cpp b/core/src/UI/UI_Workflows.cpp
index 4535f08..68fd3ee 100644
--- a/core/src/UI/UI_Workflows.cpp
+++ b/core/src/UI/UI_Workflows.cpp
@@ -75,41 +75,41 @@ public:
// Numeric nodes offset start at 0
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<NumericOperationNode>(NumericOperationNode::Addition); },
- .Name = "Add",
+ .Name = I18N_TEXT("Add", L10N_WORKFLOW_ADD),
.Category = WorkflowCategory::Numeric,
});
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<NumericOperationNode>(NumericOperationNode::Subtraction); },
- .Name = "Subtract",
+ .Name = I18N_TEXT("Subtract", L10N_WORKFLOW_SUB),
.Category = WorkflowCategory::Numeric,
});
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<NumericOperationNode>(NumericOperationNode::Multiplication); },
- .Name = "Multiply",
+ .Name = I18N_TEXT("Multiply", L10N_WORKFLOW_MUL),
.Category = WorkflowCategory::Numeric,
});
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<NumericOperationNode>(NumericOperationNode::Division); },
- .Name = "Divide",
+ .Name = I18N_TEXT("Divide", L10N_WORKFLOW_DIV),
.Category = WorkflowCategory::Numeric,
});
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<NumericExpressionNode>(); },
- .Name = "Evaluate expression",
+ .Name = I18N_TEXT("Evaluate expression", L10N_WORKFLOW_EVAL),
.Category = WorkflowCategory::Numeric,
});
mTextOffset = mCandidates.size();
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<TextFormatterNode>(); },
- .Name = "Fill template text",
+ .Name = I18N_TEXT("Format text", L10N_WORKFLOW_FMT),
.Category = WorkflowCategory::Text,
});
mDocumentOffset = mCandidates.size();
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<DocumentTemplateExpansionNode>(); },
- .Name = "Document template",
+ .Name = I18N_TEXT("Expand template", L10N_WORKFLOW_INSTANTIATE_TEMPLATE),
.Category = WorkflowCategory::Documents,
});
@@ -118,13 +118,13 @@ public:
mUserInputOffset = mCandidates.size();
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<FormInputNode>(); },
- .Name = "Input: form",
+ .Name = I18N_TEXT("Form input", L10N_WORKFLOW_FORM_INPUT),
.Category = WorkflowCategory::UserInput,
});
mCandidates.push_back(Candidate{
.Constructor = []() -> std::unique_ptr<WorkflowNode> { return std::make_unique<DatabaseRowsInputNode>(); },
- .Name = "Input: database rows",
+ .Name = I18N_TEXT("Database input", L10N_WORKFLOW_DB_INPUT),
.Category = WorkflowCategory::UserInput,
});
@@ -231,7 +231,7 @@ public:
if (ImNodes::AcceptNewItem()) {
ImNodes::Suspend();
- ImGui::BeginPopup("Create Node");
+ ImGui::BeginPopup("CreateNodeCtxMenu");
ImNodes::Resume();
}
}
@@ -266,14 +266,14 @@ public:
// Popups
ImNodes::Suspend();
if (ImNodes::ShowNodeContextMenu(&mContextMenuNodeId)) {
- ImGui::OpenPopup("Node Context Menu");
+ ImGui::OpenPopup("NodeCtxMenu");
} else if (ImNodes::ShowPinContextMenu(&mContextMenuPinId)) {
- ImGui::OpenPopup("Pin Context Menu");
+ ImGui::OpenPopup("PinCtxMenu");
} else if (ImNodes::ShowLinkContextMenu(&mContextMenuLinkId)) {
- ImGui::OpenPopup("Link Context Menu");
+ ImGui::OpenPopup("LinkCtxMenu");
}
- if (ImGui::BeginPopup("Node Context Menu")) {
+ if (ImGui::BeginPopup("NodeCtxMenu")) {
auto& node = *mWorkflow->GetNodeByNodeId(mContextMenuNodeId);
node.DrawDebugInfo();
@@ -284,7 +284,7 @@ public:
ImGui::EndPopup();
}
- if (ImGui::BeginPopup("Pin Context Menu")) {
+ if (ImGui::BeginPopup("PinCtxMenu")) {
auto [node, pinId, isOutput] = mWorkflow->DisassembleGlobalPinId(mContextMenuPinId);
if (isOutput) {
node->DrawOutputPinDebugInfo(pinId);
@@ -313,7 +313,7 @@ public:
ImGui::EndPopup();
}
- if (ImGui::BeginPopup("Link Context Menu")) {
+ if (ImGui::BeginPopup("LinkCtxMenu")) {
auto& conn = *mWorkflow->GetConnectionByLinkId(mContextMenuLinkId);
conn.DrawDebugInfo();
@@ -324,7 +324,7 @@ public:
ImGui::EndPopup();
}
- if (ImGui::BeginPopup("Create Node")) {
+ if (ImGui::BeginPopup("CreateNodeCtxMenu")) {
auto DisplayCandidatesCategory = [&](const char* name, std::span<const WorkflowDatabase::Candidate> candidates) {
if (ImGui::BeginMenu(name)) {
for (auto& candidate : candidates) {
@@ -338,12 +338,12 @@ public:
}
};
- DisplayCandidatesCategory("Numeric nodes", mWorkflowDb->GetNumericNodes());
- DisplayCandidatesCategory("Text nodes", mWorkflowDb->GetTextNodes());
- DisplayCandidatesCategory("Document nodes", mWorkflowDb->GetDocumentNodes());
- DisplayCandidatesCategory("User input nodes", mWorkflowDb->GetUserInputNodes());
- DisplayCandidatesCategory("System input nodes", mWorkflowDb->GetSystemInputNodes());
- DisplayCandidatesCategory("Output nodes", mWorkflowDb->GetOutputNodes());
+ DisplayCandidatesCategory(I18N_TEXT("Numeric", L10N_WORKFLOW_CATEGORY_NUMERIC), mWorkflowDb->GetNumericNodes());
+ DisplayCandidatesCategory(I18N_TEXT("Text", L10N_WORKFLOW_CATEGORY_TEXT), mWorkflowDb->GetTextNodes());
+ DisplayCandidatesCategory(I18N_TEXT("Document", L10N_WORKFLOW_CATEGORY_DOCUMENT), mWorkflowDb->GetDocumentNodes());
+ DisplayCandidatesCategory(I18N_TEXT("User input", L10N_WORKFLOW_CATEGORY_USER_INPUT), mWorkflowDb->GetUserInputNodes());
+ DisplayCandidatesCategory(I18N_TEXT("System input", L10N_WORKFLOW_CATEGORY_SYS_INPUT), mWorkflowDb->GetSystemInputNodes());
+ DisplayCandidatesCategory(I18N_TEXT("Output", L10N_WORKFLOW_CATEGORY_OUTPUT), mWorkflowDb->GetOutputNodes());
ImGui::EndPopup();
}
@@ -356,6 +356,10 @@ public:
ImNodes::End();
}
+
+ void DisplayNodeList()
+ {
+ }
};
} // namespace