Library Localized Strings

This commit is contained in:
Chris Li 2016-09-19 14:17:48 -04:00
parent 043ad93fcd
commit 8c2c6a80aa
5 changed files with 38 additions and 14 deletions

View File

@ -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")
}
}

View File

@ -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")
}

View File

@ -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")
}
}

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.8.827</string>
<string>1.8.838</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.8.830</string>
<string>1.8.841</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>