Skip to content

Commit

Permalink
perf: use config first langauge instead language manager userFirstLan…
Browse files Browse the repository at this point in the history
…guage
  • Loading branch information
tisfeng committed Nov 17, 2023
1 parent 51cc85f commit c90c8b7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Easydict/Feature/Service/Apple/EZAppleService.m
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ - (EZLanguage)appleDetectTextLanguage:(NSString *)text printLog:(BOOL)logFlag {

// !!!: Numbers will be return empty dict @{}: 729
if (languageProbabilityDict.count == 0) {
EZLanguage firstLanguage = [self.languageManager userFirstLanguage];
EZLanguage firstLanguage = EZConfiguration.shared.firstLanguage;
dominantLanguage = [self appleLanguageFromLanguageEnum:firstLanguage];
languageProbabilityDict = @{dominantLanguage : @(0)};
}
Expand Down
3 changes: 0 additions & 3 deletions Easydict/Feature/Service/Language/EZLanguageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
/// preferredLanguages = userPreferredTwoLanguages + systemPreferredLanguages, remove the same language
@property (nonatomic, copy, readonly) NSArray<EZLanguage> *preferredLanguages;

@property (nonatomic, copy, readonly) EZLanguage userFirstLanguage;
@property (nonatomic, copy, readonly) EZLanguage userSecondLanguage;

@property (nonatomic, copy, readonly) NSArray<EZLanguage> *allLanguages;

/// <EZLanguageEnglish : 🇬🇧 英语>
Expand Down
6 changes: 3 additions & 3 deletions Easydict/Feature/Service/OpenAI/EZOpenAIService.m
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage

/// Sentence messages.
- (NSArray<NSDictionary *> *)sentenceMessages:(NSString *)sentence from:(EZLanguage)sourceLanguage to:(EZLanguage)targetLanguage {
NSString *answerLanguage = [EZLanguageManager.shared userFirstLanguage];
NSString *answerLanguage = EZConfiguration.shared.firstLanguage;
self.result.to = answerLanguage;

NSString *prompt = @"";
Expand Down Expand Up @@ -955,7 +955,7 @@ - (NSArray *)translatioMessages:(NSString *)text from:(EZLanguage)sourceLanguage
// V5. prompt
NSString *prompt = @"";

NSString *answerLanguage = [EZLanguageManager.shared userFirstLanguage];
NSString *answerLanguage = EZConfiguration.shared.firstLanguage;
self.result.to = answerLanguage;

NSString *pronunciation = @"Pronunciation";
Expand Down Expand Up @@ -1413,7 +1413,7 @@ - (NSString *)getChineseLanguageType:(NSString *)language accordingToLanguage:(N
- (NSArray<NSDictionary *> *)jsonDictPromptMessages:(NSString *)word from:(EZLanguage)sourceLanguage to:(EZLanguage)targetLanguage {
NSString *prompt = @"";

NSString *answerLanguage = [EZLanguageManager.shared userFirstLanguage];
NSString *answerLanguage = EZConfiguration.shared.firstLanguage;
NSString *translationLanguageTitle = targetLanguage;

BOOL isEnglishWord = NO;
Expand Down
4 changes: 2 additions & 2 deletions Easydict/Feature/Utility/AppleScript/EZAppleScriptManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "EZAppleScriptManager.h"
#import "EZLanguageManager.h"
#import "EZConfiguration.h"

@interface EZAppleScriptManager ()

Expand Down Expand Up @@ -225,7 +225,7 @@ - (void)checkApplicationSupportCopyAction:(NSString *)appBundleID completion:(vo
NSString *edit;

if (!appLanguage) {
appLanguage = [EZLanguageManager.shared userFirstLanguage];
appLanguage = EZConfiguration.shared.firstLanguage;
}

if ([appLanguage isEqualToString:EZLanguageEnglish]) {
Expand Down

0 comments on commit c90c8b7

Please sign in to comment.