Commit 3f399f7c authored by Davide De Rosa's avatar Davide De Rosa
Browse files

Use parametric code length in strings

In case it changes.
parent b884a8e0
......@@ -30,11 +30,11 @@
"purchase.error.validation" = "You must enter an email address.";
"redeem.title" = "Redeem gift card";
"redeem.subtitle" = "Type in your email address and the 16 digit PIN from your gift card or trial card below.";
"redeem.subtitle" = "Type in your email address and the %lu digit PIN from your gift card or trial card below.";
"redeem.email.placeholder" = "Email address";
"redeem.submit" = "SUBMIT";
"redeem.error.title" = "Redeem";
"redeem.error.code" = "Code must be 16 numeric digits.";
"redeem.error.code" = "Code must be %lu numeric digits.";
"plan.monthly.title" = "Monthly";
"plan.yearly.title" = "Yearly";
......
......@@ -18,7 +18,7 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
private static let codePlaceholder = "1234-5678-9012-3456"
private static let maxCodeLength = 16
private static let codeLength = 16
@IBOutlet private weak var scrollView: UIScrollView!
......@@ -70,7 +70,7 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
viewFooter.isHidden = omitsSiblingLink
labelTitle.text = L10n.Welcome.Redeem.title
labelSubtitle.text = L10n.Welcome.Redeem.subtitle
labelSubtitle.text = L10n.Welcome.Redeem.subtitle(RedeemViewController.codeLength)
textEmail.placeholder = L10n.Welcome.Redeem.Email.placeholder
textCode.placeholder = RedeemViewController.codePlaceholder
textAgreement.attributedText = Theme.current.agreementText(
......@@ -121,7 +121,7 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
guard let code = redeemCode, Validator.validate(giftCode: code) else {
let alert = Macros.alert(
L10n.Welcome.Redeem.Error.title,
L10n.Welcome.Redeem.Error.code
L10n.Welcome.Redeem.Error.code(RedeemViewController.codeLength)
)
alert.addCancelAction(L10n.Ui.Global.ok)
present(alert, animated: true, completion: nil)
......@@ -229,7 +229,7 @@ extension RedeemViewController: UITextFieldDelegate {
let cursorLocation = textField.position(from: textField.beginningOfDocument, offset: range.location + string.count)
let newCode = strippedRedeemCode(newText)
guard newCode.count <= RedeemViewController.maxCodeLength else {
guard newCode.count <= RedeemViewController.codeLength else {
return false
}
redeemCode = newCode
......
......@@ -140,8 +140,10 @@ enum L10n {
enum Redeem {
/// SUBMIT
static let submit = L10n.tr("Welcome", "redeem.submit")
/// Type in your email address and the 16 digit PIN from your gift card or trial card below.
static let subtitle = L10n.tr("Welcome", "redeem.subtitle")
/// Type in your email address and the %lu digit PIN from your gift card or trial card below.
static func subtitle(_ p1: Int) -> String {
return L10n.tr("Welcome", "redeem.subtitle", p1)
}
/// Redeem gift card
static let title = L10n.tr("Welcome", "redeem.title")
......@@ -151,8 +153,10 @@ enum L10n {
}
enum Error {
/// Code must be 16 numeric digits.
static let code = L10n.tr("Welcome", "redeem.error.code")
/// Code must be %lu numeric digits.
static func code(_ p1: Int) -> String {
return L10n.tr("Welcome", "redeem.error.code", p1)
}
/// Redeem
static let title = L10n.tr("Welcome", "redeem.error.title")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment