From 8c2c6a80aa8c73af73105cdb233c0aa6a472b180 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 19 Sep 2016 14:17:48 -0400 Subject: [PATCH] Library Localized Strings --- .../Library/CloudBooksController.swift | 20 ++++++++++++++----- .../Library/DownloadTasksController.swift | 19 ++++++++++++------ .../Library/LocalBooksController.swift | 9 ++++++++- Kiwix-iOS/Info.plist | 2 +- Kiwix-iOSWidgets/Bookmarks/Info.plist | 2 +- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Kiwix-iOS/Controller/Library/CloudBooksController.swift b/Kiwix-iOS/Controller/Library/CloudBooksController.swift index a4604a07..44b581ef 100644 --- a/Kiwix-iOS/Controller/Library/CloudBooksController.swift +++ b/Kiwix-iOS/Controller/Library/CloudBooksController.swift @@ -20,7 +20,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - tabBarItem.title = LocalizedStrings.LibraryTabTitle.cloud + tabBarItem.title = LocalizedStrings.cloud tabBarItem.image = UIImage(named: "Cloud") tabBarItem.selectedImage = UIImage(named: "CloudFilled") } @@ -133,7 +133,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel let hud = MBProgressHUD.showHUDAddedTo(view, animated: true) hud.mode = .Text hud.label.numberOfLines = 0 - hud.label.text = NSLocalizedString("Library is refreshed successfully!", comment: "Cloud Book Controller") + hud.label.text = LocalizedStrings.libRefreshSuccessMessage hud.hideAnimated(true, afterDelay: 2) } @@ -154,7 +154,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel let alert = UIAlertController(title: NSLocalizedString("Only Show Preferred Language?", comment: comment), message: NSLocalizedString(String(format: "Would you like to filter the library by %@?", string), comment: comment), preferredStyle: .Alert) - let action = UIAlertAction(title: LocalizedStrings.Common.yes, style: .Default) { (action) in + let action = UIAlertAction(title: "Yes", style: .Default) { (action) in self.managedObjectContext.performBlock({ let codes = NSLocale.preferredLangCodes Language.fetchAll(self.managedObjectContext).forEach({ (language) in @@ -164,7 +164,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel }) } alert.addAction(action) - alert.addAction(UIAlertAction(title: LocalizedStrings.Common.cancel, style: .Cancel, handler: nil)) + alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)) alert.preferredAction = action presentViewController(alert, animated: true, completion: nil) } @@ -286,7 +286,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel action.backgroundColor = UIColor.orangeColor() return [action] case .NotEnough: - let action = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: LocalizedStrings.Library.spaceNotEnough, handler: { _ in + let action = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: LocalizedStrings.spaceNotEnough, handler: { _ in let alert = SpaceNotEnoughAlert(context: self) GlobalQueue.shared.addOperation(alert) self.tableView.setEditing(false, animated: true) @@ -369,4 +369,14 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel func controllerDidChangeContent(controller: NSFetchedResultsController) { tableView.endUpdates() } + + // MARK: - LocalizedStrings + + class LocalizedStrings{ + static let cloud = NSLocalizedString("Cloud", comment: "Library, cloud tab") + + static let download = NSLocalizedString("Download", comment: "Library, cloud tab") + static let spaceNotEnough = NSLocalizedString("Space Not Enough", comment: "Library, cloud tab") + static let libRefreshSuccessMessage = NSLocalizedString("Library is refreshed successfully!", comment: "Library, cloud tab") + } } diff --git a/Kiwix-iOS/Controller/Library/DownloadTasksController.swift b/Kiwix-iOS/Controller/Library/DownloadTasksController.swift index 102ca681..40b390df 100644 --- a/Kiwix-iOS/Controller/Library/DownloadTasksController.swift +++ b/Kiwix-iOS/Controller/Library/DownloadTasksController.swift @@ -118,7 +118,7 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController if string.containsString(" — ") { return string.stringByReplacingOccurrencesOfString(" — ", withString: "\n") } else { - return string + "\n" + "Estimating" + return string + "\n" + LocalizedStrings.estimating } } else { return string + "\n" + String(downloadTask.state) @@ -131,10 +131,9 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController cell.detailLabel.text = { let downloadedSize = NSByteCountFormatter.stringFromByteCount(downloadTask.totalBytesWritten, countStyle: .File) let fileSize = book.fileSizeDescription - return String(format: "%@ of %@ completed", downloadedSize, fileSize) + "\n" + String(downloadTask.state) + return String(format: LocalizedStrings.percentCompleted, downloadedSize, fileSize) + "\n" + String(downloadTask.state) }() } - } // MARK: Other Data Source @@ -186,21 +185,21 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController var actions = [UITableViewRowAction]() switch downloadTask.state { case .Downloading: - let pause = UITableViewRowAction(style: .Normal, title: "Pause") { (action, indexPath) in + let pause = UITableViewRowAction(style: .Normal, title: LocalizedStrings.pause) { (action, indexPath) in let operation = PauseBookDwonloadOperation(bookID: bookID) Network.shared.queue.addOperation(operation) tableView.setEditing(false, animated: true) } actions.insert(pause, atIndex: 0) case .Paused: - let resume = UITableViewRowAction(style: .Normal, title: "Resume") { (action, indexPath) in + let resume = UITableViewRowAction(style: .Normal, title: LocalizedStrings.resume) { (action, indexPath) in let operation = ResumeBookDwonloadOperation(bookID: bookID) Network.shared.queue.addOperation(operation) tableView.setEditing(false, animated: true) } actions.insert(resume, atIndex: 0) case .Error: - let restart = UITableViewRowAction(style: .Normal, title: "Restart") { (action, indexPath) in + let restart = UITableViewRowAction(style: .Normal, title: LocalizedStrings.restart) { (action, indexPath) in let operation = ResumeBookDwonloadOperation(bookID: bookID) Network.shared.queue.addOperation(operation) tableView.setEditing(false, animated: true) @@ -294,6 +293,14 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController class LocalizedStrings { static let download = NSLocalizedString("Download", comment: "Library, download tab") + + static let pause = NSLocalizedString("Pause", comment: "Library, download tab") + static let resume = NSLocalizedString("Resume", comment: "Library, download tab") + static let restart = NSLocalizedString("Restart", comment: "Library, download tab") + static let cancel = NSLocalizedString("Cancel", comment: "Library, download tab") + + static let estimating = NSLocalizedString("Estimating", comment: "Library, download tab") + static let percentCompleted = NSLocalizedString("%@ of %@ completed", comment: "Library, download tab") } diff --git a/Kiwix-iOS/Controller/Library/LocalBooksController.swift b/Kiwix-iOS/Controller/Library/LocalBooksController.swift index e5bcce44..264f946f 100644 --- a/Kiwix-iOS/Controller/Library/LocalBooksController.swift +++ b/Kiwix-iOS/Controller/Library/LocalBooksController.swift @@ -17,7 +17,7 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - tabBarItem.title = LocalizedStrings.LibraryTabTitle.local + tabBarItem.title = LocalizedStrings.local tabBarItem.image = UIImage(named: "Folder") tabBarItem.selectedImage = UIImage(named: "FolderFilled") } @@ -191,4 +191,11 @@ class LocalBooksController: UITableViewController, NSFetchedResultsControllerDel func controllerDidChangeContent(controller: NSFetchedResultsController) { tableView.endUpdates() } + + // MARK: - LocalizedStrings + + class LocalizedStrings{ + static let local = NSLocalizedString("Local", comment: "Library, local tab") + static let remove = NSLocalizedString("Remove", comment: "Library, local tab") + } } diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 2f84c5f5..c389140f 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.8.827 + 1.8.838 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index b4d17f96..4c6cf008 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.8.830 + 1.8.841 NSExtension NSExtensionMainStoryboard