feat(settings): support multiple auto query language exclusions - #1278
yaobii-lab wants to merge 1 commit into
Conversation
自动查询图标原先只能排除一种文本语言,多语言使用者仍会在熟悉语言上频繁看到查询入口。 将排除配置迁移为语言集合,并在高级设置中提供带勾选状态的语言菜单;升级时保留旧的单选配置。 自动查询判断现在会跳过集合中的任意语言,空集合表示全部语言都允许显示图标。 ---------------------------------------------------------------------- feat(settings): support multiple auto query language exclusions The auto query icon could previously exclude only one text language, so multilingual users still saw the query entry for languages they already understood. Migrate the exclusion setting to a language set and provide a checked language menu in Advanced settings while preserving the existing single-language value on upgrade. The auto query decision now skips every language in the set, and an empty set allows the icon for all languages.
There was a problem hiding this comment.
Pull request overview
This PR extends the “auto query icon” language exclusion setting from a single excluded language to a multi-select set, updates the Advanced settings UI accordingly, and adds a one-time migration path for existing users.
Changes:
- Replace the single-language picker with a menu of checked languages and a concise selection summary (empty = allow all languages).
- Switch configuration/storage from
autoShowQueryIconExcludedLanguage: LanguagetoautoShowQueryIconExcludedLanguages: Set<Language>. - Update the event-monitor decision path to honor multiple excluded languages and add a migration flag/key.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Easydict/Swift/View/SettingView/Tabs/TabView/AdvancedTab.swift | Replaces the single-language picker with a multi-select menu and displays a summary/“All languages” label. |
| Easydict/Swift/Utility/EventMonitor/Core/EventMonitor.swift | Updates auto-query icon gating logic to check membership in an excluded language set. |
| Easydict/Swift/Feature/Configuration/MyConfiguration.swift | Migrates legacy single-language preference to the new set-based key and observes the new key for logging. |
| Easydict/Swift/Feature/Configuration/Defaults.Keys+Extension.swift | Adds new Defaults keys for the excluded language set and a migration sentinel flag. |
| Easydict/App/Localizable.xcstrings | Adds a localized string for the “All languages” (empty exclusion) summary label. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fileprivate func didSetAutoShowQueryIconExcludedLanguages() { | ||
| logSettings(["auto_show_query_icon_excluded_languages": autoShowQueryIconExcludedLanguages.formattedDescription]) | ||
| } |
| let shouldShowAutoQueryIcon = !excludedLanguages.contains(detectedLanguage) | ||
| logInfo( | ||
| "detected language: \(detectedLanguage), excluded language: \(excludedLanguage), shouldShowAutoQueryIcon: \(shouldShowAutoQueryIcon)" | ||
| "detected language: \(detectedLanguage), excluded languages: \(excludedLanguages.formattedDescription), shouldShowAutoQueryIcon: \(shouldShowAutoQueryIcon)" |
| DispatchQueue.main.async { [weak self] in | ||
| guard let self else { return } | ||
| migrateAutoShowQueryIconExcludedLanguage() | ||
| observeKeys() | ||
| } |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a7281a86d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| static let autoShowQueryIconExcludedLanguages = Key<Set<Language>>( | ||
| "EZConfiguration_kAutoShowQueryIconExcludedLanguagesKey", default: [] | ||
| ) |
There was a problem hiding this comment.
Update the required directory overviews and diagrams
This change modifies files in Feature/Configuration and Utility/EventMonitor/Core, which each contain multiple direct source files but no required Chinese HTML overview or companion SVG, and it changes TabView without updating its overview/diagram (the existing overview is Markdown rather than the required HTML). Add or update those artifacts in this change so the documented configuration and event-monitor flows remain synchronized.
AGENTS.md reference: AGENTS.md:L164-L178
Useful? React with 👍 / 👎.
| private var excludedLanguagesSummary: String { | ||
| guard !autoShowQueryIconExcludedLanguages.isEmpty else { | ||
| return String(localized: "setting.advance.auto_show_query_icon.condition.language.none") |
There was a problem hiding this comment.
Describe an empty exclusion selection as none
When the set is empty, the control displays “All languages” next to the existing label “Show only when selected text language is not,” which tells users that all languages are excluded even though EventMonitor treats the empty set as excluding nothing. Display a value such as “None,” or adjust the surrounding label so the empty state accurately communicates that the icon is allowed for every language.
Useful? React with 👍 / 👎.
Summary
Verification
git diff --checkLocalizable.xcstringsas JSONNot run locally