Add localized strings (#365)

This commit is contained in:
Nathan Mattes 2022-11-06 09:22:26 +01:00
parent 28749b5029
commit 18720a9a51
4 changed files with 50 additions and 30 deletions

View File

@ -205,42 +205,45 @@ extension DataSourceFacade {
menuContext: MenuContext menuContext: MenuContext
) async throws { ) async throws {
switch action { switch action {
case .hideReblogs(let actionContext): case .hideReblogs(let actionContext):
//FIXME: Add localized strings let title = actionContext.showReblogs ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.title : L10n.Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.title
let alertController = UIAlertController( let message = actionContext.showReblogs ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.message : L10n.Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.message
title: actionContext.showReblogs ? "Really hide?" : "Really show?",
message: actionContext.showReblogs ? "Really??" : "Really??",
preferredStyle: .alert
)
let showHideReblogsAction = UIAlertAction( let alertController = UIAlertController(
title: actionContext.showReblogs ? "Show" : "Hide", title: title,
style: .default message: message,
) { [weak dependency] _ in preferredStyle: .alert
guard let dependency else { return } )
Task { let actionTitle = actionContext.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.showReblogs
let managedObjectContext = dependency.context.managedObjectContext let showHideReblogsAction = UIAlertAction(
let _user: ManagedObjectRecord<MastodonUser>? = try? await managedObjectContext.perform { title: actionTitle,
guard let user = menuContext.author?.object(in: managedObjectContext) else { return nil } style: .destructive
return ManagedObjectRecord<MastodonUser>(objectID: user.objectID) ) { [weak dependency] _ in
} guard let dependency else { return }
guard let user = _user else { return } Task {
let managedObjectContext = dependency.context.managedObjectContext
let _user: ManagedObjectRecord<MastodonUser>? = try? await managedObjectContext.perform {
guard let user = menuContext.author?.object(in: managedObjectContext) else { return nil }
return ManagedObjectRecord<MastodonUser>(objectID: user.objectID)
}
try await DataSourceFacade.responseToShowHideReblogAction( guard let user = _user else { return }
dependency: dependency,
user: user
)
}
}
alertController.addAction(showHideReblogsAction) try await DataSourceFacade.responseToShowHideReblogAction(
dependency: dependency,
user: user
)
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) alertController.addAction(showHideReblogsAction)
alertController.addAction(cancelAction)
dependency.present(alertController, animated: true) let cancelAction = UIAlertAction(title: L10n.Common.Controls.Actions.cancel, style: .cancel)
alertController.addAction(cancelAction)
dependency.present(alertController, animated: true)
case .muteUser(let actionContext): case .muteUser(let actionContext):
let alertController = UIAlertController( let alertController = UIAlertController(
title: actionContext.isMuting ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.title : L10n.Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.title, title: actionContext.isMuting ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.title : L10n.Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.title,

View File

@ -713,6 +713,12 @@ public enum L10n {
/// Block Account /// Block Account
public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Title") public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Title")
} }
public enum ConfirmHideReblogs {
/// Confirm to hide reblogs
public static let message = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Message")
/// Hide reblogs
public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Title")
}
public enum ConfirmMuteUser { public enum ConfirmMuteUser {
/// Confirm to mute %@ /// Confirm to mute %@
public static func message(_ p1: Any) -> String { public static func message(_ p1: Any) -> String {
@ -721,6 +727,12 @@ public enum L10n {
/// Mute Account /// Mute Account
public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.Title") public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.Title")
} }
public enum ConfirmShowReblogs {
/// Confirm to show reblogs
public static let message = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Message")
/// Show Reblogs
public static let title = L10n.tr("Localizable", "Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Title")
}
public enum ConfirmUnblockUser { public enum ConfirmUnblockUser {
/// Confirm to unblock %@ /// Confirm to unblock %@
public static func message(_ p1: Any) -> String { public static func message(_ p1: Any) -> String {

View File

@ -79,6 +79,7 @@ Please check your internet connection.";
"Common.Controls.Friendship.UnmuteUser" = "Unmute %@"; "Common.Controls.Friendship.UnmuteUser" = "Unmute %@";
"Common.Controls.Friendship.HideReblogs" = "Hide Reblogs"; "Common.Controls.Friendship.HideReblogs" = "Hide Reblogs";
"Common.Controls.Friendship.ShowReblogs" = "Show Reblogs"; "Common.Controls.Friendship.ShowReblogs" = "Show Reblogs";
"Common.Controls.Keyboard.Common.ComposeNewPost" = "Compose New Post"; "Common.Controls.Keyboard.Common.ComposeNewPost" = "Compose New Post";
"Common.Controls.Keyboard.Common.OpenSettings" = "Open Settings"; "Common.Controls.Keyboard.Common.OpenSettings" = "Open Settings";
"Common.Controls.Keyboard.Common.ShowFavorites" = "Show Favorites"; "Common.Controls.Keyboard.Common.ShowFavorites" = "Show Favorites";
@ -264,6 +265,10 @@ uploaded to Mastodon.";
"Scene.Profile.RelationshipActionAlert.ConfirmUnblockUser.Title" = "Unblock Account"; "Scene.Profile.RelationshipActionAlert.ConfirmUnblockUser.Title" = "Unblock Account";
"Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Message" = "Confirm to unmute %@"; "Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Message" = "Confirm to unmute %@";
"Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Title" = "Unmute Account"; "Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Title" = "Unmute Account";
"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Message" = "Confirm to show reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Title" = "Show Reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Message" = "Confirm to hide reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Title" = "Hide reblogs";
"Scene.Profile.SegmentedControl.About" = "About"; "Scene.Profile.SegmentedControl.About" = "About";
"Scene.Profile.SegmentedControl.Media" = "Media"; "Scene.Profile.SegmentedControl.Media" = "Media";
"Scene.Profile.SegmentedControl.Posts" = "Posts"; "Scene.Profile.SegmentedControl.Posts" = "Posts";

View File

@ -52,7 +52,7 @@ extension MastodonMenu {
func build(delegate: MastodonMenuDelegate) -> BuiltAction { func build(delegate: MastodonMenuDelegate) -> BuiltAction {
switch self { switch self {
case .hideReblogs(let context): case .hideReblogs(let context):
let title = context.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.hideReblogs let title = context.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.showReblogs
let reblogAction = BuiltAction( let reblogAction = BuiltAction(
title: title, title: title,
image: UIImage(systemName: "arrow.2.squarepath") image: UIImage(systemName: "arrow.2.squarepath")