Skip to content

Commit

Permalink
remove the EZ prefix in swift.
Browse files Browse the repository at this point in the history
  • Loading branch information
choykarl committed Mar 23, 2024
1 parent 1a43d30 commit 2f98f60
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@
62E2BF4C2B4082BA00E42D38 /* AliTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E2BF492B4082BA00E42D38 /* AliTranslateType.swift */; };
62ED29A22B15F1F500901F51 /* EZWrapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62ED29A12B15F1F500901F51 /* EZWrapView.m */; };
6A8C988E2BAC88B500DB835A /* LanguageState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8C988C2BAC88B500DB835A /* LanguageState.swift */; };
6A8C988F2BAC88B500DB835A /* EZI18nHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8C988D2BAC88B500DB835A /* EZI18nHelper.swift */; };
6A8C98952BAE841600DB835A /* EZLocalizedBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8C98942BAE841600DB835A /* EZLocalizedBundle.swift */; };
6A8C988F2BAC88B500DB835A /* I18nHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8C988D2BAC88B500DB835A /* I18nHelper.swift */; };
6A8C98952BAE841600DB835A /* LocalizedBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8C98942BAE841600DB835A /* LocalizedBundle.swift */; };
6ADED1552BAE8809004A15BE /* NSBundle+LanguagePreference.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ADED1542BAE8809004A15BE /* NSBundle+LanguagePreference.m */; };
960835502B6791F200C6A931 /* Shortcut+Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */; };
96099AE22B5D40330055C4DD /* ShortcutTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96099AE12B5D40330055C4DD /* ShortcutTab.swift */; };
Expand Down Expand Up @@ -805,8 +805,8 @@
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; };
6A8C988C2BAC88B500DB835A /* LanguageState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageState.swift; sourceTree = "<group>"; };
6A8C988D2BAC88B500DB835A /* EZI18nHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EZI18nHelper.swift; sourceTree = "<group>"; };
6A8C98942BAE841600DB835A /* EZLocalizedBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EZLocalizedBundle.swift; sourceTree = "<group>"; };
6A8C988D2BAC88B500DB835A /* I18nHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = I18nHelper.swift; sourceTree = "<group>"; };
6A8C98942BAE841600DB835A /* LocalizedBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedBundle.swift; sourceTree = "<group>"; };
6ADED1542BAE8809004A15BE /* NSBundle+LanguagePreference.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+LanguagePreference.m"; 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>"; };
Expand Down Expand Up @@ -2252,9 +2252,9 @@
6A8C988B2BAC88A600DB835A /* LanguagePreference */ = {
isa = PBXGroup;
children = (
6A8C988D2BAC88B500DB835A /* EZI18nHelper.swift */,
6A8C988D2BAC88B500DB835A /* I18nHelper.swift */,
6A8C988C2BAC88B500DB835A /* LanguageState.swift */,
6A8C98942BAE841600DB835A /* EZLocalizedBundle.swift */,
6A8C98942BAE841600DB835A /* LocalizedBundle.swift */,
6ADED1542BAE8809004A15BE /* NSBundle+LanguagePreference.m */,
);
path = LanguagePreference;
Expand Down Expand Up @@ -2948,7 +2948,7 @@
03B0230229231FA6001C7E63 /* EZWordResultView.m in Sources */,
0399C6A529A747E600B4AFCC /* EZDeepLTranslateResponse.m in Sources */,
17BCAEF82B0DFF9000A7D372 /* EZNiuTransTranslate.m in Sources */,
6A8C98952BAE841600DB835A /* EZLocalizedBundle.swift in Sources */,
6A8C98952BAE841600DB835A /* LocalizedBundle.swift in Sources */,
039F5506294B6E29004AB940 /* EZSettingViewController.m in Sources */,
03BD281E29481C0400F5891A /* EZAudioPlayer.m in Sources */,
0A8685C82B552A590022534F /* DisabledAppTab.swift in Sources */,
Expand Down Expand Up @@ -3030,7 +3030,7 @@
03B0232829231FA6001C7E63 /* NSTextView+Height.m in Sources */,
03B0232129231FA6001C7E63 /* NSPasteboard+MM.m in Sources */,
03D043522928935300E7559E /* EZMainQueryWindow.m in Sources */,
6A8C988F2BAC88B500DB835A /* EZI18nHelper.swift in Sources */,
6A8C988F2BAC88B500DB835A /* I18nHelper.swift in Sources */,
03D8B26E292DBD2000D5A811 /* EZCoordinateUtils.m in Sources */,
03B0232029231FA6001C7E63 /* NSWindow+MM.m in Sources */,
0AC8A8432B6957B0006DA5CC /* BingService+ConfigurableService.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ extension Notification.Name {
static let serviceHasUpdated = Notification.Name(EZServiceHasUpdatedNotification)

static let openSettings = Notification.Name(EZOpenSettingsNotification)

static let languagePreferenceChanged = Notification.Name(I18nHelper.languagePreferenceChangedNotification)
}

@objc
extension NSNotification {
public static let serviceHasUpdated = Notification.Name.serviceHasUpdated

public static let openSettings = Notification.Name.openSettings

public static let languagePreferenceChanged = Notification.Name.languagePreferenceChanged
}
4 changes: 2 additions & 2 deletions Easydict/NewApp/EasydictApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct EasydictApp: App {
MenuBarExtra(isInserted: $hideMenuBar.toggledValue) {
MenuItemView()
.environmentObject(languageState)
.environment(\.locale, .init(identifier: EZI18nHelper.shared.localizeCode))
.environment(\.locale, .init(identifier: I18nHelper.shared.localizeCode))
} label: {
Label {
Text("Easydict")
Expand Down Expand Up @@ -66,7 +66,7 @@ struct EasydictApp: App {
Settings {
SettingView().environmentObject(languageState).environment(
\.locale,
.init(identifier: EZI18nHelper.shared.localizeCode)
.init(identifier: I18nHelper.shared.localizeCode)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

import SwiftUI

// MARK: - EZI18nHelper
// MARK: - I18nHelper

@objcMembers
class EZI18nHelper: NSObject {
@objc(EZI18nHelper)
class I18nHelper: NSObject {
static let languagePreferenceChangedNotification = "EZLanguagePreferenceChangedNotification"
static let shared = EZI18nHelper()
static let shared = I18nHelper()

var localizedBundle: Bundle {
let res = localizeCode
Expand Down
5 changes: 1 addition & 4 deletions Easydict/NewApp/LanguagePreference/LanguageState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ class LanguageState: ObservableObject {
rawValue: Locale.current.identifier
) ?? .simplifiedChinese) {
didSet {
NotificationCenter.default.post(
name: NSNotification.Name(rawValue: EZI18nHelper.languagePreferenceChangedNotification),
object: nil
)
NotificationCenter.default.post(name: .languagePreferenceChanged, object: nil)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

import Foundation

class EZLocalizedBundle: Bundle {
@objc(EZLocalizedBundle)
class LocalizedBundle: Bundle {
override func localizedString(forKey key: String, value: String?, table tableName: String?) -> String {
EZI18nHelper.shared.localizedBundle.localizedString(forKey: key, value: value, table: tableName)
I18nHelper.shared.localizedBundle.localizedString(forKey: key, value: value, table: tableName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension Language {
}

public var localizedName: String {
if EZI18nHelper.shared.isSimplifiedChineseLocalize {
if I18nHelper.shared.isSimplifiedChineseLocalize {
chineseName
} else {
if self == .auto {
Expand Down

0 comments on commit 2f98f60

Please sign in to comment.