IOS-511 rm String.localized
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 22 May 2017 18:39:45 +0200
changeset 21904fe9e5ba269d
parent 2189 13cc8dfac328
child 2191 a01eb69e9664
IOS-511 rm String.localized
pEpForiOS/Background/AppendMailsOperation.swift
pEpForiOS/Background/TrashMailsOperation.swift
pEpForiOS/UI/AccountsAndFolders/AccountsTableViewController.swift
pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
pEpForiOS/UI/EmailDisplay/EmailViewController.swift
pEpForiOS/UI/EmailDisplay/MessageSenderCell.swift
pEpForiOS/Util/Extensions/String+Extensions.swift
     1.1 --- a/pEpForiOS/Background/AppendMailsOperation.swift	Mon May 22 18:22:36 2017 +0200
     1.2 +++ b/pEpForiOS/Background/AppendMailsOperation.swift	Mon May 22 18:39:45 2017 +0200
     1.3 @@ -71,9 +71,11 @@
     1.4                      self.context.delete(obj)
     1.5                      Record.save(context: self.context)
     1.6                  } else {
     1.7 -                    self.handleError(Constants.errorInvalidParameter(self.comp),
     1.8 -                                     message:
     1.9 -                        "Cannot find message just stored in the sent folder".localized)
    1.10 +                    self.handleError(
    1.11 +                        Constants.errorInvalidParameter(self.comp),
    1.12 +                        message:
    1.13 +                        NSLocalizedString("Cannot find message just stored in the sent folder",
    1.14 +                                          comment: "Background operation error message"))
    1.15                      return
    1.16                  }
    1.17              }
    1.18 @@ -83,7 +85,8 @@
    1.19      func appendMessage(pEpMessage: PEPMessage?) {
    1.20          guard let msg = pEpMessage else {
    1.21              handleError(Constants.errorInvalidParameter(comp),
    1.22 -                        message: "Cannot append nil message".localized)
    1.23 +                        message: NSLocalizedString("Cannot append nil message",
    1.24 +                                                   comment: "Background operation error message"))
    1.25              return
    1.26          }
    1.27          guard let folderName = targetFolderName else {
    1.28 @@ -109,27 +112,37 @@
    1.29                      self.handleError(
    1.30                          Constants.errorInvalidParameter(self.comp),
    1.31                          message:
    1.32 -                        "Need a valid message for determining the sent folder name".localized)
    1.33 +                        NSLocalizedString(
    1.34 +                            "Need a valid message for determining the sent folder name",
    1.35 +                            comment: "Background operation error message"))
    1.36                      return
    1.37                  }
    1.38                  guard let account = msg.parent?.account else {
    1.39                      self.handleError(
    1.40                          Constants.errorInvalidParameter(self.comp),
    1.41                          message:
    1.42 -                        "Cannot append message without parent folder and this, account".localized)
    1.43 +                        NSLocalizedString(
    1.44 +                            "Cannot append message without parent folder and this, account",
    1.45 +                            comment: "Background operation error message"))
    1.46                      return
    1.47                  }
    1.48                  guard let folder = self.retrieveFolderForAppend(
    1.49                      account: account, context: self.context) else {
    1.50                          self.handleError(
    1.51                              Constants.errorInvalidParameter(self.comp),
    1.52 -                            message: "Cannot find sent folder for message to append".localized)
    1.53 +                            message:
    1.54 +                            NSLocalizedString(
    1.55 +                                "Cannot find sent folder for message to append",
    1.56 +                                comment: "Background operation error message"))
    1.57                          return
    1.58                  }
    1.59                  guard let fn = folder.name else {
    1.60                      self.handleError(
    1.61                          Constants.errorInvalidParameter(self.comp),
    1.62 -                        message: "Need the name for the sent folder".localized)
    1.63 +                        message:
    1.64 +                        NSLocalizedString(
    1.65 +                            "Need the name for the sent folder",
    1.66 +                            comment: "Background operation error message"))
    1.67                      return
    1.68                  }
    1.69                  self.targetFolderName = fn
    1.70 @@ -147,7 +160,11 @@
    1.71              let (encMsg2, error) = PEPUtil.check(
    1.72                  comp: comp, status: status, encryptedMessage: encMsg)
    1.73              if let err = error {
    1.74 -                handleError(err, message: "Cannot encrypt message".localized)
    1.75 +                handleError(
    1.76 +                    err,
    1.77 +                    message: NSLocalizedString(
    1.78 +                        "Cannot encrypt message",
    1.79 +                        comment: "Background operation error message"))
    1.80                  appendMessage(pEpMessage: msg as PEPMessage)
    1.81              } else {
    1.82                  appendMessage(pEpMessage: encMsg2 as? PEPMessage)
     2.1 --- a/pEpForiOS/Background/TrashMailsOperation.swift	Mon May 22 18:22:36 2017 +0200
     2.2 +++ b/pEpForiOS/Background/TrashMailsOperation.swift	Mon May 22 18:39:45 2017 +0200
     2.3 @@ -59,9 +59,12 @@
     2.4                      obj.imap = imap
     2.5                      Record.save(context: self.context)
     2.6                  } else {
     2.7 -                    self.handleError(Constants.errorInvalidParameter(self.comp),
     2.8 -                                     message:
     2.9 -                        "Cannot find message just stored in the sent folder".localized)
    2.10 +                    self.handleError(
    2.11 +                        Constants.errorInvalidParameter(self.comp),
    2.12 +                        message:
    2.13 +                        NSLocalizedString(
    2.14 +                            "Cannot find message just stored in the sent folder",
    2.15 +                            comment: "Background operation error message"))
    2.16                      return
    2.17                  }
    2.18              }
     3.1 --- a/pEpForiOS/UI/AccountsAndFolders/AccountsTableViewController.swift	Mon May 22 18:22:36 2017 +0200
     3.2 +++ b/pEpForiOS/UI/AccountsAndFolders/AccountsTableViewController.swift	Mon May 22 18:39:45 2017 +0200
     3.3 @@ -112,14 +112,14 @@
     3.4          } else if indexPath.section == 1 {
     3.5              if indexPath.row == 1{
     3.6                  let cell = tableView.dequeueReusableCell(withIdentifier: accountsCellIdentifier, for: indexPath)
     3.7 -                cell.textLabel?.text = "New Login".localized
     3.8 +                cell.textLabel?.text = NSLocalizedString("New Login", comment: "")
     3.9                  cell.accessoryType = .disclosureIndicator
    3.10                  cell.textLabel?.numberOfLines = 0
    3.11                  return cell
    3.12              }
    3.13  
    3.14              let cell = tableView.dequeueReusableCell(withIdentifier: accountsCellIdentifier, for: indexPath)
    3.15 -            cell.textLabel?.text = "Logging".localized
    3.16 +            cell.textLabel?.text = NSLocalizedString("Logging", comment: "")
    3.17              cell.accessoryType = .disclosureIndicator
    3.18              cell.textLabel?.numberOfLines = 0
    3.19              return cell
     4.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Mon May 22 18:22:36 2017 +0200
     4.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Mon May 22 18:39:45 2017 +0200
     4.3 @@ -201,9 +201,9 @@
     4.4              self.tableView.reloadRows(at: [indexPath], with: .none)
     4.5          }
     4.6  
     4.7 -        var title = "\n\nFlag".localized
     4.8 +        var title = "\n\n" + NSLocalizedString("Flag", comment: "Message action (on swipe)")
     4.9          if message.imapFlags?.flagged ?? true {
    4.10 -            title = "\n\nUnFlag".localized
    4.11 +            title = "\n\n" + NSLocalizedString("Unflag", comment: "Message action (on swipe)")
    4.12          }
    4.13  
    4.14          return createRowAction(
    4.15 @@ -223,7 +223,7 @@
    4.16  
    4.17          return createRowAction(
    4.18              cell: cell, image: UIImage(named: "swipe-trash"), action: action,
    4.19 -            title: "\n\nDelete".localized)
    4.20 +            title: "\n\n" + NSLocalizedString("Delete", comment: "Message action (on swipe)"))
    4.21      }
    4.22  
    4.23      func createMarkAsReadAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
    4.24 @@ -237,10 +237,10 @@
    4.25          }
    4.26  
    4.27          var title = NSLocalizedString(
    4.28 -            "Unread", comment: "Unread button title in swipe action on EmailListViewController")
    4.29 +            "Unread", comment: "Message action (on swipe)")
    4.30          if !cell.haveSeen(message: message) {
    4.31              title = NSLocalizedString(
    4.32 -                "Read", comment: "Read button title in swipe action on EmailListViewController")
    4.33 +                "Read", comment: "Message action (on swipe)")
    4.34          }
    4.35  
    4.36          let isReadAction = createRowAction(cell: cell, image: nil, action: action,
    4.37 @@ -257,7 +257,7 @@
    4.38  
    4.39          return createRowAction(
    4.40              cell: cell, image: UIImage(named: "swipe-more"), action: action,
    4.41 -            title: "\n\nMore".localized)
    4.42 +            title: "\n\n" + NSLocalizedString("More", comment: "Message action (on swipe)"))
    4.43      }
    4.44  
    4.45      // MARK: - Action Sheet
     5.1 --- a/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Mon May 22 18:22:36 2017 +0200
     5.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Mon May 22 18:39:45 2017 +0200
     5.3 @@ -98,25 +98,29 @@
     5.4          }
     5.5  
     5.6          let alertActionReply = UIAlertAction(
     5.7 -        title: "Reply".localized, style: .default) { (action) in
     5.8 -            self.performSegue(withIdentifier: .segueReplyFrom , sender: self)
     5.9 +            title: NSLocalizedString("Reply", comment: "Message actions"),
    5.10 +            style: .default) { (action) in
    5.11 +                self.performSegue(withIdentifier: .segueReplyFrom , sender: self)
    5.12          }
    5.13          alertViewWithoutTitle.addAction(alertActionReply)
    5.14  
    5.15          let alertActionReplyAll = UIAlertAction(
    5.16 -        title: "Reply.All".localized, style: .default) { (action) in
    5.17 -            self.performSegue(withIdentifier: .segueReplyAllForm , sender: self)
    5.18 +            title: NSLocalizedString("Reply All", comment: "Message actions"),
    5.19 +            style: .default) { (action) in
    5.20 +                self.performSegue(withIdentifier: .segueReplyAllForm , sender: self)
    5.21          }
    5.22          alertViewWithoutTitle.addAction(alertActionReplyAll)
    5.23  
    5.24          let alertActionForward = UIAlertAction(
    5.25 -        title: "Forward".localized, style: .default) { (action) in
    5.26 -            self.performSegue(withIdentifier: .segueForward , sender: self)
    5.27 +            title: NSLocalizedString("Forward", comment: "Message actions"),
    5.28 +            style: .default) { (action) in
    5.29 +                self.performSegue(withIdentifier: .segueForward , sender: self)
    5.30          }
    5.31          alertViewWithoutTitle.addAction(alertActionForward)
    5.32  
    5.33          let cancelAction = UIAlertAction(
    5.34 -        title: "Cancel".localized, style: .cancel) { (action) in }
    5.35 +            title: NSLocalizedString("Cancel", comment: "Message actions"),
    5.36 +            style: .cancel) { (action) in }
    5.37          alertViewWithoutTitle.addAction(cancelAction)
    5.38  
    5.39          present(alertViewWithoutTitle, animated: true, completion: nil)
     6.1 --- a/pEpForiOS/UI/EmailDisplay/MessageSenderCell.swift	Mon May 22 18:22:36 2017 +0200
     6.2 +++ b/pEpForiOS/UI/EmailDisplay/MessageSenderCell.swift	Mon May 22 18:39:45 2017 +0200
     6.3 @@ -16,7 +16,8 @@
     6.4          super.updateCell(model: model, message: message, indexPath: indexPath)
     6.5          titleLabel?.text = message.from?.displayString
     6.6          
     6.7 -        let attributed = NSMutableAttributedString(string: "Message.To".localized)
     6.8 +        let attributed = NSMutableAttributedString(
     6.9 +            string: NSLocalizedString("To:", comment: "Compose field title"))
    6.10          let attributes = [
    6.11              NSFontAttributeName: UIFont.systemFont(ofSize: 15.0),
    6.12              NSForegroundColorAttributeName: UIColor.lightGray
     7.1 --- a/pEpForiOS/Util/Extensions/String+Extensions.swift	Mon May 22 18:22:36 2017 +0200
     7.2 +++ b/pEpForiOS/Util/Extensions/String+Extensions.swift	Mon May 22 18:39:45 2017 +0200
     7.3 @@ -14,10 +14,6 @@
     7.4      static let returnKey = "\n"
     7.5      static let comp = "String.Extensions"
     7.6      
     7.7 -    public var localized: String {
     7.8 -        return NSLocalizedString(self, comment: "")
     7.9 -    }
    7.10 -    
    7.11      public var trim: String {
    7.12          return trimmingCharacters(in: .whitespacesAndNewlines)
    7.13      }