Skip to content

Bugfix FXIOS-15303 [Translations Phase 2] Translation button doesn't appear when the primary device language isn't supported but a fallback language is#32861

Merged
razvanlitianu merged 4 commits into
mainfrom
rlitianu/translations-fix-button-visibility
Apr 8, 2026
Merged

Bugfix FXIOS-15303 [Translations Phase 2] Translation button doesn't appear when the primary device language isn't supported but a fallback language is#32861
razvanlitianu merged 4 commits into
mainfrom
rlitianu/translations-fix-button-visibility

Conversation

@razvanlitianu
Copy link
Copy Markdown
Collaborator

@razvanlitianu razvanlitianu commented Apr 1, 2026

📜 Tickets

Jira ticket
Github issue

💡 Description

When the translationLanguagePicker flag is ON, the translation button now checks all of the user's preferred languages against the current page, not just the primary device language. The button appears as soon as any preferred language has an available translation model for the page.

🎥 Demos

Before After
Demo

📝 Checklist

  • I filled in the ticket numbers and a description of my work
  • I updated the PR name to follow our PR naming guidelines
  • I ensured unit tests pass and wrote tests for new code
  • If working on UI, I checked and implemented accessibility (Dynamic Text and VoiceOver)
  • If adding telemetry, I read the data stewardship requirements and will request a data review
  • If adding or modifying strings, I read the guidelines and will request a string review from l10n
  • If needed, I updated documentation and added comments to complex code

@razvanlitianu razvanlitianu marked this pull request as ready for review April 1, 2026 13:52
@razvanlitianu razvanlitianu requested a review from a team as a code owner April 1, 2026 13:52
@razvanlitianu razvanlitianu requested review from FilippoZazzeroni, cyndichin and yoanarios and removed request for yoanarios April 1, 2026 13:52
@mobiletest-ci-bot
Copy link
Copy Markdown

mobiletest-ci-bot commented Apr 1, 2026

Messages
📖 Project coverage: 41.14%

💪 Quality guardian

4 tests files modified. You're a champion of test coverage! 🚀

🥇 Perfect PR size

Smaller PRs are easier to review. Thanks for making life easy for reviewers! ✨

✅ New file code coverage

No new file detected so code coverage gate wasn't ran.

Client.app: Coverage: 39.45

File Coverage
TranslationsMiddleware.swift 96.55%
TranslationsService.swift 38.0% ⚠️

Generated by 🚫 Danger Swift against f3fd3b7

…but a preferred fallback does

When the translationLanguagePicker flag is enabled, shouldOfferTranslation
now checks each preferred language in order and returns true on the first
available model pair, instead of only checking the primary device language.
The middleware builds the language list from the flag: a single device
language when the flag is OFF (no behavior change), or the full ordered
preferred list from PreferredTranslationLanguagesManager when ON.
@razvanlitianu razvanlitianu force-pushed the rlitianu/translations-fix-button-visibility branch from 821b588 to 7387b22 Compare April 7, 2026 17:51
/// When OFF, returns only the primary device language (preserving legacy behavior).
private func targetLanguagesForEligibilityCheck() async -> [String] {
if featureFlags.isFeatureEnabled(.translationLanguagePicker, checking: .buildOnly) {
let manager = PreferredTranslationLanguagesManager(prefs: profile.prefs)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should we inject this to in order to east tests as well ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated!

let supported = await translationsService.fetchSupportedTargetLanguages()
return manager.preferredLanguages(supportedTargetLanguages: supported)
}
return [Locale.current.languageCode].compactMap { $0 }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should use the SystemLocaleProvider here. we can inject it in the middleware

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point, updated

@razvanlitianu razvanlitianu merged commit fb8581f into main Apr 8, 2026
9 checks passed
@razvanlitianu razvanlitianu deleted the rlitianu/translations-fix-button-visibility branch April 8, 2026 13:10
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

🚀 PR merged to main, targeting version: 150.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants