-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configForLocale to PaywallData #1227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment but looks good!
*/ | ||
fun configForLocale(requiredLocale: Locale): LocalizedConfiguration? { | ||
return localization[requiredLocale.toString()] | ||
?: localization.takeIf { (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) }?.let { localization -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since paywalls like likely have this or higher minVersion, I think this makes sense 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh actually! I thiknk this is not necessary and it's from previous code that was using languageTag, let me check
return localization[requiredLocale.toString()] | ||
?: localization.takeIf { (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) }?.let { localization -> | ||
localization.entries.firstOrNull { (localeKey, _) -> | ||
Locale(localeKey).isO3Language == requiredLocale.isO3Language |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm is this a typo? Should it be iso3Language
? If not, I wonder if we should use the get
method, since this looks weird...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha I know it looks weird, but it's not a typo. I will use the get
method yes
* | ||
* @return [LocalizedConfiguration] for the given [Locale], if found. | ||
*/ | ||
fun configForLocale(requiredLocale: Locale): LocalizedConfiguration? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏻
I'm guessing tests will come later? 😇
Counterpart of https://github.com/RevenueCat/purchases-ios/blob/paywalls/Sources/Paywalls/PaywallData.swift#L139
Tested passing
Locale("en")
andLocale.US
Tests will come in future PR where I add tests for PaywallData