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

Language preference #440

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@
62E2BF4B2B4082BA00E42D38 /* AliResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E2BF482B4082BA00E42D38 /* AliResponse.swift */; };
62E2BF4C2B4082BA00E42D38 /* AliTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E2BF492B4082BA00E42D38 /* AliTranslateType.swift */; };
62ED29A22B15F1F500901F51 /* EZWrapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62ED29A12B15F1F500901F51 /* EZWrapView.m */; };
6A47D40C2B9576050077B2F3 /* EZI18nHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A47D40B2B9576050077B2F3 /* EZI18nHelper.swift */; };
6A6352282B94603A00AD9FCF /* LanguageState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A6352272B94603A00AD9FCF /* LanguageState.swift */; };
960835502B6791F200C6A931 /* Shortcut+Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */; };
96099AE22B5D40330055C4DD /* ShortcutTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96099AE12B5D40330055C4DD /* ShortcutTab.swift */; };
9627F9382B59956800B1E999 /* GlobalShortcutSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9627F9352B59956800B1E999 /* GlobalShortcutSetting.swift */; };
Expand Down Expand Up @@ -792,6 +794,8 @@
62ED29A02B15F1F500901F51 /* EZWrapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZWrapView.h; sourceTree = "<group>"; };
62ED29A12B15F1F500901F51 /* EZWrapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZWrapView.m; sourceTree = "<group>"; };
6372B33DFF803C7096A82250 /* Pods_Easydict.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Easydict.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6A47D40B2B9576050077B2F3 /* EZI18nHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EZI18nHelper.swift; sourceTree = "<group>"; };
6A6352272B94603A00AD9FCF /* LanguageState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageState.swift; sourceTree = "<group>"; };
91E3E579C6DB88658B4BB102 /* Pods-Easydict.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Easydict.release.xcconfig"; path = "Target Support Files/Pods-Easydict/Pods-Easydict.release.xcconfig"; sourceTree = "<group>"; };
9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Validator.swift"; sourceTree = "<group>"; };
96099AE12B5D40330055C4DD /* ShortcutTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutTab.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2217,6 +2221,15 @@
path = EZWrapView;
sourceTree = "<group>";
};
6A47D40A2B9575C00077B2F3 /* LanguagePreference */ = {
isa = PBXGroup;
children = (
6A6352272B94603A00AD9FCF /* LanguageState.swift */,
6A47D40B2B9576050077B2F3 /* EZI18nHelper.swift */,
);
path = LanguagePreference;
sourceTree = "<group>";
};
713A345D86B5BC86D158B68F /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2260,6 +2273,7 @@
967712EB2B5B93E200105E0F /* Feature */ = {
isa = PBXGroup;
children = (
6A47D40A2B9575C00077B2F3 /* LanguagePreference */,
967712EC2B5B941600105E0F /* Shortcut */,
);
path = Feature;
Expand Down Expand Up @@ -2818,6 +2832,7 @@
03991158292927E000E1B06D /* EZTitlebar.m in Sources */,
03D8A65C2A433B4100D9A968 /* EZConfiguration+EZUserData.m in Sources */,
03BD282229486CF200F5891A /* EZBlueTextButton.m in Sources */,
6A47D40C2B9576050077B2F3 /* EZI18nHelper.swift in Sources */,
0AC8A8472B6A4E3F006DA5CC /* ServiceConfigurationSecretSectionView.swift in Sources */,
03BDA7C22A26DA280079D04F /* NSString+Indenter.m in Sources */,
03542A462937B4C300C34C33 /* EZBaiduTranslateResponse.m in Sources */,
Expand Down Expand Up @@ -3014,6 +3029,7 @@
03B0232A29231FA6001C7E63 /* NSColor+MyColors.m in Sources */,
C4DD01ED2B12BE9B0025EE8E /* TencentTranslateType.swift in Sources */,
0AC8A83D2B6685EE006DA5CC /* SecureTextField.swift in Sources */,
6A6352282B94603A00AD9FCF /* LanguageState.swift in Sources */,
0AC8A8372B6659A8006DA5CC /* NiuTransTranslate+ConfigurableService.swift in Sources */,
03D043562928940500E7559E /* EZBaseQueryWindow.m in Sources */,
03BDA7B92A26DA280079D04F /* NSProcessInfo+XPMArgumentParser.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,23 @@
}
}
},
"language_preference" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Language"
tisfeng marked this conversation as resolved.
Show resolved Hide resolved
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "语言"
tisfeng marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
},
"large" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
4 changes: 4 additions & 0 deletions Easydict/App/PrefixHeader.pch
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@
#import "EZConst.h"
#import "EZConstKey.h"
#import "NSString+EZConvenience.h"

#import "Easydict-Swift.h"

#define EZLocalizedString(key) ([EZI18nHelper localizedWithKey:key])
6 changes: 3 additions & 3 deletions Easydict/Feature/Configuration/Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ enum AppearenceType: Int, CaseIterable, Defaults.Serializable {
var title: String {
switch self {
case .followSystem:
NSLocalizedString("appearenceType_followSystem", comment: "")
"appearenceType_followSystem".localized
case .light:
NSLocalizedString("appearenceType_light", comment: "")
"appearenceType_light".localized
case .dark:
NSLocalizedString("appearenceType_dark", comment: "")
"appearenceType_dark".localized
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (void)setupAppModelList {

- (NSTextField *)titleTextField {
if (!_titleTextField) {
NSTextField *titleTextField = [NSTextField wrappingLabelWithString:NSLocalizedString(@"disabled_title", nil)];
NSTextField *titleTextField = [NSTextField wrappingLabelWithString:EZLocalizedString(@"disabled_title")];
[self.view addSubview:titleTextField];
titleTextField.font = [NSFont systemFontOfSize:14];
_titleTextField = titleTextField;
Expand Down Expand Up @@ -327,7 +327,7 @@ - (NSString *)viewIdentifier {
}

- (NSString *)toolbarItemLabel {
return NSLocalizedString(@"disabled_app_list", nil);
return EZLocalizedString(@"disabled_app_list");
}

- (NSImage *)toolbarItemImage {
Expand Down
14 changes: 7 additions & 7 deletions Easydict/Feature/PerferenceWindow/EZAboutViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ - (void)setupUI {


NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString *versionString = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"current_version", nil), version];
NSString *versionString = [NSString stringWithFormat:@"%@ %@", EZLocalizedString(@"current_version"), version];
NSTextField *versionValueTextField = [NSTextField labelWithString:versionString];
versionValueTextField.font = [NSFont systemFontOfSize:14];
[self.contentView addSubview:versionValueTextField];
self.currentVersionTextField = versionValueTextField;

NSString *autoCheckUpdateTitle = NSLocalizedString(@"auto_check_update", nil);
NSString *autoCheckUpdateTitle = EZLocalizedString(@"auto_check_update");
self.autoCheckUpdateButton = [NSButton checkboxWithTitle:autoCheckUpdateTitle target:self action:@selector(autoCheckUpdateButtonClicked:)];
[self.contentView addSubview:self.autoCheckUpdateButton];

NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", NSLocalizedString(@"lastest_version", nil), version];
NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", EZLocalizedString(@"lastest_version"), version];
NSTextField *latestVersionTextField = [NSTextField labelWithString:latestVersionString];
[self.contentView addSubview:latestVersionTextField];
self.latestVersionTextField = latestVersionTextField;

self.authorView = [[NSView alloc] init];
[self.contentView addSubview:self.authorView];

NSTextField *authorTextField = [NSTextField labelWithString:NSLocalizedString(@"author", nil)];
NSTextField *authorTextField = [NSTextField labelWithString:EZLocalizedString(@"author")];
[self.authorView addSubview:authorTextField];
self.authorTextField = authorTextField;

Expand All @@ -103,7 +103,7 @@ - (void)setupUI {
authorLinkButton.openURL = authorURL; // https://github.com/tisfeng
authorLinkButton.closeWindowAfterOpeningURL = YES;

NSTextField *githubTextField = [NSTextField labelWithString:NSLocalizedString(@"GitHub:", nil)];
NSTextField *githubTextField = [NSTextField labelWithString:EZLocalizedString(@"GitHub:")];
[self.contentView addSubview:githubTextField];
self.githubTextField = githubTextField;

Expand Down Expand Up @@ -183,7 +183,7 @@ - (void)autoCheckUpdateButtonClicked:(NSButton *)sender {

- (void)updateLatestVersion {
[EZMenuItemManager.shared fetchRepoLatestVersion:EZGithubRepoEasydict completion:^(NSString *latestVersion) {
NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", NSLocalizedString(@"lastest_version", nil), latestVersion];
NSString *latestVersionString = [NSString stringWithFormat:@"(%@ %@)", EZLocalizedString(@"lastest_version"), latestVersion];
self.latestVersionTextField.stringValue = latestVersionString;
}];
}
Expand All @@ -207,7 +207,7 @@ - (NSString *)viewIdentifier {
}

- (NSString *)toolbarItemLabel {
return NSLocalizedString(@"about", nil);
return EZLocalizedString(@"about");
}

- (NSImage *)toolbarItemImage {
Expand Down
20 changes: 10 additions & 10 deletions Easydict/Feature/PerferenceWindow/EZPrivacyViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ - (void)viewDidLoad {
}

- (void)setupUI {
self.privacyStatementTextField = [NSTextField labelWithString:NSLocalizedString(@"privacy_statement", nil)];
self.privacyStatementTextField = [NSTextField labelWithString:EZLocalizedString(@"privacy_statement")];
[self.contentView addSubview:self.privacyStatementTextField];
self.privacyStatementTextField.font = [NSFont systemFontOfSize:14];

self.privacyStatementContentTextField = [NSTextField wrappingLabelWithString:NSLocalizedString(@"privacy_statement_content", nil)];
self.privacyStatementContentTextField = [NSTextField wrappingLabelWithString:EZLocalizedString(@"privacy_statement_content")];
[self.contentView addSubview:self.privacyStatementContentTextField];
self.privacyStatementContentTextField.preferredMaxLayoutWidth = 380;


self.crashLogTextField = [NSTextField labelWithString:NSLocalizedString(@"crash_log", nil)];
self.crashLogTextField = [NSTextField labelWithString:EZLocalizedString(@"crash_log")];
[self.contentView addSubview:self.crashLogTextField];

self.crashLogButton = [NSButton checkboxWithTitle:NSLocalizedString(@"allow_collect_crash_log", nil)
self.crashLogButton = [NSButton checkboxWithTitle:EZLocalizedString(@"allow_collect_crash_log")
target:self
action:@selector(crashLogButtonClicked:)];
[self.contentView addSubview:self.crashLogButton];

self.analyticsTextField = [NSTextField labelWithString:NSLocalizedString(@"analytics", nil)];
self.analyticsTextField = [NSTextField labelWithString:EZLocalizedString(@"analytics")];
[self.contentView addSubview:self.analyticsTextField];

self.analyticsButton = [NSButton checkboxWithTitle:NSLocalizedString(@"allow_collect_analytics", nil)
self.analyticsButton = [NSButton checkboxWithTitle:EZLocalizedString(@"allow_collect_analytics")
target:self
action:@selector(analyticsButtonClicked:)];
[self.contentView addSubview:self.analyticsButton];
Expand Down Expand Up @@ -111,9 +111,9 @@ - (void)updateViewConstraints {
- (void)crashLogButtonClicked:(NSButton *)sender {
if (!sender.mm_isOn) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"ok", nil)];
[alert addButtonWithTitle:NSLocalizedString(@"cancel", nil)];
alert.messageText = NSLocalizedString(@"disable_crash_log_warning", nil);
[alert addButtonWithTitle:EZLocalizedString(@"ok")];
[alert addButtonWithTitle:EZLocalizedString(@"cancel")];
alert.messageText = EZLocalizedString(@"disable_crash_log_warning");
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
// ok, disable crash log
if (returnCode == NSAlertFirstButtonReturn) {
Expand All @@ -140,7 +140,7 @@ - (NSString *)viewIdentifier {
}

- (NSString *)toolbarItemLabel {
return NSLocalizedString(@"privacy", nil);
return EZLocalizedString(@"privacy");
}

- (NSImage *)toolbarItemImage {
Expand Down
Loading