mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 00:01:00 +00:00
40 lines
1.2 KiB
Swift
40 lines
1.2 KiB
Swift
// Copyright © 2021 Metabolist. All rights reserved.
|
|
|
|
import Foundation
|
|
import Mastodon
|
|
|
|
extension Attachment.AttachmentType {
|
|
var accessibilityName: String {
|
|
switch self {
|
|
case .image, .gifv:
|
|
return NSLocalizedString("attachment.type.image", comment: "")
|
|
case .video:
|
|
return NSLocalizedString("attachment.type.video", comment: "")
|
|
case .audio:
|
|
return NSLocalizedString("attachment.type.audio", comment: "")
|
|
case .unknown:
|
|
return NSLocalizedString("attachment.type.unknown", comment: "")
|
|
}
|
|
}
|
|
|
|
func accessibilityNames(count: Int) -> String {
|
|
if count == 1 {
|
|
return accessibilityName
|
|
}
|
|
|
|
let format: String
|
|
|
|
switch self {
|
|
case .image, .gifv:
|
|
format = NSLocalizedString("attachment.type.images-%ld", comment: "")
|
|
case .video:
|
|
format = NSLocalizedString("attachment.type.videos-%ld", comment: "")
|
|
case .audio:
|
|
format = NSLocalizedString("attachment.type.audios-%ld", comment: "")
|
|
case .unknown:
|
|
format = NSLocalizedString("attachment.type.unknowns-%ld", comment: "")
|
|
}
|
|
|
|
return String.localizedStringWithFormat(format, count)
|
|
}
|
|
}
|