Skip to content

Translate: remember recent languages and default to browser language - #1619

Open
cdrini wants to merge 2 commits into
internetarchive:masterfrom
cdrini:translate-recent-languages
Open

cdrini wants to merge 2 commits into
internetarchive:masterfrom
cdrini:translate-recent-languages

Conversation

@cdrini

@cdrini cdrini commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Description

  • The translate "To" language list now shows recently used languages (up to 3, saved in localStorage) in a "Recent" group at the top.
  • The default "To" language is now the most recently used one, else the browser's language (if there's a model for it), else English.

Closes #1459

Technical

  • Recent languages also stay in the full list; if localStorage is unavailable or invalid the list just shows without the group.
  • Browser languages are matched exactly first, then by base language (e.g. fr-CA → fr, zh-CN → zh-Hans).

Testing

On the IA demo with the translate experiment enabled:

  1. Choose a couple of "To" languages, reload: they show under "Recent" and the last one is preselected.
  2. With no history (clear localStorage), set the browser language to e.g. French: "To" defaults to français. With an unsupported language (e.g. Icelandic) it defaults to English.

Screenshots/Videos

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.03%. Comparing base (042a0e4) to head (7911500).

Files with missing lines Patch % Lines
src/plugins/translate/plugin.translate.js 91.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1619      +/-   ##
==========================================
+ Coverage   64.65%   65.03%   +0.38%     
==========================================
  Files          69       69              
  Lines        6309     6338      +29     
  Branches     1400     1409       +9     
==========================================
+ Hits         4079     4122      +43     
+ Misses       2190     2176      -14     
  Partials       40       40              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Detect browser language and use for Translate plugin "To" language

2 participants