Browse Source

错误信息改为中文

master
hejl 2 months ago
parent
commit
66ac009ed4
  1. 18
      win_text_editor/lib/modules/data_format/controllers/data_format_controller.dart

18
win_text_editor/lib/modules/data_format/controllers/data_format_controller.dart

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:win_text_editor/framework/controllers/logger.dart';
import 'package:win_text_editor/modules/data_format/services/mustache_service.dart';
import 'package:win_text_editor/shared/base/base_content_controller.dart';
import 'grid_view_controller.dart';
@ -30,27 +31,31 @@ class DataFormatController extends BaseContentController { @@ -30,27 +31,31 @@ class DataFormatController extends BaseContentController {
// Apply the template to grid data
void applyTemplate() {
if (_templateText.isEmpty) {
_resultTextNotifier.value = 'Error: Template is empty';
_resultTextNotifier.value = '错误:模板文本不能为空';
Logger().error(_resultTextNotifier.value);
return;
}
// Validate template syntax
if (!MustacheService.validateTemplate(_templateText)) {
_resultTextNotifier.value = 'Error: Invalid Mustache template syntax';
_resultTextNotifier.value = '错误:模板语法不正确';
Logger().error(_resultTextNotifier.value);
return;
}
// Get variables from template
final templateVars = MustacheService.getTemplateVariables(_templateText);
if (templateVars.isEmpty) {
_resultTextNotifier.value = 'Error: No variables found in template';
_resultTextNotifier.value = '错误:模板中没有找到变量';
Logger().error(_resultTextNotifier.value);
return;
}
// Get grid data
final gridData = gridController.csvData;
if (gridData.isEmpty || gridData.length < 2) {
_resultTextNotifier.value = 'Error: No CSV data loaded';
_resultTextNotifier.value = '错误:没有CSV数据';
Logger().error(_resultTextNotifier.value);
return;
}
@ -60,7 +65,8 @@ class DataFormatController extends BaseContentController { @@ -60,7 +65,8 @@ class DataFormatController extends BaseContentController {
// Check if all template variables exist in headers
final missingVars = templateVars.where((varName) => !headers.contains(varName)).toList();
if (missingVars.isNotEmpty) {
_resultTextNotifier.value = 'Error: Template variables not found in CSV headers: ${missingVars.join(', ')}';
_resultTextNotifier.value = '错误:没有找到模板变量: ${missingVars.join(', ')}';
Logger().error(_resultTextNotifier.value);
return;
}
@ -84,7 +90,7 @@ class DataFormatController extends BaseContentController { @@ -84,7 +90,7 @@ class DataFormatController extends BaseContentController {
}
}
_resultTextNotifier.value = resultBuffer.toString();
_resultTextNotifier.value = resultBuffer.toString();
}
@override

Loading…
Cancel
Save