From f5c6529341da0f3967c1f58e92b491311b7384ba Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Wed, 21 Dec 2022 19:38:05 -0500 Subject: [PATCH] i18n for accessibility hint --- .../StringsConvertor/input/Base.lproj/app.json | 7 ++++++- Localization/app.json | 7 ++++++- .../MastodonLocalization/Generated/Strings.swift | 16 ++++++++++++---- .../Resources/Base.lproj/Localizable.strings | 5 ++++- .../MastodonUI/View/Content/MediaView.swift | 8 ++++---- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Localization/StringsConvertor/input/Base.lproj/app.json b/Localization/StringsConvertor/input/Base.lproj/app.json index 243d60b9a..2959c9597 100644 --- a/Localization/StringsConvertor/input/Base.lproj/app.json +++ b/Localization/StringsConvertor/input/Base.lproj/app.json @@ -144,7 +144,6 @@ "tap_to_reveal": "Tap to reveal", "load_embed": "Load Embed", "link_via_user": "%s via %s", - "media_label": "%s, attachment %d of %d", "poll": { "vote": "Vote", "closed": "Closed" @@ -188,6 +187,12 @@ "unknown_language": "Unknown", "unknown_provider": "Unknown", "show_original": "Shown Original" + }, + "media": { + "accessibility_label": "%s, attachment %d of %d", + "expand_image_hint": "Expands the image. Double-tap and hold to show actions", + "expand_gif_hint": "Expands the GIF. Double-tap and hold to show actions", + "expand_video_hint": "Shows the video player. Double-tap and hold to show actions" } }, "friendship": { diff --git a/Localization/app.json b/Localization/app.json index 243d60b9a..2959c9597 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -144,7 +144,6 @@ "tap_to_reveal": "Tap to reveal", "load_embed": "Load Embed", "link_via_user": "%s via %s", - "media_label": "%s, attachment %d of %d", "poll": { "vote": "Vote", "closed": "Closed" @@ -188,6 +187,12 @@ "unknown_language": "Unknown", "unknown_provider": "Unknown", "show_original": "Shown Original" + }, + "media": { + "accessibility_label": "%s, attachment %d of %d", + "expand_image_hint": "Expands the image. Double-tap and hold to show actions", + "expand_gif_hint": "Expands the GIF. Double-tap and hold to show actions", + "expand_video_hint": "Shows the video player. Double-tap and hold to show actions" } }, "friendship": { diff --git a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift index 75f348a0c..a3466fad6 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift +++ b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift @@ -298,10 +298,6 @@ public enum L10n { public static let loadEmbed = L10n.tr("Localizable", "Common.Controls.Status.LoadEmbed", fallback: "Load Embed") /// Tap anywhere to reveal public static let mediaContentWarning = L10n.tr("Localizable", "Common.Controls.Status.MediaContentWarning", fallback: "Tap anywhere to reveal") - /// %@, attachment %d of %d - public static func mediaLabel(_ p1: Any, _ p2: Int, _ p3: Int) -> String { - return L10n.tr("Localizable", "Common.Controls.Status.MediaLabel", String(describing: p1), p2, p3, fallback: "%@, attachment %d of %d") - } /// Sensitive Content public static let sensitiveContent = L10n.tr("Localizable", "Common.Controls.Status.SensitiveContent", fallback: "Sensitive Content") /// Show Post @@ -344,6 +340,18 @@ public enum L10n { /// Undo reblog public static let unreblog = L10n.tr("Localizable", "Common.Controls.Status.Actions.Unreblog", fallback: "Undo reblog") } + public enum Media { + /// %@, attachment %d of %d + public static func accessibilityLabel(_ p1: Any, _ p2: Int, _ p3: Int) -> String { + return L10n.tr("Localizable", "Common.Controls.Status.Media.AccessibilityLabel", String(describing: p1), p2, p3, fallback: "%@, attachment %d of %d") + } + /// Expands the GIF. Double-tap and hold to show actions + public static let expandGifHint = L10n.tr("Localizable", "Common.Controls.Status.Media.ExpandGifHint", fallback: "Expands the GIF. Double-tap and hold to show actions") + /// Expands the image. Double-tap and hold to show actions + public static let expandImageHint = L10n.tr("Localizable", "Common.Controls.Status.Media.ExpandImageHint", fallback: "Expands the image. Double-tap and hold to show actions") + /// Shows the video player. Double-tap and hold to show actions + public static let expandVideoHint = L10n.tr("Localizable", "Common.Controls.Status.Media.ExpandVideoHint", fallback: "Shows the video player. Double-tap and hold to show actions") + } public enum MetaEntity { /// Email address: %@ public static func email(_ p1: Any) -> String { diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings index 830f887b8..5280f2dcd 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings @@ -116,8 +116,11 @@ Please check your internet connection."; "Common.Controls.Status.ContentWarning" = "Content Warning"; "Common.Controls.Status.LinkViaUser" = "%@ via %@"; "Common.Controls.Status.LoadEmbed" = "Load Embed"; +"Common.Controls.Status.Media.AccessibilityLabel" = "%@, attachment %d of %d"; +"Common.Controls.Status.Media.ExpandGifHint" = "Expands the GIF. Double-tap and hold to show actions"; +"Common.Controls.Status.Media.ExpandImageHint" = "Expands the image. Double-tap and hold to show actions"; +"Common.Controls.Status.Media.ExpandVideoHint" = "Shows the video player. Double-tap and hold to show actions"; "Common.Controls.Status.MediaContentWarning" = "Tap anywhere to reveal"; -"Common.Controls.Status.MediaLabel" = "%@, attachment %d of %d"; "Common.Controls.Status.MetaEntity.Email" = "Email address: %@"; "Common.Controls.Status.MetaEntity.Hashtag" = "Hashtag: %@"; "Common.Controls.Status.MetaEntity.Mention" = "Show Profile: %@"; diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift index 1b471d34a..a140d9737 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift @@ -128,15 +128,15 @@ extension MediaView { case .image(let info): layoutImage() bindImage(configuration: configuration, info: info) - accessibilityHint = "Expands the image. Double-tap and hold to show actions" // TODO: i18n + accessibilityHint = L10n.Common.Controls.Status.Media.expandImageHint case .gif(let info): layoutGIF() bindGIF(configuration: configuration, info: info) - accessibilityHint = "Expands the GIF. Double-tap and hold to show actions" // TODO: i18n + accessibilityHint = L10n.Common.Controls.Status.Media.expandGifHint case .video(let info): layoutVideo() bindVideo(configuration: configuration, info: info) - accessibilityHint = "Shows video player. Double-tap and hold to show actions" // TODO: i18n + accessibilityHint = L10n.Common.Controls.Status.Media.expandVideoHint } accessibilityTraits.insert([.button, .image]) @@ -220,7 +220,7 @@ extension MediaView { private func bindAlt(configuration: Configuration, altDescription: String?) { if configuration.total > 1 { - accessibilityLabel = L10n.Common.Controls.Status.mediaLabel( + accessibilityLabel = L10n.Common.Controls.Status.Media.accessibilityLabel( altDescription ?? "", configuration.index + 1, configuration.total