feat(Widget): Implement L10n
This commit is contained in:
parent
28e5a8fa90
commit
b5dca48cb2
|
@ -131,3 +131,6 @@ env/**/**
|
|||
## Ruby ###
|
||||
vendor/
|
||||
.bundle/
|
||||
|
||||
## IntelliJ IDEA ##
|
||||
.idea
|
|
@ -816,5 +816,19 @@
|
|||
"open_in": {
|
||||
"invalid_link_error": "This doesn't seem to be a valid Mastodon link."
|
||||
}
|
||||
},
|
||||
"widget": {
|
||||
"common": {
|
||||
"unsupported_widget_family": "Sorry but this Widget family is unsupported.",
|
||||
"user_not_logged_in": "Please open Mastodon to log in to an Account."
|
||||
},
|
||||
"followers_count": {
|
||||
"title": "FOLLOWERS",
|
||||
"followers_today": "%s followers today"
|
||||
},
|
||||
"latest_followers": {
|
||||
"title": "Latest followers",
|
||||
"last_update": "Last update: %s"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1479,6 +1479,30 @@ public enum L10n {
|
|||
public static let newInMastodon = L10n.tr("Localizable", "Scene.Wizard.NewInMastodon", fallback: "New in Mastodon")
|
||||
}
|
||||
}
|
||||
public enum Widget {
|
||||
public enum Common {
|
||||
/// Sorry but this Widget family is unsupported.
|
||||
public static let unsupportedWidgetFamily = L10n.tr("Localizable", "Widget.Common.UnsupportedWidgetFamily", fallback: "Sorry but this Widget family is unsupported.")
|
||||
/// Please open Mastodon to log in to an Account.
|
||||
public static let userNotLoggedIn = L10n.tr("Localizable", "Widget.Common.UserNotLoggedIn", fallback: "Please open Mastodon to log in to an Account.")
|
||||
}
|
||||
public enum FollowersCount {
|
||||
/// %@ followers today
|
||||
public static func followersToday(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "Widget.FollowersCount.FollowersToday", String(describing: p1), fallback: "%@ followers today")
|
||||
}
|
||||
/// FOLLOWERS
|
||||
public static let title = L10n.tr("Localizable", "Widget.FollowersCount.Title", fallback: "FOLLOWERS")
|
||||
}
|
||||
public enum LatestFollowers {
|
||||
/// Last update: %@
|
||||
public static func lastUpdate(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "Widget.LatestFollowers.LastUpdate", String(describing: p1), fallback: "Last update: %@")
|
||||
}
|
||||
/// Latest followers
|
||||
public static let title = L10n.tr("Localizable", "Widget.LatestFollowers.Title", fallback: "Latest followers")
|
||||
}
|
||||
}
|
||||
public enum A11y {
|
||||
public enum Plural {
|
||||
public enum Count {
|
||||
|
|
|
@ -518,3 +518,9 @@ You can’t go wrong with any of our recommend servers, so regardless of which o
|
|||
"Scene.Privacy.Policy.Ios" = "Privacy Policy - Mastodon for iOS";
|
||||
"Scene.Privacy.Policy.Server" = "Privacy Policy - %@";
|
||||
"Extension.OpenIn.InvalidLinkError" = "This doesn't seem to be a valid Mastodon link.";
|
||||
"Widget.Common.UnsupportedWidgetFamily" = "Sorry but this Widget family is unsupported.";
|
||||
"Widget.Common.UserNotLoggedIn" = "Please open Mastodon to log in to an Account.";
|
||||
"Widget.FollowersCount.Title" = "FOLLOWERS";
|
||||
"Widget.FollowersCount.FollowersToday" = "%@ followers today";
|
||||
"Widget.LatestFollowers.Title" = "Latest followers";
|
||||
"Widget.LatestFollowers.LastUpdate" = "Last update: %@";
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import SwiftUI
|
||||
import WidgetKit
|
||||
import MastodonAsset
|
||||
import MastodonLocalization
|
||||
|
||||
struct FollowersCountWidgetView: View {
|
||||
private let followersHistory = FollowersCountHistory.shared
|
||||
|
@ -25,10 +26,10 @@ struct FollowersCountWidgetView: View {
|
|||
case .accessoryCircular:
|
||||
viewForAccessoryCircular(account)
|
||||
default:
|
||||
Text("Sorry but this Widget family is unsupported.")
|
||||
Text(L10n.Widget.Common.unsupportedWidgetFamily)
|
||||
}
|
||||
} else {
|
||||
Text("Please open Mastodon to log in to an Account.")
|
||||
Text(L10n.Widget.Common.userNotLoggedIn)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
.padding(.all, 20)
|
||||
|
@ -107,7 +108,7 @@ struct FollowersCountWidgetView: View {
|
|||
VStack(alignment: .leading, spacing: 0) {
|
||||
Spacer()
|
||||
if let increaseCount = followersHistory.increaseCountString(for: account) {
|
||||
Text("\(increaseCount) followers today")
|
||||
Text(L10n.Widget.FollowersCount.followersToday(increaseCount))
|
||||
.font(.system(size: UIFontMetrics.default.scaledValue(for: 12)))
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
|
@ -134,7 +135,7 @@ struct FollowersCountWidgetView: View {
|
|||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(alignment: .center) {
|
||||
Image("BrandIcon")
|
||||
Text("FOLLOWERS")
|
||||
Text(L10n.Widget.FollowersCount.title)
|
||||
.font(.system(size: UIFontMetrics.default.scaledValue(for: 15), weight: .semibold))
|
||||
}
|
||||
.padding(.top, 6)
|
||||
|
|
|
@ -5,6 +5,7 @@ import WidgetKit
|
|||
import MastodonSDK
|
||||
import MastodonAsset
|
||||
import MastodonUI
|
||||
import MastodonLocalization
|
||||
|
||||
struct LatestFollowersWidgetView: View {
|
||||
private let dateFormatter: DateFormatter = {
|
||||
|
@ -26,10 +27,10 @@ struct LatestFollowersWidgetView: View {
|
|||
case .systemMedium:
|
||||
viewForMediumWidget(accounts, lastUpdate: entry.date)
|
||||
default:
|
||||
Text("Sorry but this Widget family is unsupported.")
|
||||
Text(L10n.Widget.Common.unsupportedWidgetFamily)
|
||||
}
|
||||
} else {
|
||||
Text("Please open Mastodon to log in to an Account.")
|
||||
Text(L10n.Widget.Common.userNotLoggedIn)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
.padding(.all, 20)
|
||||
|
@ -38,7 +39,7 @@ struct LatestFollowersWidgetView: View {
|
|||
|
||||
private func viewForSmallWidget(_ accounts: [LatestFollowersEntryAccountable], lastUpdate: Date) -> some View {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Latest followers")
|
||||
Text(L10n.Widget.LatestFollowers.title)
|
||||
.font(.system(size: UIFontMetrics.default.scaledValue(for: 16)))
|
||||
|
||||
ForEach(accounts, id: \.acct) { account in
|
||||
|
@ -53,7 +54,6 @@ struct LatestFollowersWidgetView: View {
|
|||
|
||||
Text(account.displayNameWithFallback)
|
||||
.font(.footnote.bold())
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct LatestFollowersWidgetView: View {
|
|||
}
|
||||
}
|
||||
Spacer()
|
||||
Text("Last update: \(dateFormatter.string(from: lastUpdate))")
|
||||
Text(L10n.Widget.LatestFollowers.lastUpdate(dateFormatter.string(from: lastUpdate)))
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ struct LatestFollowersWidgetView: View {
|
|||
private func viewForMediumWidget(_ accounts: [LatestFollowersEntryAccountable], lastUpdate: Date) -> some View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Text("Latest followers")
|
||||
Text(L10n.Widget.LatestFollowers.title)
|
||||
.font(.system(size: UIFontMetrics.default.scaledValue(for: 16)))
|
||||
Spacer()
|
||||
Image("BrandIconColored")
|
||||
|
@ -98,7 +98,6 @@ struct LatestFollowersWidgetView: View {
|
|||
HStack {
|
||||
Text(account.displayNameWithFallback)
|
||||
.font(.footnote.bold())
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
|
||||
|
@ -118,7 +117,7 @@ struct LatestFollowersWidgetView: View {
|
|||
}
|
||||
}
|
||||
Spacer()
|
||||
Text("Last update: \(dateFormatter.string(from: lastUpdate))")
|
||||
Text(L10n.Widget.LatestFollowers.lastUpdate(dateFormatter.string(from: lastUpdate)))
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import SwiftUI
|
||||
import WidgetKit
|
||||
import MastodonAsset
|
||||
import MastodonLocalization
|
||||
|
||||
struct MultiFollowersCountWidgetView: View {
|
||||
@Environment(\.widgetFamily) var family
|
||||
|
@ -17,10 +18,10 @@ struct MultiFollowersCountWidgetView: View {
|
|||
case .systemMedium:
|
||||
viewForMediumWidget(accounts)
|
||||
default:
|
||||
Text("Sorry but this Widget family is unsupported.")
|
||||
Text(L10n.Widget.Common.unsupportedWidgetFamily)
|
||||
}
|
||||
} else {
|
||||
Text("Please open Mastodon to log in to an Account.")
|
||||
Text(L10n.Widget.Common.userNotLoggedIn)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
.padding(.all, 20)
|
||||
|
|
Loading…
Reference in New Issue