-
Notifications
You must be signed in to change notification settings - Fork 319
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
Paywalls
: improve PaywallData.config(for:)
disambiguation
#3605
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes an issue with `PaywallData` picking the wrong `Locale` when the configuration has multiple translations sharing the same language code. The fix replaces comparing `Language.languageCode` with the smarter `Language.isEquivalent(to:)`. ### Other changes: - Removed the duplicate `zh_TW` since it was the same as `zh_Hant`. This is covered in tests too. - Added configuration to be able to test this on `PaywallsTester` - Renamed `zh_HK` to `zh-Hant` for consistency with `Hans`
NachoSoto
commented
Jan 26, 2024
@@ -524,7 +524,7 @@ private extension Locale { | |||
|
|||
func sharesLanguageCode(with other: Locale) -> Bool { | |||
if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) { | |||
return self.language.languageCode == other.language.languageCode | |||
return self.language.isEquivalent(to: other.language) |
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.
This is the core of the fix.
NachoSoto
force-pushed
the
paywallsls-chinese-localization
branch
from
January 26, 2024 20:02
b643af8
to
54f70c5
Compare
NachoSoto
added a commit
to RevenueCat/purchases-android
that referenced
this pull request
Jan 26, 2024
iOS equivalent: RevenueCat/purchases-ios#3605 See also https://medium.com/fabiohub/chinese-locale-in-android-part-2-d1cfe87b3fb2: > In order to support zh-rHK, zh-rHK_#Hant and zh-rHK_#Hans to fall back correctly on both pre & post Android 7.0 devices, you need these resources: - `zh-rHK` (Traditional Chinese) - `zh-rTW` (Traditional Chinese) - `zh` (Simplified Chinese)
NachoSoto
added a commit
to RevenueCat/purchases-android
that referenced
this pull request
Jan 26, 2024
iOS equivalent: RevenueCat/purchases-ios#3605 See also https://medium.com/fabiohub/chinese-locale-in-android-part-2-d1cfe87b3fb2: > In order to support zh-rHK, zh-rHK_#Hant and zh-rHK_#Hans to fall back correctly on both pre & post Android 7.0 devices, you need these resources: - `zh-rHK` (Traditional Chinese) - `zh-rTW` (Traditional Chinese) - `zh` (Simplified Chinese)
NachoSoto
added a commit
to RevenueCat/purchases-android
that referenced
this pull request
Jan 26, 2024
iOS equivalent: RevenueCat/purchases-ios#3605 See also https://medium.com/fabiohub/chinese-locale-in-android-part-2-d1cfe87b3fb2: > In order to support zh-rHK, zh-rHK_#Hant and zh-rHK_#Hans to fall back correctly on both pre & post Android 7.0 devices, you need these resources: - `zh-rHK` (Traditional Chinese) - `zh-rTW` (Traditional Chinese) - `zh` (Simplified Chinese)
tonidero
approved these changes
Jan 29, 2024
NachoSoto
pushed a commit
that referenced
this pull request
Jan 30, 2024
**This is an automatic release.** ### RevenueCatUI * `Paywalls`: fix template 5 scrolling on iOS 15 (#3608) via NachoSoto (@NachoSoto) * `Paywalls`: improve `PaywallData.config(for:)` disambiguation (#3605) via NachoSoto (@NachoSoto) ### Dependency Updates * Bump cocoapods from 1.14.3 to 1.15.0 (#3607) via dependabot[bot] (@dependabot[bot]) * Bump fastlane-plugin-revenuecat_internal from `e6ba247` to `9c82c7a` (#3606) via dependabot[bot] (@dependabot[bot]) ### Other Changes * `Integration Tests`: disable failure expectation on `iOS 17.4` (#3604) via NachoSoto (@NachoSoto)
NachoSoto
added a commit
that referenced
this pull request
Feb 5, 2024
This was a regression introduced by #3605. ### Example: Consider a paywall configuration with these locales: `en_US`, `de_DE`. Running on a device with locale `en_IN` for example. Before #3605, `PaywallData.localizedConfiguration` would have returned the `en_US` localization. However, that change made it so that it could no longer find a matching localization with a different region.' This fix improves the locale lookup so that if it doesn't find a matching localization with both language AND region, it then tries to look it up with only the language, before falling back to the default localization.
NachoSoto
added a commit
that referenced
this pull request
Feb 5, 2024
This was a regression introduced by #3605. ### Example: Consider a paywall configuration with these locales: `en_US`, `de_DE`. Running on a device with locale `en_IN` for example. Before #3605, `PaywallData.localizedConfiguration` would have returned the `en_US` localization. However, that change made it so that it could no longer find a matching localization with a different region. This fix improves the locale lookup so that if it doesn't find a matching localization with both language AND region, it then tries to look it up with only the language, before falling back to the default localization.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue with
PaywallData
picking the wrongLocale
when the configuration has multiple translations sharing the same language code.The fix replaces comparing
Language.languageCode
with the smarterLanguage.isEquivalent(to:)
.Other changes:
zh_TW
since it was the same aszh_Hant
(we don't have that specific language in the dashboard either)PaywallsTester
zh_HK
tozh_Hant
for consistency withHans