From 6efb338c05ae7f3c4a3da9bdde4dcc86d9468a2e Mon Sep 17 00:00:00 2001 From: phlpsong Date: Sun, 25 Feb 2024 17:57:27 +0800 Subject: [PATCH 1/4] style: use full width colon in zh_CN --- Easydict/App/Localizable.xcstrings | 58 +++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index bfdf64130..8e00e55ef 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -39,7 +39,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "调整查询图标位置:" + "value" : "调整查询图标位置:" } } } @@ -131,7 +131,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "匿名统计:" + "value" : "匿名统计:" } } } @@ -164,7 +164,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "外观:" + "value" : "外观:" } } } @@ -288,7 +288,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "开发者:" + "value" : "开发者:" } } } @@ -368,7 +368,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "自动复制:" + "value" : "自动复制:" } } } @@ -384,7 +384,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "鼠标自动划词:" + "value" : "鼠标自动划词:" } } } @@ -416,7 +416,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "自动查询:" + "value" : "自动查询:" } } } @@ -679,7 +679,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "点击查询:" + "value" : "点击查询:" } } } @@ -760,7 +760,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "崩溃日志:" + "value" : "崩溃日志:" } } } @@ -819,7 +819,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "默认 TTS 服务:" + "value" : "默认 TTS 服务:" } } } @@ -868,7 +868,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "禁用空复制提示音:" + "value" : "禁用空复制提示音:" } } } @@ -1082,7 +1082,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "词源:" + "value" : "词源:" } } } @@ -1098,7 +1098,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "释义:" + "value" : "释义:" } } } @@ -1145,7 +1145,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "第一语言:" + "value" : "第一语言:" } } } @@ -1177,7 +1177,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "侧悬浮窗口位置:" + "value" : "侧悬浮窗口位置:" } } } @@ -1258,7 +1258,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "字体大小:" + "value" : "字体大小:" } } } @@ -1578,7 +1578,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "保留结果:" + "value" : "保留结果:" } } } @@ -1594,7 +1594,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "语种识别:" + "value" : "语种识别:" } } } @@ -1691,7 +1691,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "启动:" + "value" : "启动:" } } } @@ -1760,7 +1760,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "菜单栏图标:" + "value" : "菜单栏图标:" } } } @@ -1907,7 +1907,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "鼠标划词窗口类型:" + "value" : "鼠标划词窗口类型:" } } } @@ -2168,7 +2168,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "播放单词发音:" + "value" : "播放单词发音:" } } } @@ -2313,7 +2313,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "快捷功能:" + "value" : "快捷功能:" } } } @@ -2393,7 +2393,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "第二语言:" + "value" : "第二语言:" } } } @@ -3811,7 +3811,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "快捷键划词窗口类型:" + "value" : "快捷键划词窗口类型:" } } } @@ -3891,7 +3891,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "主窗口:" + "value" : "主窗口:" } } } @@ -4048,7 +4048,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "标签:" + "value" : "标签:" } } } @@ -4107,7 +4107,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "英:" + "value" : "英:" } } } @@ -4171,7 +4171,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "美:" + "value" : "美:" } } } From af9856e9f874997973c9aaf0930b4a18631620ab Mon Sep 17 00:00:00 2001 From: phlpsong Date: Tue, 27 Feb 2024 21:47:11 +0800 Subject: [PATCH 2/4] fix: remove explain and tag label in word result cell --- Easydict/App/Localizable.xcstrings | 40 ++--------- .../View/WordResultView/EZWordResultView.m | 70 ++++--------------- 2 files changed, 18 insertions(+), 92 deletions(-) diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index 7d255f0bb..599f16282 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -1087,22 +1087,6 @@ } } }, - "explain" : { - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Explanation:" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "释义:" - } - } - } - }, "Export Log" : { "localizations" : { "zh-Hans" : { @@ -4054,22 +4038,6 @@ } } }, - "tag" : { - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Tag:" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "标签:" - } - } - } - }, "tencent_translate" : { "comment" : "The name of Tencent Translate", "localizations" : { @@ -4118,13 +4086,13 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "UK:" + "value" : "UK" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "英:" + "value" : "英" } } } @@ -4182,13 +4150,13 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "US:" + "value" : "US" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "美:" + "value" : "美" } } } diff --git a/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m b/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m index 0bf1f2b72..f7c0cd633 100644 --- a/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m +++ b/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m @@ -133,30 +133,6 @@ - (void)refreshWithResult:(EZQueryResult *)result { explainTextFieldTopOffset += 5; } - if (result.wordResult && result.translatedResults.count) { - explainLabel = [[EZLabel alloc] init]; - [self addSubview:explainLabel]; - explainLabel.font = typeTextFont; - explainLabel.textForegroundColor = typeTextColor; - explainLabel.text = NSLocalizedString(@"explain", nil); - - CGSize labelSize = [explainLabel oneLineSize]; - - [explainLabel mas_makeConstraints:^(MASConstraintMaker *make) { - if (lastView) { - make.top.equalTo(lastView.mas_bottom).offset(explainTextFieldTopOffset); - } else { - make.top.offset(explainTextFieldTopOffset); - } - make.left.mas_equalTo(kHorizontalMargin_8); - exceptedWidth += kHorizontalMargin_8; - - make.size.mas_equalTo(labelSize).priorityHigh(); - exceptedWidth += ceil(labelSize.width); - }]; - explainLabel.mas_key = @"explainLabel"; - } - NSString *text = nil; if (result.translatedText) { text = result.translatedText; @@ -367,33 +343,8 @@ - (void)refreshWithResult:(EZQueryResult *)result { audioButton.mas_key = @"audioButton_phonetics"; }]; - EZLabel *tagLabel = nil; __block NSScrollView *tagScrollView = nil; if (wordResult.tags.count) { - tagLabel = [[EZLabel alloc] init]; - [self addSubview:tagLabel]; - tagLabel.font = typeTextFont; - tagLabel.textForegroundColor = typeTextColor; - tagLabel.text = NSLocalizedString(@"tag", nil); - - CGSize labelSize = [tagLabel oneLineSize]; - - [tagLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.offset(kHorizontalMargin_8); - CGFloat topOffset = kVerticalMargin_12 + 3; - if (lastView) { - make.top.equalTo(lastView.mas_bottom).offset(topOffset); - } else { - make.top.offset(topOffset); - } - height += topOffset; - - make.size.mas_equalTo(labelSize).priorityHigh(); - height += labelSize.height; - }]; - tagLabel.mas_key = @"tagLabel"; - lastView = tagLabel; - __block NSView *tagContentView = nil; __block CGFloat tagContentViewWidth = 0; CGFloat padding = 6; @@ -415,17 +366,24 @@ - (void)refreshWithResult:(EZQueryResult *)result { }]; [tagButton sizeToFit]; - CGSize size = tagButton.size; + CGSize tagButtonSize = tagButton.size; CGFloat expandValue = 3; - CGSize newSize = CGSizeMake(size.width + expandValue * 2, size.height + expandValue); + CGSize newSize = CGSizeMake(tagButtonSize.width + expandValue * 2, tagButtonSize.height + expandValue); if (!tagScrollView) { tagScrollView = [[NSScrollView alloc] init]; [self addSubview:tagScrollView]; [tagScrollView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(tagLabel.mas_right).offset(padding + 2); + make.left.offset(kHorizontalMargin_8); make.height.mas_equalTo(newSize.height); - make.centerY.equalTo(tagLabel); + CGFloat topOffset = kVerticalMargin_12 + 3; + if (lastView) { + make.top.equalTo(lastView.mas_bottom).offset(topOffset); + } else { + make.top.offset(topOffset); + } + height += topOffset; + height += newSize.height; }]; tagContentView = [[NSView alloc] init]; @@ -444,10 +402,10 @@ - (void)refreshWithResult:(EZQueryResult *)result { tagScrollView.hasHorizontalScroller = NO; } [tagContentView addSubview:tagButton]; - + lastView = tagContentView; [tagButton mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(newSize); - make.centerY.equalTo(tagLabel); + make.centerY.equalTo(tagContentView); if (lastTagButton) { make.left.equalTo(lastTagButton.mas_right).offset(padding); } else { @@ -460,7 +418,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { tagContentView.width = tagContentViewWidth; - CGFloat maxTagScrollViewWidth = self.width - (kHorizontalMargin_8 + labelSize.width + padding * 2); + CGFloat maxTagScrollViewWidth = self.width - (kHorizontalMargin_8 + padding * 2); CGFloat tagScrollViewWidth = MIN(tagContentViewWidth, maxTagScrollViewWidth); [tagScrollView mas_updateConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(tagScrollViewWidth); From 5306bde829d9b54b3fabf130ebfb5e20b50b8cf9 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Wed, 28 Feb 2024 00:59:23 +0800 Subject: [PATCH 3/4] perf(UI): improve tag scrollView layout --- .../ViewController/View/WordResultView/EZWordResultView.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m b/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m index f7c0cd633..2f89e56d5 100644 --- a/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m +++ b/Easydict/Feature/ViewController/View/WordResultView/EZWordResultView.m @@ -348,6 +348,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { __block NSView *tagContentView = nil; __block CGFloat tagContentViewWidth = 0; CGFloat padding = 6; + CGFloat leftMargin = kHorizontalMargin_8 + 2; __block NSButton *lastTagButton = nil; [wordResult.tags enumerateObjectsUsingBlock:^(NSString *_Nonnull tag, NSUInteger idx, BOOL *_Nonnull stop) { @@ -374,7 +375,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { tagScrollView = [[NSScrollView alloc] init]; [self addSubview:tagScrollView]; [tagScrollView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.offset(kHorizontalMargin_8); + make.left.offset(leftMargin); make.height.mas_equalTo(newSize.height); CGFloat topOffset = kVerticalMargin_12 + 3; if (lastView) { @@ -418,7 +419,7 @@ - (void)refreshWithResult:(EZQueryResult *)result { tagContentView.width = tagContentViewWidth; - CGFloat maxTagScrollViewWidth = self.width - (kHorizontalMargin_8 + padding * 2); + CGFloat maxTagScrollViewWidth = self.width - (leftMargin + padding); CGFloat tagScrollViewWidth = MIN(tagContentViewWidth, maxTagScrollViewWidth); [tagScrollView mas_updateConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(tagScrollViewWidth); From 6f803f0757bd1c6a053113ae7c10d9296c45f2c0 Mon Sep 17 00:00:00 2001 From: phlpsong Date: Wed, 28 Feb 2024 21:06:37 +0800 Subject: [PATCH 4/4] fix: update colon in openAI prompt --- .../OpenAI/EZOpenAIService+EZPromptMessages.m | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Easydict/Feature/Service/OpenAI/EZOpenAIService+EZPromptMessages.m b/Easydict/Feature/Service/OpenAI/EZOpenAIService+EZPromptMessages.m index 2b32e8d74..a080a9b5a 100644 --- a/Easydict/Feature/Service/OpenAI/EZOpenAIService+EZPromptMessages.m +++ b/Easydict/Feature/Service/OpenAI/EZOpenAIService+EZPromptMessages.m @@ -161,12 +161,12 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage @"role" : @"assistant", @"content" : @"但是这位新任总理是否能够提供有活力的领导,而不是延续德国最近的漂泊,还很难说。\n\n" - @"1. 重点词汇: \n" + @"1. 重点词汇: \n" @"chancellor: n. 总理;大臣。这里指德国总理。\n" @"dynamic: adj. 有活力的;动态的。这里指强力的领导。\n" @"drift: n. 漂流;漂泊。这里是随波逐流的意思,和前面的 dynamic 做对比。\n\n" - @"2. 语法分析: \n该句子为一个复合句。主句为 \"But...is hard to say.\"(但是这位新任总理是否能提供强力的领导还难以说),其中包含了一个 whether 引导的从句作宾语从句。\n\n" - @"3. 意译:\n但是这位新任总理是否能够提供强力的领导,而不是继续德国最近的随波逐流之势,还很难说。\n\n" + @"2. 语法分析: \n该句子为一个复合句。主句为 \"But...is hard to say.\"(但是这位新任总理是否能提供强力的领导还难以说),其中包含了一个 whether 引导的从句作宾语从句。\n\n" + @"3. 意译:\n但是这位新任总理是否能够提供强力的领导,而不是继续德国最近的随波逐流之势,还很难说。\n\n" }, // @{ // @"role" : @"user", // The stock market has now reached a plateau. @@ -198,11 +198,11 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage @"role" : @"assistant", @"content" : @"这本书是简单的乡土哲学。\n\n" - @"1. 重点词汇: \n" + @"1. 重点词汇: \n" @"homespun: adj. 简朴的;手织的。\n" @"philosophy: n. 哲学;哲理。\n\n" @"2. 该句子是一个简单的主语+谓语+宾语结构。主语为 \"The book\"(这本书),谓语动词为 \"is\"(是),宾语为 \"simple homespun philosophy\"(简单朴素的哲学)。 \n\n" - @"3. 意译:\n这本书是简单朴素的哲学。\n\n" + @"3. 意译:\n这本书是简单朴素的哲学。\n\n" }, @{ @@ -214,10 +214,10 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage @"role" : @"assistant", @"content" : @"你不开始理解他们的意思。\n\n" - @"1. 重点词汇: \n" + @"1. 重点词汇: \n" @"don't begin to: 常用搭配句式,表示一点也不,完全不\n" @"2. 该句为一个简单的否定句。主语为 \"You\"(你),谓语动词为 \"don't begin to\"(一点也不),宾语为 \"understand what they mean\"(理解他们的意思)。\n\n" - @"3. 意译:\n你根本不理解他们的意思。\n\n" + @"3. 意译:\n你根本不理解他们的意思。\n\n" }, ]; @@ -418,13 +418,13 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage }, @{ @"role" : @"assistant", - @"content" : @"发音: / ˈælbəm / \n\n" + @"content" : @"发音: / ˈælbəm / \n\n" "n. 相册;唱片集;集邮簿 \n\n" "复数:albums \n\n" "解释:{explanation} \n\n" "词源学:{etymology} \n\n" "记忆方法:{how_to_remember} \n\n" - "同根词: \n" + "同根词: \n" "n. almanac 年历,历书 \n" "n. anthology 选集,文选 \n\n" "近义词:record, collection, compilation \n" @@ -443,20 +443,20 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage }, @{ @"role" : @"assistant", - @"content" : @"发音: / ˈreɪvən / \n\n" + @"content" : @"发音:/ ˈreɪvən / \n\n" "n. 掠夺,劫掠;大乌鸦 \n" "adj. 乌黑的 \n" "vt. 掠夺;狼吞虎咽 \n" "vi. 掠夺;狼吞虎咽 \n\n" - "复数: ravens \n" - "第三人称单数: ravens \n" - "现在分词: ravening \n" - "过去式: ravened \n" - "过去分词: ravened \n\n" + "复数: ravens \n" + "第三人称单数: ravens \n" + "现在分词: ravening \n" + "过去式: ravened \n" + "过去分词: ravened \n\n" "解释:{explanation} \n\n" "词源学:{etymology} \n\n" "记忆方法:{how_to_remember} \n\n" - "同根词: \n" + "同根词: \n" "n. ravage 蹂躏,破坏 \n" "vi. ravage 毁坏;掠夺 \n" "vt. ravage 毁坏;破坏;掠夺 \n\n"