Skip to content

Commit

Permalink
perf: do not check spell if text language is not in the checker suppo…
Browse files Browse the repository at this point in the history
…rted language list
  • Loading branch information
tisfeng committed Dec 5, 2023
1 parent 6c4b7d5 commit d6d81aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Easydict/Feature/Service/Apple/EZAppleService.m
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,13 @@ - (EZLanguage)getMostConfidentLanguage:(NSDictionary<NLLanguage, NSNumber *> *)d
if ([text isWord]) {
for (NLLanguage language in sortedLanguages) {
EZLanguage ezLang = [self languageEnumFromAppleLanguage:language];
NSString *sepllCheckerLanguage = [[self spellCheckerLanguagesDictionary] objectForKey:ezLang];
if (sepllCheckerLanguage && [text isSpelledCorrectly:sepllCheckerLanguage]) {
NSString *spellCheckerLanguage = [[self spellCheckerLanguagesDictionary] objectForKey:ezLang];
// If text language is not in the list of languages that support checking spelling, such as Indonesian, break.
if (!spellCheckerLanguage) {
break;
}

if ([text isSpelledCorrectly:spellCheckerLanguage]) {
NSLog(@"Spell check language: %@", ezLang);
return ezLang;
}
Expand Down

0 comments on commit d6d81aa

Please sign in to comment.