Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 反馈问题:特定应用中无法使用划词翻译 #84

Closed
3 tasks done
Jerry23011 opened this issue May 3, 2023 · 67 comments
Closed
3 tasks done

🐞 反馈问题:特定应用中无法使用划词翻译 #84

Jerry23011 opened this issue May 3, 2023 · 67 comments
Labels
bug Something isn't working fixed in next release The issue will be closed once next release is available

Comments

@Jerry23011
Copy link
Collaborator

Jerry23011 commented May 3, 2023

请先确认以下事项:

  • 已仔细阅读了 README
  • issues 页面搜索过问题(包括已关闭的 issue),但未能找到解决方法
  • Easydict 已升级到最新版本

问题描述

在 Pages、Keynote、Numbers、Word、微信、无边记、图书几个应用中无法正常使用划词翻译功能

重现步骤

  1. 启动上述应用,例如 Pages 或 Microsoft Word
  2. 选中文本
  3. 使用快捷键划词翻译
  4. 看到文本框中没有内容

期望结果

可以在上述应用中正常使用划词翻译

解决方案(可选)

在 Easydict/Easydict/Feature/EventMonitor/EZEventMonitor.m 文件中手动添加应用,模拟 ⌘C

设备信息 && 操作系统版本(可选)

macOS 13.3.1 (a)

@Jerry23011 Jerry23011 added the bug Something isn't working label May 3, 2023
@tisfeng
Copy link
Owner

tisfeng commented May 3, 2023

奇怪,我试了一下 Pages,发现它居然原生就支持 Auxiliary 取词,不需要额外适配。 我的系统是 13.2

image

@Jerry23011
Copy link
Collaborator Author

Jerry23011 commented May 3, 2023 via email

@tisfeng
Copy link
Owner

tisfeng commented May 3, 2023

Word 确实不行,和这个一样 #81 (comment) ,我加一下。

@tisfeng tisfeng added the fixed in next release The issue will be closed once next release is available label May 3, 2023
@Jerry23011
Copy link
Collaborator Author

试了一下,Pages 还是不好用
不知道是不是版本问题:Pages 版本 13.0 (7036.0.126)

@tisfeng
Copy link
Owner

tisfeng commented May 3, 2023

还是不能取词吗?这就难搞,我也是这个版本 😢

你可以用 dev 分支断点调试一下,看看 Pages 这个取词错误 error 的值吗

- (BOOL)checkIfNeedUseShortcut:(NSString *)text error:(AXError)error {

@Jerry23011
Copy link
Collaborator Author

项目不知道为什么,build 不起来,我回头再看看

@Jerry23011
Copy link
Collaborator Author

Jerry23011 commented May 5, 2023

build 的时候报错,想问一下这里是什么情况
截屏2023-05-05 09 36 57
截屏2023-05-05 09 37 43

@tisfeng
Copy link
Owner

tisfeng commented May 5, 2023

像是桥接文件出了问题,你有改过代码文件吗?看一下 Easydict-Bridging-Header.h 文件的路径对不对

image

@Jerry23011
Copy link
Collaborator Author

我没改,直接编译的
截屏2023-05-05 10 34 03

@tisfeng
Copy link
Owner

tisfeng commented May 5, 2023

看一下你的 Xcode 版本,是最新的吗
image

@Jerry23011
Copy link
Collaborator Author

对,14.3

@tisfeng
Copy link
Owner

tisfeng commented May 5, 2023

没头绪,问了下 ChatGPT,不确定是不是 CocoaLumberjack 问题,你重新 pod install 一下吧,或者移除现有的 pod,再 pod install

image

@Jerry23011
Copy link
Collaborator Author

我这里这个显示是红色的,不知道有没有关系
截屏2023-05-05 12 16 40

@tisfeng
Copy link
Owner

tisfeng commented May 5, 2023

一看你这个目录结构就不对 😓

你是不是打开的 Easydict.xcodeproj ? pod 项目要打开 Easydict.xcworkspace

image

@Jerry23011
Copy link
Collaborator Author

不好意思,第一次接触 pod 项目😓

@Jerry23011
Copy link
Collaborator Author

这里是断点的结果 截屏2023-05-05 12 45 35

2023-05-05 12:42:55.404551+0800 Easydict-Debug[52452:2397065] [MMLog ● 75 ● I] +[MMManagerForLog sharedDDLog]_block_invoke ●
=========>
🚀 com.izual.Easydict-debug(1.3.0)[15] 启动 MMLog(Defalut)...

日志文件夹:
/Users/jerry/Library/Caches/com.izual.Easydict-debug/MMLogs/Default
<=========
2023-05-05 12:42:55.405475+0800 Easydict-Debug[52452:2397064] [AppDelegate ● 28 ● I] -[AppDelegate applicationDidFinishLaunching:] ● 程序启动
2023-05-05 12:42:55.443618+0800 Easydict-Debug[52452:2397060] [EZWindowManager ● 76 ● V] -[EZWindowManager setup] ● [
-1
]
2023-05-05 12:42:55.444547+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:55.444858+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:55.445062+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:55.445260+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:55.448385+0800 Easydict-Debug[52452:2397042] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-05-05 12:42:55.973262+0800 Easydict-Debug[52452:2397042] [Window] Warning: Window NSMenuWindowManagerWindow 0x12460e570 ordered front from a non-active application and may order beneath the active application's windows.
2023-05-05 12:42:56.508575+0800 Easydict-Debug[52452:2397065] [EZStatusItem ● 143 ● V] -[EZStatusItem preferenceAction:] ● 偏好设置
2023-05-05 12:42:56.519330+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.519376+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.519729+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.519753+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.536370+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.536402+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.536673+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.536698+0800 Easydict-Debug[52452:2397042] [NSToolbarItem] NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
2023-05-05 12:42:56.547050+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:56.547340+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:56.547455+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:56.547542+0800 Easydict-Debug[52452:2397042] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
2023-05-05 12:42:56.561065+0800 Easydict-Debug[52452:2397042] Metal API Validation Enabled
2023-05-05 12:42:56.598214+0800 Easydict-Debug[52452:2397042] [Window] Warning: Window NSWindow 0x134655100 ordered front from a non-active application and may order beneath the active application's windows.
2023-05-05 12:42:58.603691+0800 Easydict-Debug[52452:2397061] [EZWindowManager ● 782 ● V] -[EZWindowManager closeWindow] ● Close window
2023-05-05 12:42:58.604978+0800 Easydict-Debug[52452:2397065] [EZWindowManager ● 712 ● V] -[EZWindowManager closeFloatingWindow] ● close floating window: (null)
2023-05-05 12:43:05.595917+0800 Easydict-Debug[52452:2397065] [EZEventMonitor ● 365 ● V] -[EZEventMonitor isAccessibilityTrusted] ● isTrusted: 1
2023-05-05 12:43:05.632375+0800 Easydict-Debug[52452:2397063] [EZEventMonitor ● 302 ● I] -[EZEventMonitor getSelectedTextByAuxiliary:] ● Can't get selected text: -25205
(lldb)

@tisfeng
Copy link
Owner

tisfeng commented May 5, 2023

确认一下,这是你在 Pages 中无法取词的日志,error 是 -25205 ?

看看你的 Pages bundle id 是不是 com.apple.iWork.Pages

@Jerry23011
Copy link
Collaborator Author

是的,bundle id com.apple.iWork.Pages
截屏2023-05-05 15 55 28
又重新跑了一下,error是 -25205

Please debug, this is what Xcode shows me 2023-05-05 15:58:53.734059+0800 Easydict-Debug[61284:2484476] [EZEventMonitor ● 302 ● I] -[EZEventMonitor getSelectedTextByAuxiliary:] ● Can't get selected text: -25205

@tisfeng
Copy link
Owner

tisfeng commented May 5, 2023

我在最新的 dev 分支把 Pages 加入了白名单,你测一下看行不行,以及是否会对别的应用造成影响。

@Jerry23011
Copy link
Collaborator Author

Jerry23011 commented May 5, 2023

测试了下最新的 dev,Pages 还是不行,可能是我自己的问题 😣
Xcode 还是会有报错,我分别在 Keynote 和 Numbers 中测试,也是会出现同样的问题

2023-05-06 07:17:04.757162+0800 Easydict-Debug[79486:2780209] [EZEventMonitor ● 173 ● V] -[EZEventMonitor getSelectedText:completion:]_block_invoke ● AXError: -25205

@tisfeng
Copy link
Owner

tisfeng commented May 6, 2023

不不,AXError: -25205 这个是日志提示,是正常的,表示某些应用不支持常规的 Auxiliary 取词,所以这种情况就需要白名单,对白名单中的应用实行备用方法——模拟快捷键 Cmd+C 方式取词。

这个你不用管,你只要确定用最新的代码,能够在 Pages 等应用中能够取词就行了。

@Jerry23011
Copy link
Collaborator Author

Jerry23011 commented May 6, 2023

这个问题不知道为什么 build 不了,好像是有道的 API
截屏2023-05-07 00 08 38

@tisfeng
Copy link
Owner

tisfeng commented May 6, 2023

你截全屏看一下,项目里好像没有用这个 JS 文件,另外,你这个路径显示也不太对 🧐

@tisfeng
Copy link
Owner

tisfeng commented May 6, 2023

好像是有文件引用问题,忘记移除了 🥲 我更新了 dev 代码,你再试一下。

@Jerry23011
Copy link
Collaborator Author

Jerry23011 commented May 6, 2023

这回成功了!感谢,一起不好用的还有 iWork 三件套,还是不理解为什么 iWork 会不好用,可能是我 macOS 版本问题
我想这个 issue 要不要先不关,看看别人有没有同样的问题
截屏2023-05-07 00 21 56

@tisfeng
Copy link
Owner

tisfeng commented May 6, 2023

你的 Numbers 和 Keynote 也还不能取词吗? 我这边显示它们都是正常的。

如果是,看一下 error 是不是一样,参考这个 commit 23742ec , 那也可以在这里加一下它们的 bundle id

@"com.apple.iWork.Pages", // Pages, FIX: https://github.com/tisfeng/Easydict/issues/84#issuecomment-1535885832

@Jerry23011
Copy link
Collaborator Author

刚刚试了一下,我这边加上 bundle id 就好用了

@tisfeng
Copy link
Owner

tisfeng commented May 7, 2023

行吧。感觉你的电脑配置环境可能有点不一样,你可以把你所有的应用都测一遍,列出有问题的应用,我看看能不能找出问题。

如果有问题,也可以都按下面这种 error 和 bundle id 字典对应方式添加,然后在 dev 上提一个 PR

        // Some App return kAXErrorAttributeUnsupported but actually has selected text.
        @(kAXErrorAttributeUnsupported) : @[
            @"com.sublimetext.4", // Sublime Text
            @"com.microsoft.Word", // Word
            @"com.apple.iWork.Pages", // Pages, FIX: https://github.com/tisfeng/Easydict/issues/84#issuecomment-1535885832
        ],

@tisfeng
Copy link
Owner

tisfeng commented Nov 22, 2023

你可以测一下 macOS 13 吗,也看一下图书 App 取词失败时的日志。

@Jerry23011
Copy link
Collaborator Author

[EZEventMonitor ● 515 ● I] -[EZEventMonitor getSelectedTextByAccessibility:] ● --> Accessibility success, getText:
[EZEventMonitor ● 520 ● I] -[EZEventMonitor getSelectedTextByAccessibility:] ● Accessibility error: -25205

我这边在 13.6.2 上也是这两个来回出现,但是没找到触发条件是什么 Accessibility success, getText: 出现相对多一些

@tisfeng
Copy link
Owner

tisfeng commented Nov 22, 2023

ok,你分别在 macOS 13 和 14 都测一下:

  1. 划词是否会自动弹窗
  2. 取词失败时的日志

@Jerry23011
Copy link
Collaborator Author

ok,你分别在 macOS 13 和 14 都测一下:

  1. 划词是否会自动弹窗
  2. 取词失败时的日志

我稍晚一些去测

@Jerry23011
Copy link
Collaborator Author

@tisfeng 我的虚拟机不支持Apple ID登录,不能直接MAS下载Xcode,回头我看看有什么其他方法再测

Jerry23011 added a commit to Jerry23011/Easydict that referenced this issue Dec 3, 2023
Add Keynote, Numbers, WeChat, iBooks, and Freeform
@pipashu
Copy link

pipashu commented Dec 10, 2023

macOS Sonoma ,edge 浏览器页面,划词不弹出图标,快捷键可以弹出图标。

@tisfeng
Copy link
Owner

tisfeng commented Dec 10, 2023

edge 之前测试过,正常来说只要为 Easydict 开启了【隐私与安全性-->辅助功能】权限,那就支持 Accessibility 取词。

但某些特殊情况下 Accessibility 取词可能会失败 #85 (comment) ,建议开启浏览器的【允许 Apple 事件中的 JavaScript】功能。

@tisfeng
Copy link
Owner

tisfeng commented Dec 10, 2023

另外,某些奇怪问题可能导致【隐私与安全性-->辅助功能】权限失效,建议删除,重新加一下。

@EricWong1994
Copy link

EricWong1994 commented Feb 26, 2024

anki里不能 滑词翻译,我之前用popClip也会有这个问题,他们说是因为 调用了第三方库 导致的 https://forum.popclip.app/t/popclip-not-working-in-anki/563/7 ,始终无法解决,
我以为我们这软件支持,没想到也不行,
不知道开发人员有没有用过 sider 客户端,这个工具就能在 anki中滑词出现浮窗,
为啥呢

@tisfeng
Copy link
Owner

tisfeng commented Feb 26, 2024

我下载测试了一下 anki macOS 12+ (Apple Silicon, 23.12.1 Qt6),鼠标取词好像没有问题?

image

@EricWong1994
Copy link

我下载测试了一下 anki macOS 12+ (Apple Silicon, 23.12.1 Qt6),鼠标取词好像没有问题?

image

好像是Qt-5版本会有这个问题。(我由于某些特殊原因 不能升级到 Qt-6)....
我看TTime滑词会出现一个悬浮球,

@tisfeng
Copy link
Owner

tisfeng commented Feb 26, 2024

试了一下 Qt-5 版本,确实不支持系统 Accessibility API 取词,但只要在设置中开启【强制划词】,也能成功的。

image

@EricWong1994
Copy link

找到了,太感谢了
另外请教一个问题,我电脑系统现在的语言是英文,如何将这款软件默认为中文啊,
下面图片中的首选语言和 第二选择语言是什么意思啊,互换后也没生效
image

@tisfeng
Copy link
Owner

tisfeng commented Feb 26, 2024

应用内切换语言还在开发中 #348 ,目前可以在【设置-语言与地区】中修改。

image

@tisfeng
Copy link
Owner

tisfeng commented Feb 26, 2024

#131 (comment)

翻译时,如果用户没有指定目标翻译语言,则会根据输入文本识别的语言和偏好语言,来自动选择目标翻译语言,具体规则如下:

如果输入文本语言不是第一语言,则目标翻译语言为第一语言。
如果输入文本语言是第一语言,则目标翻译语言为第二语言。

@danaquentin
Copy link

问题描述
在 WPS 中无法正常使用划词翻译功能,更新到最新版后功能失效,之前[v2.7.2] 版本可用。

重现步骤
启动上述应用
选中文本
使用快捷键划词翻译
看到文本框中没有内容
期望结果
可以在上述应用中正常使用划词翻译

应用版本:
WPS 6.11.0(8885)
Easydict 2.9.0

@Jerry23011
Copy link
Collaborator Author

@danaquentin 有尝试开始剪贴板强制取词吗?设置 -> 通用 -> 鼠标查询

@danaquentin
Copy link

@danaquentin 有尝试开始剪贴板强制取词吗?设置 -> 通用 -> 鼠标查询

强制取词可以

@Dzx1025
Copy link

Dzx1025 commented Oct 29, 2024

问题描述

在 Safari 和 Edge 的 PDF Preview 中无法正常使用划词翻译功能。(已开启强制取词和Allow Javascript From Apple Event )

选中文本后可以正常复制到剪切板。

重现步骤

  1. 启动上述应用
  2. 使用快捷键或者触控板选中文本后划词翻译,不会弹出查询图标
  3. 同时弹出窗口文本框中没有内容
image

期望结果

可以在上述情景中正常使用划词翻译。

应用版本

Easydict 2.9.0

@tisfeng
Copy link
Owner

tisfeng commented Nov 2, 2024

问题描述

在 Safari 和 Edge 的 PDF Preview 中无法正常使用划词翻译功能。(已开启强制取词和Allow Javascript From Apple Event )

选中文本后可以正常复制到剪切板。

重现步骤

  1. 启动上述应用
  2. 使用快捷键或者触控板选中文本后划词翻译,不会弹出查询图标
  3. 同时弹出窗口文本框中没有内容
image ### 期望结果 可以在上述情景中正常使用划词翻译。

应用版本

Easydict 2.9.0 易字典2.9.0

这样简单描述,无法确定问题所在。

请另外单独开 issue,记得附上运行日志,方便开发者排查问题。

@CanglongCl CanglongCl unpinned this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next release The issue will be closed once next release is available
Projects
None yet
Development

No branches or pull requests

8 participants