diff --git a/App/App_iOS.swift b/App/App_iOS.swift index 9e173af2..de2ed2a6 100644 --- a/App/App_iOS.swift +++ b/App/App_iOS.swift @@ -19,9 +19,6 @@ struct Kiwix: App { private let fileMonitor: DirectoryMonitor init() { - if let enforcedLanguage: String = Config.value(for: .enforcedLanguage) { - DefaultLanguages.enforce(language: enforcedLanguage) - } fileMonitor = DirectoryMonitor(url: URL.documentDirectory) { LibraryOperations.scanDirectory($0) } LibraryOperations.registerBackgroundTask() UNUserNotificationCenter.current().delegate = appDelegate diff --git a/App/App_macOS.swift b/App/App_macOS.swift index 205d97d0..5eea9c09 100644 --- a/App/App_macOS.swift +++ b/App/App_macOS.swift @@ -19,9 +19,6 @@ struct Kiwix: App { private let notificationCenterDelegate = NotificationCenterDelegate() init() { - if let enforcedLanguage: String = Config.value(for: .enforcedLanguage) { - DefaultLanguages.enforce(language: enforcedLanguage) - } UNUserNotificationCenter.current().delegate = notificationCenterDelegate } diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj index d335a795..f75bfdf4 100644 --- a/Kiwix.xcodeproj/project.pbxproj +++ b/Kiwix.xcodeproj/project.pbxproj @@ -113,7 +113,6 @@ 9882080D2B2CF57A00D6B1AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 988207FE2B2CF57A00D6B1AE /* Localizable.strings */; }; 9882080E2B2CF57A00D6B1AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 988208012B2CF57A00D6B1AE /* Localizable.strings */; }; 9882080F2B2CF57A00D6B1AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 988208042B2CF57A00D6B1AE /* Localizable.strings */; }; - 98B5D3252B2F36680047CC13 /* DefaultLanguages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5D3242B2F36680047CC13 /* DefaultLanguages.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -258,7 +257,6 @@ 988207FF2B2CF57A00D6B1AE /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Localizable.strings; sourceTree = ""; }; 988208022B2CF57A00D6B1AE /* mk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = mk; path = Localizable.strings; sourceTree = ""; }; 988208052B2CF57A00D6B1AE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizable.strings; sourceTree = ""; }; - 98B5D3242B2F36680047CC13 /* DefaultLanguages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultLanguages.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -571,7 +569,6 @@ 97E94B26271EF359005B0295 /* Support */ = { isa = PBXGroup; children = ( - 98B5D3242B2F36680047CC13 /* DefaultLanguages.swift */, 988207FD2B2CF57A00D6B1AE /* de.lproj */, 988208032B2CF57A00D6B1AE /* en.lproj */, 988207EE2B2CF57A00D6B1AE /* he.lproj */, @@ -946,7 +943,6 @@ 974E7EE92930201500BDF59C /* ZimFileService.swift in Sources */, 973A0DFD283100C300B41E71 /* ZimFilesOpened.swift in Sources */, 9744068A28CF65AE00916BD4 /* LibraryOperations.swift in Sources */, - 98B5D3252B2F36680047CC13 /* DefaultLanguages.swift in Sources */, 972DE4B62814A502004FD9B9 /* Enum.swift in Sources */, 9744068728CE263800916BD4 /* DirectoryMonitor.swift in Sources */, 974C33A9285589E900DF6F4C /* Patches.swift in Sources */, diff --git a/Model/Brand.swift b/Model/Brand.swift index 9cd7ecb5..a4114288 100644 --- a/Model/Brand.swift +++ b/Model/Brand.swift @@ -66,7 +66,6 @@ enum Config: String { case showSearchSnippetInSettings = "SETTINGS_SHOW_SEARCH_SNIPPET" case aboutText = "CUSTOM_ABOUT_TEXT" case aboutWebsite = "CUSTOM_ABOUT_WEBSITE" - case enforcedLanguage = "ENFORCED_LANGUAGE" static func value(for key: Config) -> T? where T: LosslessStringConvertible { guard let object = Bundle.main.object(forInfoDictionaryKey: key.rawValue) else { diff --git a/Model/Utilities/String+Extension.swift b/Model/Utilities/String+Extension.swift index 65e6ad7a..49b31a56 100644 --- a/Model/Utilities/String+Extension.swift +++ b/Model/Utilities/String+Extension.swift @@ -28,7 +28,7 @@ extension String { } private func localizedWithFallback( - bundle: Bundle = DefaultLanguages.currentBundle, + bundle: Bundle = Bundle.main, comment: String = "" ) -> String { let englishValue: String diff --git a/Support/DefaultLanguages.swift b/Support/DefaultLanguages.swift deleted file mode 100644 index bc36b4d6..00000000 --- a/Support/DefaultLanguages.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// DefaultLanguages.swift -// Kiwix -// - -import Foundation -import Defaults - -/// Enforce the selected languages on start up time -/// It fully works on 2nd launch, as @main cannot be easily overriden in SwiftUI -/// For the first launch we can override the bundle we use for localization -enum DefaultLanguages { - /// We need a work around bundle with a specific - static var currentBundle: Bundle = Bundle.main - - static func enforce(language: String) { - if UserDefaults.standard[.isFirstLaunch] { - UserDefaults.standard[.isFirstLaunch] = false - // override the system picked languages at start - UserDefaults.standard.set([language], forKey: "AppleLanguages") - - // override the bundle used on first launch of the app: - if let path = Bundle.main.path(forResource: language, ofType: "lproj") { - if let langBundle = Bundle.init(path: path) { - currentBundle = langBundle - } - } - } - } -}