From d489943b45991025a6e3f4b78613f629294e0493 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 6 Nov 2022 20:22:06 -0500 Subject: [PATCH 1/6] Improve ComposeContentView.avatarView label --- .../Scene/ComposeContent/View/ComposeContentView.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift index 25584848a..56ddbbb7f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift @@ -147,6 +147,9 @@ extension ComposeContentView { } Spacer() } + .accessibilityElement(children: .ignore) + // TODO: i18n + .accessibilityLabel("Posting as \(viewModel.name.string), \(viewModel.username)") } } From 7a3b9205e5f242a3ed69b11ba0399eea7d9896e5 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 6 Nov 2022 20:49:12 -0500 Subject: [PATCH 2/6] Add missing labels to compose toolbar --- .../ComposeContentToolbarView+ViewModel.swift | 15 +++++++++++++++ .../View/ComposeContentToolbarView.swift | 2 ++ 2 files changed, 17 insertions(+) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView+ViewModel.swift index 4a34c77d4..fefc0821f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView+ViewModel.swift @@ -120,4 +120,19 @@ extension ComposeContentToolbarView.ViewModel { return action.inactiveImage } } + + func label(for action: Action) -> String { + switch action { + case .attachment: + return L10n.Scene.Compose.Accessibility.appendAttachment + case .poll: + return isPollActive ? L10n.Scene.Compose.Accessibility.removePoll : L10n.Scene.Compose.Accessibility.appendPoll + case .emoji: + return L10n.Scene.Compose.Accessibility.customEmojiPicker + case .contentWarning: + return isContentWarningActive ? L10n.Scene.Compose.Accessibility.disableContentWarning : L10n.Scene.Compose.Accessibility.enableContentWarning + case .visibility: + return L10n.Scene.Compose.Accessibility.postVisibilityMenu + } + } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift index 52026c636..aba52ff9a 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift @@ -61,6 +61,7 @@ struct ComposeContentToolbarView: View { } } label: { label(for: viewModel.visibility.image) + .accessibilityLabel(L10n.Scene.Compose.Keyboard.selectVisibilityEntry(viewModel.visibility.title)) } .frame(width: 48, height: 48) default: @@ -100,6 +101,7 @@ extension ComposeContentToolbarView { Image(uiImage: viewModel.image(for: action)) .foregroundColor(Color(Asset.Scene.Compose.buttonTint.color)) .frame(width: 24, height: 24, alignment: .center) + .accessibilityLabel(viewModel.label(for: action)) } func label(for image: UIImage) -> some View { From 7ac9e7c564095eb82b69e166e332452e12449a97 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 6 Nov 2022 20:51:13 -0500 Subject: [PATCH 3/6] Add description to compose content toolbar container --- .../Scene/ComposeContent/View/ComposeContentToolbarView.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift index aba52ff9a..53058cc12 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift @@ -92,6 +92,9 @@ struct ComposeContentToolbarView: View { .padding(.trailing, 16) .frame(height: ComposeContentToolbarView.toolbarHeight) .background(Color(viewModel.backgroundColor)) + .accessibilityElement(children: .contain) + // TODO: i18n + .accessibilityLabel("Post Options") } } From 022f8c11151801ea3faf2e77eddf60d4a6ee23dc Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 6 Nov 2022 20:51:43 -0500 Subject: [PATCH 4/6] Clarify meaning of character counter --- .../Scene/ComposeContent/View/ComposeContentToolbarView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift index 53058cc12..8c6d84a28 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift @@ -87,6 +87,8 @@ struct ComposeContentToolbarView: View { Text("\(remains)") .foregroundColor(Color(isOverflow ? UIColor.systemRed : UIColor.secondaryLabel)) .font(.system(size: isOverflow ? 18 : 16, weight: isOverflow ? .medium : .regular)) + // TODO: i18n + .accessibilityLabel("\(remains) characters left") } .padding(.leading, 4) // 4 + 12 = 16 .padding(.trailing, 16) From 549739b6cb50433878ef4586508ae6f52007b7ee Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 7 Nov 2022 06:26:20 -0500 Subject: [PATCH 5/6] Add new strings to Localization folder --- Localization/Localizable.stringsdict | 20 +++++++++++++++++++ Localization/app.json | 6 ++++-- .../View/ComposeContentToolbarView.swift | 4 ++-- .../View/ComposeContentView.swift | 4 ++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Localization/Localizable.stringsdict b/Localization/Localizable.stringsdict index 051bb50ef..46b79deb2 100644 --- a/Localization/Localizable.stringsdict +++ b/Localization/Localizable.stringsdict @@ -68,6 +68,26 @@ %ld characters + a11y.plural.count.characters_left + + NSStringLocalizedFormatKey + %#@character_count@ + character_count + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + zero + no characters left + one + 1 character left + few + %ld characters left + many + %ld characters left + other + %ld characters left + + plural.count.followed_by_and_mutual NSStringLocalizedFormatKey diff --git a/Localization/app.json b/Localization/app.json index a965b23ae..45ff94363 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -405,7 +405,9 @@ "custom_emoji_picker": "Custom Emoji Picker", "enable_content_warning": "Enable Content Warning", "disable_content_warning": "Disable Content Warning", - "post_visibility_menu": "Post Visibility Menu" + "post_visibility_menu": "Post Visibility Menu", + "post_options": "Post Options", + "posting_as": "Posting as %s" }, "keyboard": { "discard_post": "Discard Post", @@ -686,4 +688,4 @@ "accessibility_hint": "Double tap to dismiss this wizard" } } -} \ No newline at end of file +} diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift index 8c6d84a28..ac1a56b20 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift @@ -87,7 +87,7 @@ struct ComposeContentToolbarView: View { Text("\(remains)") .foregroundColor(Color(isOverflow ? UIColor.systemRed : UIColor.secondaryLabel)) .font(.system(size: isOverflow ? 18 : 16, weight: isOverflow ? .medium : .regular)) - // TODO: i18n + // TODO: i18n (a11y.plural.count.characters_left) .accessibilityLabel("\(remains) characters left") } .padding(.leading, 4) // 4 + 12 = 16 @@ -95,7 +95,7 @@ struct ComposeContentToolbarView: View { .frame(height: ComposeContentToolbarView.toolbarHeight) .background(Color(viewModel.backgroundColor)) .accessibilityElement(children: .contain) - // TODO: i18n + // TODO: i18n (scene.compose.accessibility.post_options) .accessibilityLabel("Post Options") } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift index 56ddbbb7f..b48f4e060 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift @@ -148,8 +148,8 @@ extension ComposeContentView { Spacer() } .accessibilityElement(children: .ignore) - // TODO: i18n - .accessibilityLabel("Posting as \(viewModel.name.string), \(viewModel.username)") + // TODO: i18n (scene.compose.accessibility.posting_as) + .accessibilityLabel("Posting as \([viewModel.name.string, viewModel.username].joined(separator: ", "))") } } From 60b69ca2e539a86d0e8f6ffee40655f0e74c57e3 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 8 Nov 2022 13:50:23 -0500 Subject: [PATCH 6/6] Add real localization keys --- Localization/Localizable.stringsdict | 14 +++++++----- .../input/en.lproj/Localizable.stringsdict | 22 +++++++++++++++++++ .../StringsConvertor/input/en.lproj/app.json | 4 +++- .../Generated/Strings.swift | 10 +++++++++ .../Resources/en.lproj/Localizable.strings | 2 ++ .../en.lproj/Localizable.stringsdict | 22 +++++++++++++++++++ .../View/ComposeContentToolbarView.swift | 6 ++--- .../View/ComposeContentView.swift | 3 +-- 8 files changed, 70 insertions(+), 13 deletions(-) diff --git a/Localization/Localizable.stringsdict b/Localization/Localizable.stringsdict index 46b79deb2..cd97825f4 100644 --- a/Localization/Localizable.stringsdict +++ b/Localization/Localizable.stringsdict @@ -71,21 +71,23 @@ a11y.plural.count.characters_left NSStringLocalizedFormatKey - %#@character_count@ + %#@character_count@ left character_count NSStringFormatSpecTypeKey NSStringPluralRuleType + NSStringFormatValueTypeKey + ld zero - no characters left + no characters one - 1 character left + 1 character few - %ld characters left + %ld characters many - %ld characters left + %ld characters other - %ld characters left + %ld characters plural.count.followed_by_and_mutual diff --git a/Localization/StringsConvertor/input/en.lproj/Localizable.stringsdict b/Localization/StringsConvertor/input/en.lproj/Localizable.stringsdict index bdcae6ac9..297e6675a 100644 --- a/Localization/StringsConvertor/input/en.lproj/Localizable.stringsdict +++ b/Localization/StringsConvertor/input/en.lproj/Localizable.stringsdict @@ -50,6 +50,28 @@ %ld characters + a11y.plural.count.characters_left + + NSStringLocalizedFormatKey + %#@character_count@ left + character_count + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + no characters + one + 1 character + few + %ld characters + many + %ld characters + other + %ld characters + + plural.count.followed_by_and_mutual NSStringLocalizedFormatKey diff --git a/Localization/StringsConvertor/input/en.lproj/app.json b/Localization/StringsConvertor/input/en.lproj/app.json index a965b23ae..69b71b0e9 100644 --- a/Localization/StringsConvertor/input/en.lproj/app.json +++ b/Localization/StringsConvertor/input/en.lproj/app.json @@ -405,7 +405,9 @@ "custom_emoji_picker": "Custom Emoji Picker", "enable_content_warning": "Enable Content Warning", "disable_content_warning": "Disable Content Warning", - "post_visibility_menu": "Post Visibility Menu" + "post_visibility_menu": "Post Visibility Menu", + "post_options": "Post Options", + "posting_as": "Posting as %s" }, "keyboard": { "discard_post": "Discard Post", diff --git a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift index 52ed59c09..d6a2d2579 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift +++ b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift @@ -435,6 +435,12 @@ public enum L10n { public static let disableContentWarning = L10n.tr("Localizable", "Scene.Compose.Accessibility.DisableContentWarning") /// Enable Content Warning public static let enableContentWarning = L10n.tr("Localizable", "Scene.Compose.Accessibility.EnableContentWarning") + /// Posting as %@ + public static func postingAs(_ p1: Any) -> String { + return L10n.tr("Localizable", "Scene.Compose.Accessibility.PostingAs", String(describing: p1)) + } + /// Post Options + public static let postOptions = L10n.tr("Localizable", "Scene.Compose.Accessibility.PostOptions") /// Post Visibility Menu public static let postVisibilityMenu = L10n.tr("Localizable", "Scene.Compose.Accessibility.PostVisibilityMenu") /// Remove Poll @@ -1262,6 +1268,10 @@ public enum L10n { public enum A11y { public enum Plural { public enum Count { + /// Plural format key: "%#@character_count@ left" + public static func charactersLeft(_ p1: Int) -> String { + return L10n.tr("Localizable", "a11y.plural.count.characters_left", p1) + } /// Plural format key: "Input limit exceeds %#@character_count@" public static func inputLimitExceeds(_ p1: Int) -> String { return L10n.tr("Localizable", "a11y.plural.count.input_limit_exceeds", p1) diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings index 6917eb0c7..494d49fdc 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings @@ -160,7 +160,9 @@ Your profile looks like this to them."; "Scene.Compose.Accessibility.CustomEmojiPicker" = "Custom Emoji Picker"; "Scene.Compose.Accessibility.DisableContentWarning" = "Disable Content Warning"; "Scene.Compose.Accessibility.EnableContentWarning" = "Enable Content Warning"; +"Scene.Compose.Accessibility.PostOptions" = "Post Options"; "Scene.Compose.Accessibility.PostVisibilityMenu" = "Post Visibility Menu"; +"Scene.Compose.Accessibility.PostingAs" = "Posting as %@"; "Scene.Compose.Accessibility.RemovePoll" = "Remove Poll"; "Scene.Compose.Attachment.AttachmentBroken" = "This %@ is broken and can’t be uploaded to Mastodon."; diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.stringsdict b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.stringsdict index bdcae6ac9..297e6675a 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.stringsdict +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.stringsdict @@ -50,6 +50,28 @@ %ld characters + a11y.plural.count.characters_left + + NSStringLocalizedFormatKey + %#@character_count@ left + character_count + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + no characters + one + 1 character + few + %ld characters + many + %ld characters + other + %ld characters + + plural.count.followed_by_and_mutual NSStringLocalizedFormatKey diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift index ac1a56b20..b7f01e64a 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift @@ -87,16 +87,14 @@ struct ComposeContentToolbarView: View { Text("\(remains)") .foregroundColor(Color(isOverflow ? UIColor.systemRed : UIColor.secondaryLabel)) .font(.system(size: isOverflow ? 18 : 16, weight: isOverflow ? .medium : .regular)) - // TODO: i18n (a11y.plural.count.characters_left) - .accessibilityLabel("\(remains) characters left") + .accessibilityLabel(L10n.A11y.Plural.Count.charactersLeft(remains)) } .padding(.leading, 4) // 4 + 12 = 16 .padding(.trailing, 16) .frame(height: ComposeContentToolbarView.toolbarHeight) .background(Color(viewModel.backgroundColor)) .accessibilityElement(children: .contain) - // TODO: i18n (scene.compose.accessibility.post_options) - .accessibilityLabel("Post Options") + .accessibilityLabel(L10n.Scene.Compose.Accessibility.postOptions) } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift index b48f4e060..98b55018f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift @@ -148,8 +148,7 @@ extension ComposeContentView { Spacer() } .accessibilityElement(children: .ignore) - // TODO: i18n (scene.compose.accessibility.posting_as) - .accessibilityLabel("Posting as \([viewModel.name.string, viewModel.username].joined(separator: ", "))") + .accessibilityLabel(L10n.Scene.Compose.Accessibility.postingAs([viewModel.name.string, viewModel.username].joined(separator: ", "))) } }