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

Remvoe all custom localization from Frameworks #1782

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import RuuviLocalization
import SwiftUI
import UIKit

private enum ActivityPresenterAssets {
static let activityOngoingDefault = "activity_ongoing_generic"
static let activitySuccessDefault = "activity_success_generic"
static let activityFailedDefault = "activity_failed_generic"

static let activityLogoRuuvi = "ruuvi_activity_presenter_logo"
}

Expand Down Expand Up @@ -84,25 +81,22 @@ struct ActivityPresenterContentView: View {
if let message {
message
} else {
ActivityPresenterAssets
.activityOngoingDefault
.localized(for: ActivityPresenterViewProvider.self)
RuuviLocalization
.activityOngoingGeneric
}
case let .success(message):
if let message {
message
} else {
ActivityPresenterAssets
.activitySuccessDefault
.localized(for: ActivityPresenterViewProvider.self)
RuuviLocalization
.activitySuccessGeneric
}
case let .failed(message):
if let message {
message
} else {
ActivityPresenterAssets
.activityFailedDefault
.localized(for: ActivityPresenterViewProvider.self)
RuuviLocalization
.activityFailedGeneric
}
case .dismiss:
"" // Placeholder for dismiss state
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import RuuviLocalization
import UIKit

public final class ErrorPresenterAlert: ErrorPresenter {
Expand All @@ -8,13 +9,13 @@ public final class ErrorPresenterAlert: ErrorPresenter {
}

private func presentAlert(error: Error) {
var title: String? = "ErrorPresenterAlert.Error".localized(for: Self.self)
var title: String? = RuuviLocalization.ErrorPresenterAlert.error
if let localizedError = error as? LocalizedError {
title = localizedError.failureReason ?? "ErrorPresenterAlert.Error".localized(for: Self.self)
title = localizedError.failureReason ?? RuuviLocalization.ErrorPresenterAlert.error
}
let alert = UIAlertController(title: title, message: error.localizedDescription, preferredStyle: .alert)
let action = UIAlertAction(
title: "ErrorPresenterAlert.OK".localized(for: Self.self),
title: RuuviLocalization.ErrorPresenterAlert.ok,
style: .cancel,
handler: nil
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import RuuviLocalization
import UIKit

public final class PermissionPresenterAlert: PermissionPresenter {
public init() {}

public func presentNoPhotoLibraryPermission() {
let message = "PermissionPresenter.NoPhotoLibraryAccess.message".localized(for: Self.self)
let message = RuuviLocalization.PermissionPresenter.NoPhotoLibraryAccess.message
presentAlert(with: message)
}

public func presentNoCameraPermission() {
let message = "PermissionPresenter.NoCameraAccess.message".localized(for: Self.self)
let message = RuuviLocalization.PermissionPresenter.NoCameraAccess.message
presentAlert(with: message)
}

public func presentNoLocationPermission() {
let message = "PermissionPresenter.NoLocationAccess.message".localized(for: Self.self)
let message = RuuviLocalization.PermissionPresenter.NoLocationAccess.message
presentAlert(with: message)
}

public func presentNoPushNotificationsPermission() {
let message = "PermissionPresenter.NoPushNotificationsPermission.message".localized(for: Self.self)
let message = RuuviLocalization.PermissionPresenter.NoPushNotificationsPermission.message
presentAlert(with: message)
}

private func presentAlert(with message: String) {
guard let viewController = UIApplication.shared.topViewController() else { return }
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let cancel = UIAlertAction(title: "Cancel".localized(for: Self.self), style: .cancel, handler: nil)
let actionTitle = "PermissionPresenter.settings".localized(for: Self.self)
let cancel = UIAlertAction(title: RuuviLocalization.cancel, style: .cancel, handler: nil)
let actionTitle = RuuviLocalization.PermissionPresenter.settings
let settings = UIAlertAction(title: actionTitle, style: .default) { _ in
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsUrl, options: [:])
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,6 @@ public extension UIImage {
}
}

extension String {
public func localized(for clazz: AnyClass) -> String {
let bundle: Bundle
#if SWIFT_PACKAGE
bundle = Bundle.module
#else
bundle = Bundle.pod(clazz)
#endif
if let module = NSStringFromClass(clazz).components(separatedBy: ".").first {
if let path = bundle.path(forResource: currentLanguage(), ofType: "lproj"),
let bundle = Bundle(path: path) {
return bundle.localizedString(forKey: self, value: nil, table: module)
} else if let path = bundle.path(forResource: "Base", ofType: "lproj"),
let bundle = Bundle(path: path) {
return bundle.localizedString(forKey: self, value: nil, table: module)
} else {
assertionFailure()
return self
}
} else {
assertionFailure()
return self
}
}

private func currentLanguage() -> String {
if let preferred = Bundle.main.preferredLocalizations.first {
preferred
} else {
"Base"
}
}
}

public extension UIStoryboard {
static func named(_ name: String, for clazz: AnyClass) -> UIStoryboard {
let bundle: Bundle
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading