Sprinkle in some localization (IOS-141)

This commit is contained in:
Nathan Mattes 2023-09-17 13:34:08 +02:00
parent ed56e7aebe
commit 558f88e77a
5 changed files with 32 additions and 28 deletions

View File

@ -651,12 +651,10 @@
}
},
"searching": {
"segment": {
"all": "All",
"people": "People",
"hashtags": "Hashtags",
"posts": "Posts"
},
"posts": "Posts with \"%@\"",
"people": "People with \"%@\"",
"profile": "Go to @%@@%@",
"url": "Open Link",
"empty_state": {
"no_results": "No results"
},

View File

@ -2,6 +2,7 @@
import UIKit
import MastodonSDK
import MastodonLocalization
import CoreDataStack
enum SearchResultOverviewSection: Hashable {
@ -21,15 +22,14 @@ enum SearchResultOverviewItem: Hashable {
var title: String {
switch self {
//TODO: Add localization
case .posts(let text):
return "Posts with \(text)"
return L10n.Scene.Search.Searching.posts(text)
case .people(let username):
return "People with \(username)"
return L10n.Scene.Search.Searching.people(username)
case .profile(let username, let instanceName):
return "Go to @\(username)@\(instanceName)"
return L10n.Scene.Search.Searching.profile(username, instanceName)
case .openLink(_):
return "Open Link"
return L10n.Scene.Search.Searching.url
}
}
@ -46,11 +46,11 @@ enum SearchResultOverviewItem: Hashable {
}
}
}
enum SuggestionSectionEntry: Hashable {
case hashtag(tag: Mastodon.Entity.Tag)
case profile(user: Mastodon.Entity.Account)
var title: String? {
if case let .hashtag(tag) = self {
return tag.name
@ -58,7 +58,7 @@ enum SearchResultOverviewItem: Hashable {
return nil
}
}
var icon: UIImage? {
if case .hashtag(_) = self {
return UIImage(systemName: "number")

View File

@ -116,6 +116,8 @@ extension SearchResultViewController {
self.tableView.verticalScrollIndicatorInsets.top = frame.height
}
.store(in: &disposeBag)
title = viewModel.searchText.value
}
override func viewWillAppear(_ animated: Bool) {

View File

@ -1279,22 +1279,26 @@ public enum L10n {
public static let clear = L10n.tr("Localizable", "Scene.Search.Searching.Clear", fallback: "Clear")
/// Clear all
public static let clearAll = L10n.tr("Localizable", "Scene.Search.Searching.ClearAll", fallback: "Clear all")
/// People with "%@"
public static func people(_ p1: Any) -> String {
return L10n.tr("Localizable", "Scene.Search.Searching.People", String(describing: p1), fallback: "People with \"%@\"")
}
/// Posts with "%@"
public static func posts(_ p1: Any) -> String {
return L10n.tr("Localizable", "Scene.Search.Searching.Posts", String(describing: p1), fallback: "Posts with \"%@\"")
}
/// Go to @%@@%@
public static func profile(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "Scene.Search.Searching.Profile", String(describing: p1), String(describing: p2), fallback: "Go to @%@@%@")
}
/// Recent searches
public static let recentSearch = L10n.tr("Localizable", "Scene.Search.Searching.RecentSearch", fallback: "Recent searches")
/// Open Link
public static let url = L10n.tr("Localizable", "Scene.Search.Searching.Url", fallback: "Open Link")
public enum EmptyState {
/// No results
public static let noResults = L10n.tr("Localizable", "Scene.Search.Searching.EmptyState.NoResults", fallback: "No results")
}
public enum Segment {
/// All
public static let all = L10n.tr("Localizable", "Scene.Search.Searching.Segment.All", fallback: "All")
/// Hashtags
public static let hashtags = L10n.tr("Localizable", "Scene.Search.Searching.Segment.Hashtags", fallback: "Hashtags")
/// People
public static let people = L10n.tr("Localizable", "Scene.Search.Searching.Segment.People", fallback: "People")
/// Posts
public static let posts = L10n.tr("Localizable", "Scene.Search.Searching.Segment.Posts", fallback: "Posts")
}
}
}
public enum ServerPicker {

View File

@ -443,10 +443,10 @@ uploaded to Mastodon.";
"Scene.Search.Searching.ClearAll" = "Clear all";
"Scene.Search.Searching.EmptyState.NoResults" = "No results";
"Scene.Search.Searching.RecentSearch" = "Recent searches";
"Scene.Search.Searching.Segment.All" = "All";
"Scene.Search.Searching.Segment.Hashtags" = "Hashtags";
"Scene.Search.Searching.Segment.People" = "People";
"Scene.Search.Searching.Segment.Posts" = "Posts";
"Scene.Search.Searching.Posts" = "Posts with \"%@\"";
"Scene.Search.Searching.People" = "People with \"%@\"";
"Scene.Search.Searching.Profile" = "Go to @%@@%@";
"Scene.Search.Searching.Url" = "Open Link";
"Scene.Search.Title" = "Search";
"Scene.ServerPicker.Button.Category.Academia" = "academia";
"Scene.ServerPicker.Button.Category.Activism" = "activism";