Skip to content

Conversation

joshdholtz
Copy link
Member

@joshdholtz joshdholtz commented Mar 12, 2025

Motivation

Fixes #4829

Description

Improves LocaleFinder by falling back to different variations of language code, script, and region.

Previously, it would use the locale's identifier to find the matching locale in our localizations. However, this didn't work well for language codes like zh_CN (shorthand for zh_Hans_CK or zh_HK (shorthand for zh_Hant_HK.

With this change, LocaleFinder will now use Locale to find the script (ex: Hans or Hant) and region (ex: CN or HK). It will go in this order:

  1. Max identifier (code, region, script)
  2. Code and region
  3. Code

@joshdholtz joshdholtz requested review from a team March 12, 2025 02:27
@joshdholtz joshdholtz changed the title Map other chinese languages to simplified or traditional Map other chinese languages to simplified or traditional (if not explicitly supported) Mar 12, 2025
@joshdholtz joshdholtz changed the title Map other chinese languages to simplified or traditional (if not explicitly supported) Fallback to using language code and script for unknown Locale (ex: zh_CN will look for zh_Hans) Mar 12, 2025
@joshdholtz joshdholtz changed the title Fallback to using language code and script for unknown Locale (ex: zh_CN will look for zh_Hans) Fallback to using variations of language code, script, and region for unknown Locale (ex: zh_CN will look for zh_Hans) Mar 12, 2025
@joshdholtz joshdholtz force-pushed the paywalls-v2/handle-other-chinese-language-codes branch from b6bc329 to 5176365 Compare March 12, 2025 03:49
Copy link
Member

@ajpallares ajpallares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Only one little mistake I think

@joshdholtz joshdholtz force-pushed the paywalls-v2/handle-other-chinese-language-codes branch from c43e55b to 1227a21 Compare March 12, 2025 11:59
@JayShortway JayShortway merged commit a02fc3f into main Mar 12, 2025
10 checks passed
@JayShortway JayShortway deleted the paywalls-v2/handle-other-chinese-language-codes branch March 12, 2025 12:34
@JayShortway
Copy link
Member

Merged upon @joshdholtz's request 🤷

@tonidero
Copy link
Contributor

It looks like there are some tests failing for iOS 15 that seem related to these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paywall localization error for Simplified Chinese
4 participants