Add email template to offer as translator

This commit is contained in:
Davide De Rosa 2019-04-07 16:16:59 +02:00
parent 64e00fdadd
commit d13f813236
6 changed files with 78 additions and 11 deletions

View File

@ -57,7 +57,7 @@ class IssueReporter: NSObject {
func present(in viewController: UIViewController, withAttachments attachments: Attachments) {
guard MFMailComposeViewController.canSendMail() else {
let alert = Macros.alert(L10n.IssueReporter.title, L10n.IssueReporter.Alerts.EmailNotConfigured.message)
let alert = Macros.alert(L10n.IssueReporter.title, L10n.Global.emailNotConfigured)
alert.addCancelAction(L10n.Global.ok)
viewController.present(alert, animated: true, completion: nil)
return

View File

@ -24,6 +24,7 @@
//
import UIKit
import MessageUI
import Passepartout_Core
// XXX: convoluted due to the separation of provider/host profiles
@ -61,7 +62,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
model.set([.siriShortcuts], in: .siri)
}
model.setHeader(L10n.Organizer.Sections.Support.header, for: .support)
model.set([.donate, .patreon], in: .support)
model.set([.donate, .patreon, .translate], in: .support)
model.set([.openAbout], in: .about)
model.set([.uninstall], in: .destruction)
if AppConstants.Flags.isBeta {
@ -199,6 +200,23 @@ class OrganizerViewController: UITableViewController, TableModelHost {
UIApplication.shared.open(AppConstants.URLs.patreon, options: [:], completionHandler: nil)
}
private func offerTranslation() {
guard MFMailComposeViewController.canSendMail() else {
let alert = Macros.alert(L10n.IssueReporter.title, L10n.Global.emailNotConfigured)
alert.addCancelAction(L10n.Global.ok)
present(alert, animated: true, completion: nil)
return
}
let vc = MFMailComposeViewController()
vc.setToRecipients([AppConstants.Translations.recipient])
vc.setSubject(L10n.Translations.Email.subject(GroupConstants.App.name))
vc.setMessageBody(L10n.Translations.Email.body(L10n.Translations.Email.description), isHTML: false)
vc.mailComposeDelegate = self
vc.apply(Theme.current)
present(vc, animated: true, completion: nil)
}
private func about() {
perform(segue: StoryboardSegue.Organizer.aboutSegueIdentifier, sender: nil)
}
@ -315,6 +333,8 @@ extension OrganizerViewController {
case donate
case patreon
case translate
case openAbout
@ -401,6 +421,11 @@ extension OrganizerViewController {
cell.leftText = L10n.Organizer.Cells.Patreon.caption
return cell
case .translate:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.Translate.caption
return cell
case .openAbout:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.About.caption(GroupConstants.App.name)
@ -445,6 +470,9 @@ extension OrganizerViewController {
case .patreon:
visitPatreon()
case .translate:
offerTranslation()
case .openAbout:
about()
@ -588,3 +616,9 @@ extension OrganizerViewController: ConnectionServiceDelegate {
}
}
}
extension OrganizerViewController: MFMailComposeViewControllerDelegate {
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
dismiss(animated: true, completion: nil)
}
}

View File

@ -29,6 +29,7 @@
"global.close" = "Close";
"global.host.title_input.message" = "Acceptable characters are alphanumerics plus dash \"-\", underscore \"_\" and dot \".\".";
"global.host.title_input.placeholder" = "My profile";
"global.email_not_configured" = "No e-mail account is configured.";
"reddit.title" = "Reddit";
"reddit.message" = "Did you know that Passepartout has a subreddit? Subscribe for updates or to discuss issues, features, new platforms or whatever you like.\n\nIt's also a great way to show you care about this project.";
@ -49,6 +50,7 @@
"organizer.cells.siri_shortcuts.caption" = "Manage shortcuts";
"organizer.cells.donate.caption" = "Make a donation";
"organizer.cells.patreon.caption" = "Support me on Patreon";
"organizer.cells.translate.caption" = "Offer to translate";
"organizer.cells.about.caption" = "About %@";
"organizer.cells.uninstall.caption" = "Remove VPN configuration";
"organizer.alerts.exhausted_providers.message" = "You have created profiles for any available provider.";
@ -212,11 +214,15 @@
"issue_reporter.title" = "Report issue";
"issue_reporter.message" = "The debug log of your latest connections is crucial to resolve your connectivity issues and is completely anonymous.\n\nThe .ovpn configuration file, if any, is attached stripped of any sensitive data.\n\nPlease double check the e-mail attachments if unsure.";
"issue_reporter.buttons.accept" = "I understand";
"issue_reporter.alerts.email_not_configured.message" = "No e-mail account is configured.";
"issue_reporter.email.subject" = "%@ - Report issue";
"issue_reporter.email.body" = "Hi,\n\n%@\n\n%@\n\nRegards";
"issue_reporter.email.description" = "description of the issue:";
"translations.title" = "Translations";
"translations.email.subject" = "%@ - Translations";
"translations.email.body" = "Hi,\n\n%@\n\nRegards";
"translations.email.description" = "I offer to translate to:";
"shortcuts.add.title" = "Add shortcut";
"shortcuts.add.sections.vpn.header" = "VPN";
"shortcuts.add.sections.wifi.header" = "Wi-Fi";

View File

@ -29,6 +29,7 @@
"global.close" = "Chiudi";
"global.host.title_input.message" = "I caratteri ammessi sono gli alfanumerici e il trattino breve \"-\", il trattino basso \"_\" ed il punto \".\".";
"global.host.title_input.placeholder" = "Il mio profilo";
"global.email_not_configured" = "Nessun account e-mail configurato.";
"reddit.title" = "Reddit";
"reddit.message" = "Sapevi che Passepartout ha un subreddit? Iscriviti per aggiornamenti o per discutere problemi, aggiunte, nuove piattaforme o qualunque cosa tu voglia.\n\nÈ anche un ottimo modo per dimostrare che hai a cuore questo progetto.";
@ -49,6 +50,7 @@
"organizer.cells.siri_shortcuts.caption" = "Gestisci comandi rapidi";
"organizer.cells.donate.caption" = "Fai una donazione";
"organizer.cells.patreon.caption" = "Supportami su Patreon";
"organizer.cells.translate.caption" = "Proponi una traduzione";
"organizer.cells.about.caption" = "Informazioni su %@";
"organizer.cells.uninstall.caption" = "Rimuovi configurazione VPN";
"organizer.alerts.exhausted_providers.message" = "Hai creato profili per tutti i provider disponibili.";
@ -212,11 +214,15 @@
"issue_reporter.title" = "Segnala problema";
"issue_reporter.message" = "Il debug log delle tue ultime connessioni è cruciale per risolvere i tuoi problemi di connettività ed è completamente anonimo.\n\nIl file di configurazione .ovpn, se presente, è allegato privato di ogni dato sensibile.\n\nPer favore controlla gli allegati dell'e-mail se non sei sicuro/a.";
"issue_reporter.buttons.accept" = "Ho capito";
"issue_reporter.alerts.email_not_configured.message" = "Nessun account e-mail configurato.";
"issue_reporter.email.subject" = "%@ - Segnala problema";
"issue_reporter.email.body" = "Ciao,\n\n%@\n\n%@\n\nGrazie";
"issue_reporter.email.description" = "descrizione del problema:";
"translations.title" = "Traduzioni";
"translations.email.subject" = "%@ - Traduzioni";
"translations.email.body" = "Ciao,\n\n%@\n\nGrazie";
"translations.email.description" = "Mi offro di tradurre alla lingua:";
"shortcuts.add.title" = "Aggiungi comando rapido";
"shortcuts.add.sections.vpn.header" = "VPN";
"shortcuts.add.sections.wifi.header" = "Wi-Fi";

View File

@ -130,7 +130,11 @@ public class AppConstants {
public static let configuration = "text/plain"
}
}
public class Translations {
public static let recipient = "translate@\(Domain.name)"
}
public class URLs {
public static let website = URL(string: "https://\(Domain.name)")!

View File

@ -346,6 +346,8 @@ public enum L10n {
public static let cancel = L10n.tr("Localizable", "global.cancel")
/// Close
public static let close = L10n.tr("Localizable", "global.close")
/// No e-mail account is configured.
public static let emailNotConfigured = L10n.tr("Localizable", "global.email_not_configured")
/// Next
public static let next = L10n.tr("Localizable", "global.next")
/// OK
@ -370,12 +372,6 @@ public enum L10n {
public static let message = L10n.tr("Localizable", "issue_reporter.message")
/// Report issue
public static let title = L10n.tr("Localizable", "issue_reporter.title")
public enum Alerts {
public enum EmailNotConfigured {
/// No e-mail account is configured.
public static let message = L10n.tr("Localizable", "issue_reporter.alerts.email_not_configured.message")
}
}
public enum Buttons {
/// I understand
public static let accept = L10n.tr("Localizable", "issue_reporter.buttons.accept")
@ -449,6 +445,10 @@ public enum L10n {
/// Manage shortcuts
public static let caption = L10n.tr("Localizable", "organizer.cells.siri_shortcuts.caption")
}
public enum Translate {
/// Offer to translate
public static let caption = L10n.tr("Localizable", "organizer.cells.translate.caption")
}
public enum Uninstall {
/// Remove VPN configuration
public static let caption = L10n.tr("Localizable", "organizer.cells.uninstall.caption")
@ -870,6 +870,23 @@ public enum L10n {
}
}
public enum Translations {
/// Translations
public static let title = L10n.tr("Localizable", "translations.title")
public enum Email {
/// Hi,\n\n%@\n\nRegards
public static func body(_ p1: String) -> String {
return L10n.tr("Localizable", "translations.email.body", p1)
}
/// I offer to translate to:
public static let description = L10n.tr("Localizable", "translations.email.description")
/// %@ - Translations
public static func subject(_ p1: String) -> String {
return L10n.tr("Localizable", "translations.email.subject", p1)
}
}
}
public enum Version {
/// Version
public static let title = L10n.tr("Localizable", "version.title")