Hi Maria,
Sorry yes my introDuration variable is of type String
Oh gosh I forgot to give you the extension that gives you the periodTitle here it is :)
extension SubscriptionPeriod {
var durationTitle: String {
switch self.unit {
case .day: return "day"
case .week: return "week"
case .month: return "month"
case .year: return "year"
@unknown default: return "Unknown"
}
}
var periodTitle: String {
let periodString = "\(self.value) \(self.durationTitle)"
let pluralized = self.value > 1 ? periodString + "s" : periodString
return pluralized
}
}
this is brilliant! Thank you for this extension, now i fixed one of my problems with RevCat Gooog luck
Hey Nic,
Glad you were able to get this solved! Unfortunately we dont have a method that returns a localized string for the periodTitle but I will go ahead and mark that as a feature request!
For future reference, you can see what localized strings we have by searching for `localized` in our SDK reference sheets listed here: https://www.revenuecat.com/docs/reference
Hi! I have the same issue with localization. Wrote about It to support, waiting for answer. moreover, for some reason periodTitle property is not available for me (don’t know, may be because of xCode version, or RevCat version. i get this error: “Value of type 'SubscriptionPeriod' has no member 'periodTitle'” but i found two other properties of subsctiptionPeriod - value (number) and unit (days, weeks, months etc) and the same - I can’t localize this units because they are of type SubscriptionPeriod.Unit, can’t turn it into String… will write back, if guys from support give me a solution.
Hi Maria, thanks for the reply. I actually just figured it out. I am not sure why periodTitle isn't available to you but here is how I worked out the localisation.
Example for a string in a Text view with German localisation and with string interpolation for your trial length property:
Text(“Start \(NSLocalizedString(introDuration, comment: "intro length")) free trial”)
then in your Localizable file:
“Start %@ free trial" = "Probieren Sie %@ kostenlos";
I hope that helps :)
Hi Nic!
Happy to hear that you’ve found the solution, that works for you.. But I still can’t even access this periodTitle property btw, your introDuration that you localize here - (“Start \(NSLocalizedString(introDuration, comment: "intro length")) free trial”) is of the String type?…
Hi Michael oh cool thanks so much
Hey @Michael Fogel , any update on this property, feels like a very important value, don’t all paywalls include this string?