From 53647dfb0e786b71b3c75f6ea68c66f609cfb3ce Mon Sep 17 00:00:00 2001 From: CMK Date: Mon, 9 Aug 2021 15:14:08 +0800 Subject: [PATCH] chore: update i18n --- Localization/Localizable.stringsdict | 242 ++++++++++++++++++ Localization/app.json | 25 +- .../xcschemes/xcschememanagement.plist | 12 +- .../Section/Status/StatusSection.swift | 6 +- Mastodon/Extension/Date.swift | 24 +- .../Compose/ComposeViewModel+DataSource.swift | 2 +- .../Share/View/Node/Status/StatusNode.swift | 4 +- 7 files changed, 275 insertions(+), 40 deletions(-) diff --git a/Localization/Localizable.stringsdict b/Localization/Localizable.stringsdict index b002a41c3..cfa87b017 100644 --- a/Localization/Localizable.stringsdict +++ b/Localization/Localizable.stringsdict @@ -2,6 +2,50 @@ + a11y.plural.count.input_limit_exceeds + + NSStringLocalizedFormatKey + Input limit exceeds %#@character_count@ + character_count + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 characters + one + 1 character + few + %ld characters + many + %ld characters + other + %ld characters + + + a11y.plural.count.input_limit_remains + + NSStringLocalizedFormatKey + Input limit remains %#@character_count@ + character_count + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 characters + one + 1 character + few + %ld characters + many + %ld characters + other + %ld characters + + plural.count.metric_formatted.post NSStringLocalizedFormatKey @@ -23,6 +67,28 @@ other posts + + plural.count.post + + NSStringLocalizedFormatKey + %#@post_count@ + post_count + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 posts + one + 1 post + few + %ld posts + many + %ld posts + other + %ld posts + plural.count.favorite @@ -134,5 +200,181 @@ %ld people talking + plural.count.following + + NSStringLocalizedFormatKey + %#@count_following@ + count_following + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 following + one + 1 following + few + %ld following + many + %ld following + other + %ld following + + + plural.count.follower + + NSStringLocalizedFormatKey + %#@count_follower@ + count_follower + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 followers + one + 1 follower + few + %ld followers + many + %ld followers + other + %ld followers + + + date.year.left + + NSStringLocalizedFormatKey + %#@count_year_left@ + count_year_left + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 years left + one + 1 year left + few + %ld years left + many + %ld years left + other + %ld years left + + + date.month.left + + NSStringLocalizedFormatKey + %#@count_month_left@ + count_month_left + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 months left + one + 1 months left + few + %ld months left + many + %ld months left + other + %ld months left + + + date.day.left + + NSStringLocalizedFormatKey + %#@count_day_left@ + count_day_left + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 days left + one + 1 day left + few + %ld days left + many + %ld days left + other + %ld days left + + + date.hour.left + + NSStringLocalizedFormatKey + %#@count_hour_left@ + count_hour_left + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 hours left + one + 1 hour left + few + %ld hours left + many + %ld hours left + other + %ld hours left + + + date.minute.left + + NSStringLocalizedFormatKey + %#@count_minute_left@ + count_minute_left + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 minutes left + one + 1 minute left + few + %ld minutes left + many + %ld minutes left + other + %ld minutes left + + + date.second.left + + NSStringLocalizedFormatKey + %#@count_second_left@ + count_second_left + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + zero + 0 seconds left + one + 1 second left + few + %ld seconds left + many + %ld seconds left + other + %ld seconds left + + diff --git a/Localization/app.json b/Localization/app.json index 7b5e271e4..ba6aca468 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -13,7 +13,7 @@ }, "vote_failure": { "title": "Vote Failure", - "poll_expired": "The poll has expired" + "poll_ended": "The poll has ended" }, "discard_post_content": { "title": "Discard Draft", @@ -130,7 +130,6 @@ "media_content_warning": "Tap anywhere to reveal", "poll": { "vote": "Vote", - "time_left": "%s left", "closed": "Closed" }, "actions": { @@ -171,8 +170,7 @@ "timeline": { "filtered": "Filtered", "timestamp": { - "now": "Now", - "time_ago": "%s ago" + "now": "Now" }, "loader": { "load_missing_posts": "Load missing posts", @@ -187,11 +185,6 @@ "user_blocked_warning": "You can’t view %s’s profile\n until they unblock you.", "suspended_warning": "This user has been suspended.", "user_suspended_warning": "%s’s account has been suspended." - }, - "accessibility": { - "count_replies": "%s replies", - "count_reblogs": "%s reblogs", - "count_favorites": "%s favorites" } } } @@ -383,9 +376,7 @@ "custom_emoji_picker": "Custom Emoji Picker", "enable_content_warning": "Enable Content Warning", "disable_content_warning": "Disable Content Warning", - "post_visibility_menu": "Post Visibility Menu", - "input_limit_remains_count": "Input limit remains %ld", - "input_limit_exceeds_count": "Input limit exceeds %ld" + "post_visibility_menu": "Post Visibility Menu" }, "keyboard": { "discard_post": "Discard Post", @@ -400,12 +391,7 @@ "dashboard": { "posts": "posts", "following": "following", - "followers": "followers", - "accessibility": { - "count_posts": "%ld posts", - "count_following": "%ld following", - "count_followers": "%ld followers" - } + "followers": "followers" }, "fields": { "add_row": "Add Row", @@ -463,9 +449,6 @@ "clear": "Clear" } }, - "hashtag": { - "prompt": "%s people talking" - }, "favorite": { "title": "Your Favorites" }, diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index 575dc6248..6faa9959a 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,12 +7,12 @@ AppShared.xcscheme_^#shared#^_ orderHint - 32 + 30 CoreDataStack.xcscheme_^#shared#^_ orderHint - 33 + 34 Mastodon - ASDK.xcscheme_^#shared#^_ @@ -37,7 +37,7 @@ Mastodon - ca.xcscheme_^#shared#^_ orderHint - 30 + 29 Mastodon - en.xcscheme_^#shared#^_ @@ -67,7 +67,7 @@ Mastodon - zh_Hans.xcscheme_^#shared#^_ orderHint - 29 + 28 Mastodon.xcscheme_^#shared#^_ @@ -77,7 +77,7 @@ MastodonIntent.xcscheme_^#shared#^_ orderHint - 31 + 32 MastodonIntents.xcscheme_^#shared#^_ @@ -97,7 +97,7 @@ ShareActionExtension.xcscheme_^#shared#^_ orderHint - 35 + 31 SuppressBuildableAutocreation diff --git a/Mastodon/Diffiable/Section/Status/StatusSection.swift b/Mastodon/Diffiable/Section/Status/StatusSection.swift index 0958ec73f..92f39b215 100644 --- a/Mastodon/Diffiable/Section/Status/StatusSection.swift +++ b/Mastodon/Diffiable/Section/Status/StatusSection.swift @@ -390,14 +390,14 @@ extension StatusSection { StatusSection.configureStatusViewAuthor(cell: cell, status: status) // set timestamp let createdAt = (status.reblog ?? status).createdAt - cell.statusView.dateLabel.text = createdAt.slowedTimeAgoSinceNow + cell.statusView.dateLabel.text = createdAt.localizedSlowedTimeAgoSinceNow cell.statusView.dateLabel.accessibilityValue = createdAt.timeAgoSinceNow AppContext.shared.timestampUpdatePublisher .receive(on: RunLoop.main) // will be paused when scrolling (on purpose) .sink { [weak cell] _ in guard let cell = cell else { return } - cell.statusView.dateLabel.text = createdAt.slowedTimeAgoSinceNow - cell.statusView.dateLabel.accessibilityLabel = createdAt.slowedTimeAgoSinceNow + cell.statusView.dateLabel.text = createdAt.localizedSlowedTimeAgoSinceNow + cell.statusView.dateLabel.accessibilityLabel = createdAt.localizedSlowedTimeAgoSinceNow } .store(in: &cell.disposeBag) // set content diff --git a/Mastodon/Extension/Date.swift b/Mastodon/Extension/Date.swift index daa5eab6c..2d2ff6a99 100644 --- a/Mastodon/Extension/Date.swift +++ b/Mastodon/Extension/Date.swift @@ -10,21 +10,31 @@ import DateToolsSwift extension Date { - var slowedTimeAgoSinceNow: String { - return self.slowedTimeAgo(since: Date()) + static let relativeTimestampFormatter: RelativeDateTimeFormatter = { + let formatter = RelativeDateTimeFormatter() + formatter.dateTimeStyle = .numeric + formatter.unitsStyle = .abbreviated + return formatter + }() + + var localizedSlowedTimeAgoSinceNow: String { + return self.localizedSlowedTimeAgo(since: Date()) } - func slowedTimeAgo(since date: Date) -> String { + func localizedSlowedTimeAgo(since date: Date) -> String { let earlierDate = date < self ? date : self - let latest = earlierDate == date ? self : date + let latestDate = earlierDate == date ? self : date - if earlierDate.timeIntervalSince(latest) >= -60 { + if earlierDate.timeIntervalSince(latestDate) >= -60 { return L10n.Common.Controls.Timeline.Timestamp.now } else { - let interval = latest.shortTimeAgo(since: earlierDate) // 1s - return L10n.Common.Controls.Timeline.Timestamp.timeAgo(interval) // 1s ago + return Date.relativeTimestampFormatter.localizedString(for: earlierDate, relativeTo: latestDate) } } + func timeLeft() -> String { + return "" + } + } diff --git a/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift b/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift index 49406144b..f6e700fbb 100644 --- a/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift +++ b/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift @@ -212,7 +212,7 @@ extension ComposeViewModel: UITableViewDataSource { assertionFailure() } // set date - cell.statusView.dateLabel.text = status.createdAt.slowedTimeAgoSinceNow + cell.statusView.dateLabel.text = status.createdAt.localizedSlowedTimeAgoSinceNow } return cell case .status: diff --git a/Mastodon/Scene/Share/View/Node/Status/StatusNode.swift b/Mastodon/Scene/Share/View/Node/Status/StatusNode.swift index 693540473..2f640a140 100644 --- a/Mastodon/Scene/Share/View/Node/Status/StatusNode.swift +++ b/Mastodon/Scene/Share/View/Node/Status/StatusNode.swift @@ -101,7 +101,7 @@ final class StatusNode: ASCellNode { .font: UIFont.systemFont(ofSize: 13, weight: .regular) ]) // set date - dateTextNode.attributedText = NSAttributedString(string: timestamp.slowedTimeAgoSinceNow, attributes: [ + dateTextNode.attributedText = NSAttributedString(string: timestamp.localizedSlowedTimeAgoSinceNow, attributes: [ .foregroundColor: Asset.Colors.Label.secondary.color, .font: UIFont.systemFont(ofSize: 13, weight: .regular) ]) @@ -131,7 +131,7 @@ final class StatusNode: ASCellNode { timestampSubscription = AppContext.shared.timestampUpdatePublisher .sink { [weak self] _ in guard let self = self else { return } - self.dateTextNode.attributedText = NSAttributedString(string: self.timestamp.slowedTimeAgoSinceNow, attributes: [ + self.dateTextNode.attributedText = NSAttributedString(string: self.timestamp.localizedSlowedTimeAgoSinceNow, attributes: [ .foregroundColor: Asset.Colors.Label.secondary.color, .font: UIFont.systemFont(ofSize: 13, weight: .regular) ])