← Back to Pull requests

feat(framework): add language preference setting #3680

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Sep 30, 2026 15:24 UTC
Author

Summary

Adds a user preference for selecting the interface language. The selected language is persisted per user, applied immediately through the existing i18n setup, and can be reset to browser-detected language. Language options display native names alongside English names and are sorted by English name for consistent discoverability.

Type of Change

  • Bug fix

  • Enhancement

  • Tests

  • Documentation

  • Other (please specify)
  • Risk Analysis - REQUIRED

  • High — Broad platform impact (e.g., SWR config, shared framework components, authentication, routing, API wrappers, build/bundler config). Changes affect multiple workspaces or could cause widespread regressions.

  • Medium — Scoped but cross-cutting (e.g., shared utility functions, changes to multiple pages within one workspace, component library updates, test infrastructure). Limited blast radius but touches common code paths.

  • Low — Narrowly scoped (e.g., single page fix, styling tweak, documentation, test-only changes, copy/string updates). Minimal risk of unintended side effects.
  • Dependencies

    None.

    Testing

    Ephemeral E2E Tests

    Once PR is ready and preliminary checks pass, trigger tests by posting a comment /run-playwright on this PR.

    Tests run against a fresh AAP instance (version based on branch).

    External Server E2E Runs

    Not applicable.

    Manual Testing

    Page Settings Language Manual Verification

    ##### 1. Default language follows browser

    1. Set the browser preferred language to English.
    2. Open the application in a fresh/incognito window.
    3. Navigate to User preferences → Language.
    4. Confirm Follow browser is selected.
    5. Confirm the UI is in English.
    6. In DevTools:
    - localStorage.getItem('lang') should be null.
    - The lang cookie should be absent or empty.

    ##### 2. Language options order and divider

    1. Open User preferences → Language.
    2. Open the language dropdown.
    3. Confirm Follow browser is the first option.
    4. Confirm a divider appears immediately below it.
    5. Confirm all explicit languages appear below the divider.
    6. Confirm the explicit languages retain their configured order:
    - Chinese
    - Dutch
    - English
    - French
    - Japanese
    - Korean
    - Spanish

    ##### 3. Select an explicit language

    1. Select French.
    2. Save the preferences.
    3. Confirm the UI text changes to French.
    4. Confirm the document language in DevTools:

       document.documentElement.lang
       

    It should be fr.
    5. Confirm the language cache:

       localStorage.getItem('lang')
       

    It should be fr.
    6. Confirm the selected preference is persisted in:

       JSON.parse(localStorage.getItem('user-preferences')).language
       

    It should be fr.

    ##### 4. Explicit language persists after reload

    1. With French selected, reload the page.
    2. Confirm the UI remains in French.
    3. Reopen User preferences.
    4. Confirm the language selection is still French.
    5. Confirm document.documentElement.lang remains fr.

    ##### 5. Return to browser language

    1. Set the browser preferred language to English.
    2. In the application, select Follow browser.
    3. Save the preferences.
    4. Confirm the UI changes from French back to English without requiring a reload.
    5. Confirm:

       document.documentElement.lang
       

    is en.
    6. Confirm the language cache was cleared:

       localStorage.getItem('lang')
       

    should be null.
    7. Confirm the language cookie is cleared:

       document.cookie
       

    should not contain a lang=... entry.

    ##### 6. Browser preference is restored after reload

    1. After selecting Follow browser, reload the page.
    2. Confirm the UI remains English.
    3. Confirm Follow browser remains selected.
    4. Confirm no stale French language cache or cookie is recreated.

    ##### 7. Non-English browser preference

    1. Change the browser preferred language to Spanish or Japanese.
    2. Select Follow browser in the application.
    3. Confirm the UI switches to the browser language.
    4. Confirm document.documentElement.lang matches the resolved language.
    5. Reload the page and confirm the browser language remains active.

    ##### 8. Browser language with regional locale

    1. Set the browser language to a regional locale such as en-US or fr-CA.
    2. Select Follow browser.
    3. Confirm the application resolves it to the supported base language (en or fr) rather than failing to load translations.
    4. Confirm the UI and document.documentElement.lang use the resolved supported language.

    ##### 9. Query-string override regression check

    1. Open the application with a language query parameter, for example:

       ?lang=fr
       

    2. Confirm French is loaded because the query string has higher detection priority.
    3. Select Follow browser and save.
    4. Confirm the query-string override behavior remains consistent with the application's intended precedence.

    ##### 10. Invalid or stale preference recovery

    1. In DevTools, set an invalid preference:

       localStorage.setItem(
         'user-preferences',
         JSON.stringify({ language: 'invalid' })
       );
       localStorage.setItem('lang', 'fr');
       

    2. Reload the page.
    3. Confirm the application treats the Page Settings preference as Follow browser.
    4. Confirm the stale lang cache is cleared.
    5. Confirm the UI follows the browser language.

    Screenshots

    <img width="1263" height="372" alt="image" src="https://github.com/user-attachments/assets/faeab6a1-76c9-4f7c-8b67-e686c617926c" />

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: h-kataria Review duration: 21348m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3680"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%