Skip to content

Commit

Permalink
Localize search and details features
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniCarlo committed Apr 30, 2023
1 parent 8b2e18f commit ab9fe7d
Show file tree
Hide file tree
Showing 28 changed files with 514 additions and 250 deletions.
29 changes: 21 additions & 8 deletions BookPlayer/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
Localizable.strings
BookPlayer

Created by Gianni Carlo on 12/29/19.
Copyright © 2019 Tortuga Power. All rights reserved.
*/

"library_title" = "Library";
"settings_button" = "Settings";
"settings_title" = "Settings";
Expand Down Expand Up @@ -231,3 +223,24 @@
"gesture_swipe_left_title" = "Swipe left to rewind";
"gesture_swipe_right_title" = "Swipe right to skip forward";
"gesture_swipe_vertically_title" = "Swipe vertically to create bookmark";
"details_title" = "Details";
"download_title" = "Download";
"cancel_download_title" = "Cancel download";
"remove_downloaded_file_title" = "Remove from device";
"download_from_url_title" = "Download from URL";
"done_title" = "Done";
"select_title" = "Select";
"sort_button_title" = "Sort";
"search_title" = "Search";
"books_title" = "Books";
"folders_title" = "Folders";
"item_title_placeholder" = "Title";
"item_author_placeholder" = "Author";
"artwork_options_title" = "Artwork options";
"artwork_photolibrary_title" = "Choose from Photo Library";
"artwork_clipboard_title" = "Paste from clipboard";
"artwork_reset_title" = "Reset";
"artwork_clipboard_empty_title" = "No image in the clipboard";
"artwork_title" = "Artwork";
"update_title" = "Update";
"edit_title" = "Edit";
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ItemDetailsViewController: BaseViewController<ItemDetailsCoordinator, Item
}

func setupNavigationItem() {
self.navigationItem.title = "Edit"
self.navigationItem.title = "edit_title".localized
self.navigationItem.leftBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .cancel,
target: self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ struct ItemDetailsArtworkSectionView: View {
var body: some View {
Section(
header: HStack {
Text("Artwork")
Text("artwork_title".localized)
.foregroundColor(themeViewModel.secondaryColor)
Spacer()
Button(action: actionHandler) {
if image != nil {
Text("Update")
Text("update_title".localized)
} else {
Text("Add")
Text("library_add_button".localized)
}
}
.foregroundColor(themeViewModel.linkColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ struct ItemDetailsForm: View {

var body: some View {
Form {
Section(header: Text("Details")
Section(header: Text("details_title".localized)
.foregroundColor(themeViewModel.secondaryColor)
) {
ClearableTextField("Title", text: $viewModel.title)
ClearableTextField("item_title_placeholder".localized, text: $viewModel.title)
if viewModel.showAuthor {
ClearableTextField("Author", text: $viewModel.author)
ClearableTextField("item_author_placeholder".localized, text: $viewModel.author)
}
}
.listRowBackground(themeViewModel.secondarySystemBackgroundColor)
Expand All @@ -44,19 +44,19 @@ struct ItemDetailsForm: View {
})
.actionSheet(isPresented: $showingArtworkOptions) {
ActionSheet(
title: Text("Artwork options"),
title: Text("artwork_options_title".localized),
buttons: [
.default(Text("Choose from Photo Library")) {
.default(Text("artwork_photolibrary_title".localized)) {
showingImagePicker = true
},
.default(Text("Paste from clipboard")) {
.default(Text("artwork_clipboard_title".localized)) {
if let image = UIPasteboard.general.image {
viewModel.selectedImage = image
} else {
showingEmptyPasteboardAlert = true
}
},
.default(Text("Reset")) {
.default(Text("artwork_reset_title".localized)) {
viewModel.resetArtwork()
},
.cancel(),
Expand All @@ -68,8 +68,8 @@ struct ItemDetailsForm: View {
}
.alert(isPresented: $showingEmptyPasteboardAlert) {
Alert(
title: Text("No image in the clipboard"),
dismissButton: .default(Text("Ok"))
title: Text("artwork_clipboard_empty_title".localized),
dismissButton: .default(Text("ok_button".localized))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ItemListViewController: BaseViewController<ItemListCoordinator, ItemListVi

private lazy var sortButton: UIButton = {
let button = ComposedButton(
title: "Sort",
title: "sort_button_title".localized,
systemImage: "chevron.down",
imageHeight: 8
)
Expand All @@ -45,7 +45,7 @@ class ItemListViewController: BaseViewController<ItemListCoordinator, ItemListVi
}()

private lazy var selectButton: UIButton = {
let button = ComposedButton(title: "Select")
let button = ComposedButton(title: "select_title".localized)
button.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
button.addTarget(self, action: #selector(handleSelectButtonPressed), for: .touchUpInside)
return button
Expand Down Expand Up @@ -311,14 +311,14 @@ class ItemListViewController: BaseViewController<ItemListCoordinator, ItemListVi
self.tableView.setEditing(editing, animated: true)

if editing {
self.selectButton.setTitle("Done", for: .normal)
self.selectButton.setTitle("done_title".localized, for: .normal)
self.navigationItem.rightBarButtonItem?.isEnabled = false
self.selectAllButton.isHidden = false
sortButton.isHidden = true
self.selectAllButton.isEnabled = self.tableView.numberOfRows(inSection: BPSection.data.rawValue) > 0
self.updateSelectionStatus()
} else {
self.selectButton.setTitle("Select", for: .normal)
self.selectButton.setTitle("select_title".localized, for: .normal)
self.selectAllButton.isHidden = true
sortButton.isHidden = false
self.navigationItem.rightBarButtonItem?.isEnabled = true
Expand Down
20 changes: 8 additions & 12 deletions BookPlayer/Library/ItemList Screen/ItemListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ class ItemListViewModel: BaseViewModel<ItemListCoordinator> {
}
),
BPActionItem(
// TODO: translate string for download button
title: "download_button".localized,
title: "download_title".localized,
handler: { [weak self] in
self?.showDownloadFromUrlAlert()
}
Expand Down Expand Up @@ -637,10 +636,10 @@ class ItemListViewModel: BaseViewModel<ItemListCoordinator> {
guard let item = selectedItems.first else { return }

let isSingle = selectedItems.count == 1
// TODO: localize

var actions = [
BPActionItem(
title: "Details",
title: "details_title".localized,
isEnabled: isSingle,
handler: { [weak self] in
self?.onTransition?(.showItemDetails(item: item))
Expand Down Expand Up @@ -721,17 +720,17 @@ class ItemListViewModel: BaseViewModel<ItemListCoordinator> {

switch getDownloadState(for: item) {
case .notDownloaded:
title = "Download"
title = "download_title".localized
handler = { [weak self] in
self?.startDownload(of: item)
}
case .downloading:
title = "Cancel download"
title = "cancel_download_title".localized
handler = { [weak self] in
self?.cancelDownload(of: item)
}
case .downloaded:
title = "Remove from device"
title = "remove_downloaded_file_title".localized
handler = { [weak self] in
do {
let fileURL = item.fileURL
Expand Down Expand Up @@ -877,14 +876,12 @@ class ItemListViewModel: BaseViewModel<ItemListCoordinator> {
func showDownloadFromUrlAlert() {
sendEvent(.showAlert(
content: BPAlertContent(
// TODO: Translate title
title: "download_from_url_title".localized,
style: .alert,
textInputPlaceholder: "https://",
actionItems: [
BPActionItem(
// TODO: translate button
title: "download_button".localized,
title: "download_title".localized,
inputHandler: { [weak self] url in
if let bookUrl = URL(string: url) {
self?.handleDownload(bookUrl)
Expand Down Expand Up @@ -1238,10 +1235,9 @@ extension ItemListViewModel {
func cancelDownload(of item: SimpleLibraryItem) {
guard let tasks = downloadTasksDictionary[item.relativePath] else { return }

/// TODO: Localize
sendEvent(.showAlert(
content: BPAlertContent(
message: "Cancel download",
message: "cancel_download_title".localized,
style: .alert,
actionItems: [
BPActionItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BulkControlsView: NibLoadableView {
override func awakeFromNib() {
super.awakeFromNib()

self.editButton.accessibilityLabel = "Details"
self.editButton.accessibilityLabel = "details_title".localized
self.moveButton.accessibilityLabel = "move_title".localized
self.trashButton.accessibilityLabel = "delete_button".localized
self.moreButton.accessibilityLabel = "options_button".localized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SearchListViewController: BaseViewController<SearchListCoordinator, Search
}

func setupSearchBar() {
searchBar.placeholder = "Search \(viewModel.placeholderTitle)"
searchBar.placeholder = "search_title".localized + " \(viewModel.placeholderTitle)"
searchBar.showsCancelButton = false
searchBar.returnKeyType = .done
searchBar.enablesReturnKeyAutomatically = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class SearchListViewModel: BaseViewModel<SearchListCoordinator> {
return searchScopes.map { item in
switch item {
case .book, .bound:
return "Books"
return "books_title".localized
case .folder:
return "Folders"
return "folders_title".localized
}
}
}
Expand Down
29 changes: 21 additions & 8 deletions BookPlayer/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
Localizable.strings
BookPlayer

Created by Gianni Carlo on 12/29/19.
Copyright © 2019 Tortuga Power. All rights reserved.
*/

"library_title" = "المكتبة";
"settings_button" = "الاعدادات";
"settings_title" = "الاعدادات";
Expand Down Expand Up @@ -231,3 +223,24 @@
"gesture_swipe_left_title" = "اسحب لليسار للترجيع";
"gesture_swipe_right_title" = "اسحب لليمين للتخطي للأمام";
"gesture_swipe_vertically_title" = "اسحب عموديًا لإنشاء إشارة مرجعية";
"details_title" = "تفاصيل";
"download_title" = "تحميل";
"cancel_download_title" = "إلغاء التنزيل";
"remove_downloaded_file_title" = "إزالة من الجهاز";
"download_from_url_title" = "تنزيل من URL";
"done_title" = "منتهي";
"select_title" = "يختار";
"sort_button_title" = "نوع";
"search_title" = "يبحث";
"books_title" = "كتب";
"folders_title" = "المجلدات";
"item_title_placeholder" = "عنوان";
"item_author_placeholder" = "مؤلف";
"artwork_options_title" = "خيارات العمل الفني";
"artwork_photolibrary_title" = "اختر من مكتبة الصور";
"artwork_clipboard_title" = "لصق من الحافظة";
"artwork_reset_title" = "إعادة ضبط";
"artwork_clipboard_empty_title" = "لا توجد صورة في الحافظة";
"artwork_title" = "عمل فني";
"update_title" = "تحديث";
"edit_title" = "يحرر";
29 changes: 21 additions & 8 deletions BookPlayer/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
Localizable.strings
BookPlayer

Created by Gianni Carlo on 12/29/19.
Copyright © 2019 Tortuga Power. All rights reserved.
*/

"library_title" = "Knihovna";
"settings_button" = "Nastavení";
"settings_title" = "Nastavení";
Expand Down Expand Up @@ -231,3 +223,24 @@
"gesture_swipe_left_title" = "Přejetím doleva převinete zpět";
"gesture_swipe_right_title" = "Přejetím doprava přeskočíte vpřed";
"gesture_swipe_vertically_title" = "Záložku vytvoříte přejetím prstem svisle";
"details_title" = "Podrobnosti";
"download_title" = "Stažení";
"cancel_download_title" = "Zrušit stahování";
"remove_downloaded_file_title" = "Odebrat ze zařízení";
"download_from_url_title" = "Stáhnout z URL";
"done_title" = "Hotovo";
"select_title" = "Vybrat";
"sort_button_title" = "Seřadit";
"search_title" = "Vyhledávání";
"books_title" = "knihy";
"folders_title" = "Složky";
"item_title_placeholder" = "Titul";
"item_author_placeholder" = "Autor";
"artwork_options_title" = "Možnosti uměleckého díla";
"artwork_photolibrary_title" = "Vyberte si z knihovny fotografií";
"artwork_clipboard_title" = "Vložit ze schránky";
"artwork_reset_title" = "Resetovat";
"artwork_clipboard_empty_title" = "Ve schránce není žádný obrázek";
"artwork_title" = "Umělecké dílo";
"update_title" = "Aktualizace";
"edit_title" = "Upravit";
29 changes: 21 additions & 8 deletions BookPlayer/da.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
Localizable.strings
BookPlayer

Created by Gianni Carlo on 12/29/19.
Copyright © 2019 Tortuga Power. All rights reserved.
*/

"library_title" = "Bibliotek";
"settings_button" = "Indstillinger";
"settings_title" = "Indstillinger";
Expand Down Expand Up @@ -231,3 +223,24 @@
"gesture_swipe_left_title" = "Stryg til venstre for at spole tilbage";
"gesture_swipe_right_title" = "Stryg til højre for at springe fremad";
"gesture_swipe_vertically_title" = "Stryg lodret for at oprette et bogmærke";
"details_title" = "detaljer";
"download_title" = "Hent";
"cancel_download_title" = "Annuller download";
"remove_downloaded_file_title" = "Fjern fra enheden";
"download_from_url_title" = "Download fra URL";
"done_title" = "Færdig";
"select_title" = "Vælg";
"sort_button_title" = "Sortere";
"search_title" = "Søg";
"books_title" = "Bøger";
"folders_title" = "Mapper";
"item_title_placeholder" = "Titel";
"item_author_placeholder" = "Forfatter";
"artwork_options_title" = "Muligheder for kunstværker";
"artwork_photolibrary_title" = "Vælg fra Fotobibliotek";
"artwork_clipboard_title" = "Indsæt fra udklipsholder";
"artwork_reset_title" = "Nulstil";
"artwork_clipboard_empty_title" = "Intet billede i udklipsholderen";
"artwork_title" = "Kunstværk";
"update_title" = "Opdatering";
"edit_title" = "Redigere";
Loading

0 comments on commit ab9fe7d

Please sign in to comment.