mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 02:09:46 +08:00
feat(test): 添加单元测试框架并完善国际化支持
- 新增 CMake 测试框架配置,支持 safe_string、string_ext 和 path_manager 模块的单元测试 - 实现 Windows API Mock 机制,便于测试编码转换函数 - 添加 error_code 模块的字符串表示函数,支持英文错误日志 - 在 UI 回调函数中集成国际化翻译,覆盖新建、编辑、导入导出等操作提示 - 扩展 string_list 功能,新增重复路径检查函数 - 更新翻译文件,同步所有用户界面的中英文文本
This commit is contained in:
@@ -18,11 +18,19 @@ int btn_new_cb(Ihandle *self)
|
||||
{
|
||||
Ihandle *dlg = IupGetDialog(self);
|
||||
char buffer[PATH_BUFFER_SIZE] = "";
|
||||
if (custom_input_dialog("新建环境变量", "请输入路径:", buffer, sizeof(buffer)))
|
||||
if (custom_input_dialog(_("New Environment Variable"), _("Please enter a path:"), buffer, sizeof(buffer)))
|
||||
{
|
||||
if (strlen(buffer) > 0)
|
||||
{
|
||||
StringList *raw_data = get_current_raw_data(dlg);
|
||||
|
||||
// 检查是否已存在重复路径
|
||||
if (string_list_contains(raw_data, buffer))
|
||||
{
|
||||
IupMessage(_("Warning"), _("This path already exists and will not be added again."));
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
add_string_list(raw_data, buffer);
|
||||
|
||||
Ihandle *current_list = get_current_list(dlg);
|
||||
@@ -51,7 +59,7 @@ int btn_edit_cb(Ihandle *self)
|
||||
char buffer[PATH_BUFFER_SIZE];
|
||||
safe_strcpy(buffer, sizeof(buffer), string_list_get(raw_data, selected - 1));
|
||||
|
||||
if (custom_input_dialog("编辑环境变量", "编辑路径:", buffer, sizeof(buffer)))
|
||||
if (custom_input_dialog(_("Edit Environment Variable"), _("Edit path:"), buffer, sizeof(buffer)))
|
||||
{
|
||||
if (strlen(buffer) > 0)
|
||||
{
|
||||
@@ -91,6 +99,15 @@ int btn_browse_cb(Ihandle *self)
|
||||
if (value)
|
||||
{
|
||||
StringList *raw_data = get_current_raw_data(dlg);
|
||||
|
||||
// 检查是否已存在重复路径
|
||||
if (string_list_contains(raw_data, value))
|
||||
{
|
||||
IupMessage(_("Warning"), _("This path already exists and will not be added again."));
|
||||
IupDestroy(filedlg);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
add_string_list(raw_data, value);
|
||||
|
||||
Ihandle *current_list = get_current_list(dlg);
|
||||
@@ -113,7 +130,7 @@ int btn_del_cb(Ihandle *self)
|
||||
|
||||
if (selected == 0)
|
||||
{
|
||||
IupMessage("提示", "请先选择要删除的项");
|
||||
IupMessage(_("Info"), _("Please select an item to delete first"));
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user