forked from zelo72/mastodon-ios
chore: using i18n strings
This commit is contained in:
parent
05c5b77bbd
commit
e119a06bba
|
@ -8,6 +8,7 @@
|
||||||
import os.log
|
import os.log
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
|
import MastodonLocalization
|
||||||
|
|
||||||
final class FamiliarFollowersViewController: UIViewController, NeedsDependency {
|
final class FamiliarFollowersViewController: UIViewController, NeedsDependency {
|
||||||
|
|
||||||
|
@ -38,7 +39,8 @@ extension FamiliarFollowersViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
title = "Followers you familiar"
|
title = L10n.Scene.Familiarfollowers.title
|
||||||
|
|
||||||
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
||||||
ThemeService.shared.currentTheme
|
ThemeService.shared.currentTheme
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
|
|
|
@ -43,7 +43,7 @@ extension FollowerListViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
title = L10n.Scene.Profile.Dashboard.followers
|
title = L10n.Scene.Follower.title
|
||||||
|
|
||||||
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
||||||
ThemeService.shared.currentTheme
|
ThemeService.shared.currentTheme
|
||||||
|
|
|
@ -43,7 +43,7 @@ extension FollowingListViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
title = L10n.Scene.Profile.Dashboard.following
|
title = L10n.Scene.Following.title
|
||||||
|
|
||||||
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
||||||
ThemeService.shared.currentTheme
|
ThemeService.shared.currentTheme
|
||||||
|
|
|
@ -47,7 +47,7 @@ extension FavoritedByViewController {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
title = "Favorited By"
|
title = L10n.Scene.FavoritedBy.title
|
||||||
|
|
||||||
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
||||||
ThemeService.shared.currentTheme
|
ThemeService.shared.currentTheme
|
||||||
|
|
|
@ -47,7 +47,7 @@ extension RebloggedByViewController {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
title = "Favorited By"
|
title = L10n.Scene.RebloggedBy.title
|
||||||
|
|
||||||
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
||||||
ThemeService.shared.currentTheme
|
ThemeService.shared.currentTheme
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// MastodonLocalization+Bundle.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by MainasuK on 2022-5-17.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public enum MastodonLocalization {
|
||||||
|
public static var bundle: Bundle {
|
||||||
|
Bundle.module
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ extension FamiliarFollowersDashboardView {
|
||||||
public func configure(familiarFollowers: Mastodon.Entity.FamiliarFollowers?) {
|
public func configure(familiarFollowers: Mastodon.Entity.FamiliarFollowers?) {
|
||||||
assert(Thread.isMainThread)
|
assert(Thread.isMainThread)
|
||||||
|
|
||||||
let accounts = familiarFollowers?.accounts.prefix(4) ?? []
|
let accounts = familiarFollowers?.accounts ?? []
|
||||||
|
|
||||||
viewModel.avatarURLs = accounts.map { $0.avatarImageURL() }
|
viewModel.avatarURLs = accounts.map { $0.avatarImageURL() }
|
||||||
viewModel.names = accounts.map { $0.displayNameWithFallback }
|
viewModel.names = accounts.map { $0.displayNameWithFallback }
|
||||||
|
|
|
@ -10,6 +10,7 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import MastodonMeta
|
import MastodonMeta
|
||||||
|
import MastodonLocalization
|
||||||
|
|
||||||
extension FamiliarFollowersDashboardView {
|
extension FamiliarFollowersDashboardView {
|
||||||
public final class ViewModel: ObservableObject {
|
public final class ViewModel: ObservableObject {
|
||||||
|
@ -32,6 +33,9 @@ extension FamiliarFollowersDashboardView.ViewModel {
|
||||||
UIContentSizeCategory.publisher
|
UIContentSizeCategory.publisher
|
||||||
)
|
)
|
||||||
.sink { avatarURLs, backgroundColor, contentSizeCategory in
|
.sink { avatarURLs, backgroundColor, contentSizeCategory in
|
||||||
|
// only using first 4 items
|
||||||
|
let avatarURLs = avatarURLs.prefix(4)
|
||||||
|
|
||||||
view.avatarContainerView.subviews.forEach { $0.removeFromSuperview() }
|
view.avatarContainerView.subviews.forEach { $0.removeFromSuperview() }
|
||||||
|
|
||||||
let initialOffset = min(12 * 1.5, UIFontMetrics(forTextStyle: .headline).scaledValue(for: 12)) // max 1.5x
|
let initialOffset = min(12 * 1.5, UIFontMetrics(forTextStyle: .headline).scaledValue(for: 12)) // max 1.5x
|
||||||
|
@ -82,12 +86,12 @@ extension FamiliarFollowersDashboardView.ViewModel {
|
||||||
|
|
||||||
switch names.count {
|
switch names.count {
|
||||||
case 1..<3:
|
case 1..<3:
|
||||||
return "Followed by \(firstTwoNames)"
|
return L10n.Scene.Familiarfollowers.followedByNames(firstTwoNames)
|
||||||
case 3:
|
|
||||||
return "Followed by \(firstTwoNames), and another mutual"
|
|
||||||
default:
|
default:
|
||||||
|
// Note: SwiftGen generates wrong formate argv for "%1$@"
|
||||||
let remains = count - 2
|
let remains = count - 2
|
||||||
return "Followed by \(firstTwoNames), and \(remains) mutuals"
|
let format = MastodonLocalization.bundle.localizedString(forKey: "plural.count.followed_by_and_mutual", value: nil, table: "Localizable")
|
||||||
|
return String(format: format, locale: .current, arguments: [firstTwoNames, remains])
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
let document = MastodonContent(content: content, emojis: emojis)
|
let document = MastodonContent(content: content, emojis: emojis)
|
||||||
|
|
|
@ -666,8 +666,7 @@ extension StatusView.ViewModel {
|
||||||
let meidaAccessibilityLabel = $mediaViewConfigurations
|
let meidaAccessibilityLabel = $mediaViewConfigurations
|
||||||
.map { configurations -> String? in
|
.map { configurations -> String? in
|
||||||
let count = configurations.count
|
let count = configurations.count
|
||||||
// TODO: i18n
|
return L10n.Plural.Count.media(count)
|
||||||
return count > 0 ? "\(count) media" : nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Toolbar
|
// TODO: Toolbar
|
||||||
|
|
Loading…
Reference in New Issue