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
) async throws {
switch action {
case .hideReblogs(let actionContext):
//FIXME: Add localized strings
let alertController = UIAlertController(
title: actionContext.showReblogs ? "Really hide?" : "Really show?",
message: actionContext.showReblogs ? "Really??" : "Really??",
preferredStyle: .alert
)
case .hideReblogs(let actionContext):
let title = actionContext.showReblogs ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.title : L10n.Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.title
let message = actionContext.showReblogs ? L10n.Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.message : L10n.Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.message
let showHideReblogsAction = UIAlertAction(
title: actionContext.showReblogs ? "Show" : "Hide",
style: .default
) { [weak dependency] _ in
guard let dependency else { return }
let alertController = UIAlertController(
title: title,
message: message,
preferredStyle: .alert
)
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)
}
let actionTitle = actionContext.showReblogs ? L10n.Common.Controls.Friendship.hideReblogs : L10n.Common.Controls.Friendship.showReblogs
let showHideReblogsAction = UIAlertAction(
title: actionTitle,
style: .destructive
) { [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(
dependency: dependency,
user: user
)
}
}
guard let user = _user else { return }
alertController.addAction(showHideReblogsAction)
try await DataSourceFacade.responseToShowHideReblogAction(
dependency: dependency,
user: user
)
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
alertController.addAction(cancelAction)
alertController.addAction(showHideReblogsAction)
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):
let alertController = UIAlertController(
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
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 {
/// Confirm to mute %@
public static func message(_ p1: Any) -> String {
@ -721,6 +727,12 @@ public enum L10n {
/// Mute Account
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 {
/// Confirm to unblock %@
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.HideReblogs" = "Hide Reblogs";
"Common.Controls.Friendship.ShowReblogs" = "Show Reblogs";
"Common.Controls.Keyboard.Common.ComposeNewPost" = "Compose New Post";
"Common.Controls.Keyboard.Common.OpenSettings" = "Open Settings";
"Common.Controls.Keyboard.Common.ShowFavorites" = "Show Favorites";
@ -264,6 +265,10 @@ uploaded to Mastodon.";
"Scene.Profile.RelationshipActionAlert.ConfirmUnblockUser.Title" = "Unblock Account";
"Scene.Profile.RelationshipActionAlert.ConfirmUnmuteUser.Message" = "Confirm to unmute %@";
"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.Media" = "Media";
"Scene.Profile.SegmentedControl.Posts" = "Posts";

View File

@ -52,7 +52,7 @@ extension MastodonMenu {
func build(delegate: MastodonMenuDelegate) -> BuiltAction {
switch self {
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(
title: title,
image: UIImage(systemName: "arrow.2.squarepath")