Skip to content

Commit

Permalink
Improve accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Jan 24, 2025
1 parent 8862a56 commit b788dd2
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
- Introduce the new AppleScript parameter `editable` to document objects.


### Improvements

- Improve the VoiceOver support.


### TODO

- Localize new strings.
Expand Down
89 changes: 89 additions & 0 deletions CotEditor/Resources/Localizables/Panels/About.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,95 @@
{
"sourceLanguage" : "en",
"strings" : {
"%@ icon" : {
"comment" : "%@ is application name",
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ikona %@"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@-Symbol"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ icon"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Icono de %@"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Icône %@"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Icona %@"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "“%@”アイコン"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ 아이콘"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@-symbool"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "ikona %@"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ícone do %@"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ simgesi"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@图标"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@圖像"
}
}
}
},
"About %@" : {
"comment" : "accessibility label (%@ is app name)",
"localizations" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"sourceLanguage" : "en",
"strings" : {
"%@ times" : {
"extractionState" : "stale",
"localizations" : {
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ times"
}
}
}
},
"Antialias" : {
"localizations" : {
"cs" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,95 @@
}
}
}
},
"Sidebar" : {
"comment" : "accessibility label",
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "Boční panel"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Seitenleiste"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sidebar"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Barra lateral"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Barre latérale"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Barra laterale"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "サイドバー"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "사이드바"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Navigatiekolom"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Pasek boczny"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
"value" : "Barra Lateral"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Kenar çubuğu"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "边栏"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "側邊欄"
}
}
}
}
},
"version" : "1.0"
Expand Down
11 changes: 8 additions & 3 deletions CotEditor/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// ---------------------------------------------------------------------------
//
// © 2004-2007 nakamuxu
// © 2013-2024 1024jp
// © 2013-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -96,7 +96,7 @@ private enum BundleIdentifier {

private var menuUpdateObservers: Set<AnyCancellable> = []

private lazy var aboutPanel = NSPanel(view: AboutView())
private lazy var aboutPanel = NSPanel(view: AboutView(), title: String(localized: "About \(Bundle.main.bundleName)", table: "About", comment: "accessibility label (%@ is app name)"))
private lazy var whatsNewPanel = NSPanel(view: WhatsNewView())

@IBOutlet private weak var encodingsMenu: NSMenu?
Expand Down Expand Up @@ -541,7 +541,8 @@ private extension NSPanel {
///
/// - Parameters:
/// - view: The SwiftUI view.
convenience init(view: any View) {
/// - title: The window title mainly for the accessibility.
convenience init(view: any View, title: String? = nil) {

let viewController = NSHostingController(rootView: AnyView(view))
viewController.safeAreaRegions = []
Expand All @@ -555,6 +556,10 @@ private extension NSPanel {
self.becomesKeyOnlyIfNeeded = true
self.setContentSize(viewController.view.intrinsicContentSize)

if let title {
self.title = title
}

self.center()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2021-2024 1024jp
// © 2021-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,6 +55,7 @@ struct AdvancedCharacterCounterView: View {

Text(attributedCount)
.foregroundStyle(.secondary)
.accessibilityAddTraits(.updatesFrequently)

} else {
Label(String(localized: "failed", table: "AdvancedCharacterCount", comment: "error message when count failed"), systemImage: "exclamationmark.triangle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2014-2024 1024jp
// © 2014-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@ struct UnicodeInputView: View {
HStack(alignment: .center) {
Text(self.pictureString ?? "")
.font(.system(size: 26))
.accessibilityHidden(self.unicodeName == nil)
.frame(minWidth: 30, minHeight: 30)

Text(self.unicodeName ?? String(localized: "Invalid code", table: "UnicodeInput"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2024 1024jp
// © 2024-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,6 +50,7 @@ struct NavigationBar: View {
.padding(.vertical, 4)
.padding(.horizontal, 3)
.opacity(self.splitState.canClose ? 1 : 0)
.accessibilityHidden(!self.splitState.canClose)

OutlineNavigationView(navigator: $outlineNavigator)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ private struct EditorCountView: View {

Text(self.attributedString)
.monospacedDigit()
.accessibilityAddTraits(.updatesFrequently)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,29 @@ private struct CountLocationView: View {
OptionalLabeledContent(String(localized: "Lines", table: "Document",
comment: "label in document inspector"),
value: self.result.lines.formatted)
.accessibilityAddTraits(.updatesFrequently)
OptionalLabeledContent(String(localized: "Characters", table: "Document",
comment: "label in document inspector"),
value: self.result.characters.formatted)
.accessibilityAddTraits(.updatesFrequently)
OptionalLabeledContent(String(localized: "Words", table: "Document",
comment: "label in document inspector"),
value: self.result.words.formatted)
.accessibilityAddTraits(.updatesFrequently)
.padding(.bottom, 8)

OptionalLabeledContent(String(localized: "Location", table: "Document",
comment: "label in document inspector"),
value: self.result.location?.formatted())
.accessibilityAddTraits(.updatesFrequently)
OptionalLabeledContent(String(localized: "Line", table: "Document",
comment: "label in document inspector"),
value: self.result.line?.formatted())
.accessibilityAddTraits(.updatesFrequently)
OptionalLabeledContent(String(localized: "Column", table: "Document",
comment: "label in document inspector"),
value: self.result.column?.formatted())
.accessibilityAddTraits(.updatesFrequently)
}
.monospacedDigit()
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
Loading

0 comments on commit b788dd2

Please sign in to comment.