diff --git a/README.md b/README.md index 991f9b0..bb66dfe 100644 --- a/README.md +++ b/README.md @@ -124,9 +124,9 @@ - [x] 方案下载功能实现 -- [ ] 方案应用功能实现 +- [x] 方案应用功能实现 - [ ] BugFix -- [ ] MD 编辑器中的UI文本国际化 +- [x] MD 编辑器中的UI文本国际化 - [ ] 编写帮助说明文档 - [ ] 浅色模式界面优化 - [ ] 打包上架 Deepin/UOS 应用商店 diff --git a/app/3rd_party/markdown_editor_ot/lib/markdown_editor.dart b/app/3rd_party/markdown_editor_ot/lib/markdown_editor.dart index 678a6fe..a9c3aca 100644 --- a/app/3rd_party/markdown_editor_ot/lib/markdown_editor.dart +++ b/app/3rd_party/markdown_editor_ot/lib/markdown_editor.dart @@ -2,3 +2,4 @@ library markdown_editor; export 'package:markdown_editor_ot/src/editor.dart'; export 'package:markdown_editor_ot/src/preview.dart'; +export 'package:markdown_editor_ot/src/action.dart'; diff --git a/app/3rd_party/markdown_editor_ot/lib/src/action.dart b/app/3rd_party/markdown_editor_ot/lib/src/action.dart index 8a218d4..ecf72f7 100644 --- a/app/3rd_party/markdown_editor_ot/lib/src/action.dart +++ b/app/3rd_party/markdown_editor_ot/lib/src/action.dart @@ -11,6 +11,7 @@ class ActionImage extends StatefulWidget { this.imageSelect, required this.color, this.getCursorPosition, + required this.message, }) : super(key: key); final ActionType type; @@ -20,6 +21,8 @@ class ActionImage extends StatefulWidget { final Color? color; + final String? message; + @override ActionImageState createState() => ActionImageState(); } @@ -60,7 +63,7 @@ class ActionImageState extends State { Widget build(BuildContext context) { return Tooltip( preferBelow: false, - message: _defaultImageAttributes + message: widget.message ?? _defaultImageAttributes .firstWhere((img) => img.type == widget.type) .tip, child: IconButton( @@ -243,7 +246,6 @@ enum ActionType { fontBold, fontItalic, fontStrikethrough, - fontDeleteLine, textQuote, list, h1, diff --git a/app/3rd_party/markdown_editor_ot/lib/src/editor.dart b/app/3rd_party/markdown_editor_ot/lib/src/editor.dart index e2a5df5..2c61aef 100644 --- a/app/3rd_party/markdown_editor_ot/lib/src/editor.dart +++ b/app/3rd_party/markdown_editor_ot/lib/src/editor.dart @@ -24,6 +24,7 @@ class MdEditor extends StatefulWidget { this.appendBottomWidget, this.splitWidget, this.textFocusNode, + required this.actionMessages, required this.onComplete, }) : super(key: key); @@ -51,6 +52,8 @@ class MdEditor extends StatefulWidget { final OnComplete onComplete; + final Map actionMessages; + @override State createState() => MdEditorState(); } @@ -186,6 +189,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { widgets.add(ActionImage( type: ActionType.done, + message: widget.actionMessages[ActionType.done], color: widget.actionIconColor, tap: (t, s, i, [p]) { widget.onComplete(getText()); @@ -194,6 +198,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { widgets.add(ActionImage( type: ActionType.undo, + message: widget.actionMessages[ActionType.undo], color: widget.actionIconColor, tap: (t, s, i, [p]) { _editPerform.undo(); @@ -201,6 +206,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { )); widgets.add(ActionImage( type: ActionType.redo, + message: widget.actionMessages[ActionType.redo], color: widget.actionIconColor, tap: (t, s, i, [p]) { _editPerform.redo(); @@ -237,6 +243,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.image), widget: ActionImage( type: ActionType.image, + message: widget.actionMessages[ActionType.image], color: widget.actionIconColor, tap: _disposeText, imageSelect: widget.imageSelect, @@ -247,6 +254,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.link), widget: ActionImage( type: ActionType.link, + message: widget.actionMessages[ActionType.link], color: widget.actionIconColor, tap: _disposeText, ), @@ -255,6 +263,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.fontBold), widget: ActionImage( type: ActionType.fontBold, + message: widget.actionMessages[ActionType.fontBold], color: widget.actionIconColor, tap: _disposeText, ), @@ -263,6 +272,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.fontItalic), widget: ActionImage( type: ActionType.fontItalic, + message: widget.actionMessages[ActionType.fontItalic], color: widget.actionIconColor, tap: _disposeText, ), @@ -271,6 +281,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.fontStrikethrough), widget: ActionImage( type: ActionType.fontStrikethrough, + message: widget.actionMessages[ActionType.fontStrikethrough], color: widget.actionIconColor, tap: _disposeText, ), @@ -279,6 +290,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.textQuote), widget: ActionImage( type: ActionType.textQuote, + message: widget.actionMessages[ActionType.textQuote], color: widget.actionIconColor, tap: _disposeText, ), @@ -287,6 +299,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.list), widget: ActionImage( type: ActionType.list, + message: widget.actionMessages[ActionType.list], color: widget.actionIconColor, tap: _disposeText, ), @@ -295,6 +308,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.h4), widget: ActionImage( type: ActionType.h4, + message: widget.actionMessages[ActionType.h4], color: widget.actionIconColor, tap: _disposeText, ), @@ -303,6 +317,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.h5), widget: ActionImage( type: ActionType.h5, + message: widget.actionMessages[ActionType.h5], color: widget.actionIconColor, tap: _disposeText, ), @@ -311,6 +326,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.h1), widget: ActionImage( type: ActionType.h1, + message: widget.actionMessages[ActionType.h1], color: widget.actionIconColor, tap: _disposeText, ), @@ -319,6 +335,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.h2), widget: ActionImage( type: ActionType.h2, + message: widget.actionMessages[ActionType.h2], color: widget.actionIconColor, tap: _disposeText, ), @@ -327,6 +344,7 @@ class MdEditorState extends State with AutomaticKeepAliveClientMixin { sortValue: getSortValue(ActionType.h3), widget: ActionImage( type: ActionType.h3, + message: widget.actionMessages[ActionType.h3], color: widget.actionIconColor, tap: _disposeText, ), diff --git a/app/lib/widgets/dde_markdown_field.dart b/app/lib/widgets/dde_markdown_field.dart index cb3b5ae..c001c2d 100644 --- a/app/lib/widgets/dde_markdown_field.dart +++ b/app/lib/widgets/dde_markdown_field.dart @@ -96,6 +96,7 @@ class _DMarkdownFieldState extends State { ) : MdEditor( initText: widget.initText, + hintText: LocaleKeys.md_editor_init_text.tr(), textFocusNode: _focusNode, padding: EdgeInsets.symmetric(horizontal: 5), onComplete: (content) { @@ -106,6 +107,23 @@ class _DMarkdownFieldState extends State { else widget.onComplete(content); }, + actionMessages: { + ActionType.done: LocaleKeys.md_editor_done.tr(), + ActionType.undo: LocaleKeys.md_editor_undo.tr(), + ActionType.redo: LocaleKeys.md_editor_redo.tr(), + ActionType.image: LocaleKeys.md_editor_image.tr(), + ActionType.link: LocaleKeys.md_editor_link.tr(), + ActionType.fontBold: LocaleKeys.md_editor_font_bold.tr(), + ActionType.fontItalic: LocaleKeys.md_editor_font_italic.tr(), + ActionType.fontStrikethrough: LocaleKeys.md_editor_font_strikethrough.tr(), + ActionType.textQuote: LocaleKeys.md_editor_text_quote.tr(), + ActionType.list: LocaleKeys.md_editor_list.tr(), + ActionType.h1: LocaleKeys.md_editor_h1.tr(), + ActionType.h2: LocaleKeys.md_editor_h2.tr(), + ActionType.h3: LocaleKeys.md_editor_h3.tr(), + ActionType.h4: LocaleKeys.md_editor_h4.tr(), + ActionType.h5: LocaleKeys.md_editor_h5.tr(), + }, ), ); }), diff --git a/app/resources/langs/en.json b/app/resources/langs/en.json index e5e237f..41f5173 100644 --- a/app/resources/langs/en.json +++ b/app/resources/langs/en.json @@ -185,5 +185,23 @@ "downloaded": "Downloaded", "liked": "Liked" } + }, + "md_editor": { + "init_text": "Please enter a description", + "done": "Done", + "undo": "Undo", + "redo": "redo", + "image": "Image", + "link": "Link", + "font_bold": "FontBold", + "font_italic": "FontItalic", + "font_strikethrough": "FontStrikethrough", + "text_quote": "TextQuote", + "list": "List", + "h1": "H1", + "h2": "H2", + "h3": "H3", + "h4": "H4", + "h5": "H5" } } \ No newline at end of file diff --git a/app/resources/langs/zh-CN.json b/app/resources/langs/zh-CN.json index b72af6f..caa997b 100644 --- a/app/resources/langs/zh-CN.json +++ b/app/resources/langs/zh-CN.json @@ -185,5 +185,23 @@ "downloaded": "我的下载", "liked": "我的点赞" } + }, + "md_editor": { + "init_text": "请输入描述", + "done": "完成", + "undo": "撤销", + "redo": "重做", + "image": "图片", + "link": "链接", + "font_bold": "加粗", + "font_italic": "斜体", + "font_strikethrough": "删除线", + "text_quote": "文字引用", + "list": "无序列表", + "h1": "一级标题", + "h2": "二级标题", + "h3": "三级标题", + "h4": "四级标题", + "h5": "五级标题" } } \ No newline at end of file