Skip to content

Conversation

xeenon
Copy link
Contributor

@xeenon xeenon commented Jan 15, 2025

f1892e2

REGRESSION: Web Extensions do not pick zh locale when zh-Hant is preferred.
https://webkit.org/b/286024
rdar://142602243

Reviewed by Brian Weinstein.

On Apple platforms, the best match search uses Foundation, which skips "zh" when the preferred locale is "zh-Hant",
likely assuming "zh" refers to simplified Chinese. However, web extensions expect the base language to be selected
if it is supported, regardless of specific variants.

Fix this by adding a special-case for base language fallback before using the default locale.

* Source/WebKit/UIProcess/Extensions/WebExtension.cpp:
(WebKit::WebExtension::bestMatchLocale): Added base language fallback.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPILocalization.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPILocalization, i18nChineseTraditionalFallback)): Added.
(TestWebKitAPI::TEST(WKWebExtensionAPILocalization, i18nChineseSimplifiedFallback)): Added.

Canonical link: https://commits.webkit.org/288974@main

f6c435f

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac 🛠 wpe 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2 🧪 win-tests
✅ 🧪 webkitperl 🧪 ios-wk2 ✅ 🧪 api-mac 🧪 api-wpe
🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 🛠 wpe-cairo
🧪 api-ios ✅ 🧪 mac-wk2 🛠 gtk
✅ 🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress 🧪 api-gtk
✅ 🧪 vision-wk2 🧪 mac-intel-wk2 🛠 playstation
✅ 🛠 🧪 unsafe-merge ✅ 🛠 tv 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@xeenon xeenon requested a review from b-weinstein as a code owner January 15, 2025 21:59
@xeenon xeenon self-assigned this Jan 15, 2025
@xeenon xeenon added the WebKit Extensions Bugs related to extension support. label Jan 15, 2025
@xeenon xeenon added the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Jan 15, 2025
@xeenon xeenon added unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing and removed safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks labels Jan 15, 2025
…erred.

https://webkit.org/b/286024
rdar://142602243

Reviewed by Brian Weinstein.

On Apple platforms, the best match search uses Foundation, which skips "zh" when the preferred locale is "zh-Hant",
likely assuming "zh" refers to simplified Chinese. However, web extensions expect the base language to be selected
if it is supported, regardless of specific variants.

Fix this by adding a special-case for base language fallback before using the default locale.

* Source/WebKit/UIProcess/Extensions/WebExtension.cpp:
(WebKit::WebExtension::bestMatchLocale): Added base language fallback.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPILocalization.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPILocalization, i18nChineseTraditionalFallback)): Added.
(TestWebKitAPI::TEST(WKWebExtensionAPILocalization, i18nChineseSimplifiedFallback)): Added.

Canonical link: https://commits.webkit.org/288974@main
@webkit-commit-queue
Copy link
Collaborator

Committed 288974@main (f1892e2): https://commits.webkit.org/288974@main

Reviewed commits have been landed. Closing PR #39097 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit f1892e2 into WebKit:main Jan 15, 2025
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jan 15, 2025
@xeenon xeenon deleted the bug/286024 branch January 16, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebKit Extensions Bugs related to extension support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants