Skip to content

Commit d206bc7

Browse files
authored
Update for CodeEditApp#334, Support localized items (CodeEditApp#359)
* Include commit hash for debug/copy information * Update for CodeEditApp#334, Support localized items * Commit hash to Placeholder
1 parent f9de9c0 commit d206bc7

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

CodeEditModules/Modules/CodeFile/src/TextView/CodeEditorTextView.swift

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -181,26 +181,39 @@ public class CodeEditorTextView: NSTextView {
181181
///
182182
/// The only problem currently is how well it would work with other languages.
183183
func removeMenus(_ menu: NSMenu) -> NSMenu {
184-
for action in ["No Guesses Found",
185-
"Learn Spelling",
186-
"Ignore Spelling",
187-
"Search With Google",
188-
"Translate",
189-
"Spelling and Grammar",
190-
"Substitutions",
191-
"Transformations",
192-
"Speech",
193-
"Share",
194-
"Search With Google",
195-
"Font",
196-
"Services"] {
197-
let index = menu.indexOfItem(withTitle: action)
198-
if index > -1 {
199-
menu.removeItem(at: index)
184+
let removeItemsContaining = [
185+
// Learn Spelling
186+
"_learnSpellingFromMenu:",
187+
188+
// Ignore Spelling
189+
"_ignoreSpellingFromMenu:",
190+
191+
// Spelling suggestion
192+
"_changeSpellingFromMenu:",
193+
194+
// Search with Google
195+
"_searchWithGoogleFromMenu:",
196+
197+
// Share, Font, Spelling and Grammar, Substitutions, Transformations
198+
// Speech, Layout Orientation
199+
"submenuAction:",
200+
201+
// Lookup, Translate
202+
"_rvMenuItemAction"
203+
]
204+
205+
for item in menu.items {
206+
if let itemAction = item.action {
207+
if removeItemsContaining.contains(String(describing: itemAction)) {
208+
// Get localized item name, and remove it.
209+
let index = menu.indexOfItem(withTitle: item.title)
210+
if index >= 0 {
211+
menu.removeItem(at: index)
212+
}
213+
}
200214
}
201215
}
202216

203217
return menu
204218
}
205-
206219
}

0 commit comments

Comments
 (0)