Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add page_lang parameter to st.set_page_config#16024

Open
atharv-sys32 wants to merge 3 commits into
streamlit:developstreamlit/streamlit:developfrom
atharv-sys32:feat/page-lang-configatharv-sys32/streamlit:feat/page-lang-configCopy head branch name to clipboard
Open

Add page_lang parameter to st.set_page_config#16024
atharv-sys32 wants to merge 3 commits into
streamlit:developstreamlit/streamlit:developfrom
atharv-sys32:feat/page-lang-configatharv-sys32/streamlit:feat/page-lang-configCopy head branch name to clipboard

Conversation

@atharv-sys32

@atharv-sys32 atharv-sys32 commented Jul 15, 2026

Copy link
Copy Markdown

Describe your changes

Adds a page_lang parameter to st.set_page_config() that sets the lang attribute on the root <html> element. Previously this was hardcoded to "en", causing unwanted browser translation prompts for non-English apps and incorrect screen reader pronunciation.

GitHub Issue Link (if applicable)

Fixes #15726

Testing Plan

Changes follow the exact same pattern as the existing title / favicon handling. Proto field added, Python backend wires it, frontend sets it.


Note

Low Risk
Small, additive API and DOM attribute change with no auth or data-path impact; behavior matches existing page config patterns.

Overview
Adds page_lang to st.set_page_config() so apps can set the root <html> lang attribute instead of relying on the static en in the shell HTML.

The value flows through a new PageConfig.lang proto field; Python forwards non-empty tags on page_config_changed, and the frontend updates document.documentElement.lang when pageConfigChanged includes lang. Docs describe BCP 47 tags and the same additive/inherit behavior as other page config options (default en when never set).

Reviewed by Cursor Bugbot for commit 0e6b338. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a page_lang parameter to st.set_page_config that sets the
lang attribute on the root <html> element via PageConfig proto.
Previously the value was hardcoded to "en", which caused unwanted
browser translation prompts for non-English apps.

Changes:
- PageConfig.proto: add string lang = 7 field
- page_config.py: add page_lang parameter, wire to protobuf
- App.tsx: set document.documentElement.lang when config arrives

Fixes streamlit#15726
Copilot AI review requested due to automatic review settings July 15, 2026 19:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@snyk-io

snyk-io Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Streamlit! 🎈

Please make sure you have read our Contributing Guide. You can find additional information about Streamlit development in the wiki.

The review process:

  1. Initial triage: A maintainer will apply labels, approve CI to run, and trigger AI-assisted reviews. Your PR may be flagged with status:needs-product-approval if the feature requires product team sign-off.

  2. Code review: A core maintainer will start reviewing your PR once:

    • It is marked as 'ready for review', not 'draft'
    • It has status:product-approved (or doesn't need it)
    • All CI checks pass
    • All AI review comments are addressed

We're receiving many contributions and have limited review bandwidth — please expect some delay. We appreciate your patience! 🙏

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds configurable page-language metadata to Streamlit apps. The main changes are:

  • A page_lang parameter for st.set_page_config().
  • A protobuf field carrying the language to the frontend.
  • An update to the root HTML lang attribute when a language is provided.

Confidence Score: 5/5

No additional blocking issue was found in the updated code.

  • The empty protobuf default no longer clears the root HTML language.
  • No separate production failure requiring an additional change was identified.

Important Files Changed

Filename Overview
lib/streamlit/commands/page_config.py Adds the public page_lang parameter and includes non-empty values in page configuration messages.
frontend/app/src/App.tsx Applies the configured language to the root HTML element while preserving the existing value when omitted.
proto/streamlit/proto/PageConfig.proto Adds the backward-compatible lang string field to PageConfig.

Reviews (3): Last reviewed commit: "Fix: use falsy check for lang proto3 def..." | Re-trigger Greptile

Comment thread lib/streamlit/commands/page_config.py Outdated
Comment on lines +309 to +310
if page_lang is not None:
msg.page_config_changed.lang = page_lang

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Invalid Language Tags Pass Through

Any non-None string, including "" or "not_a_language", is forwarded despite the documented BCP 47 requirement. The frontend then either ignores the empty value and leaves a stale language in place or assigns an invalid <html lang> value, so browsers and screen readers can continue using the wrong language.

Comment thread frontend/app/src/App.tsx
Comment on lines +1127 to +1129
if (lang) {
document.documentElement.lang = lang
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The condition if (lang) will fail for empty strings since empty strings are falsy in JavaScript. However, the Python backend at page_config.py:309-310 checks if page_lang is not None, which means empty strings will be sent to the frontend but not applied. This creates an inconsistency.

Fix by checking explicitly for null/undefined:

if (lang !== undefined && lang !== null) {
  document.documentElement.lang = lang
}

Or if empty strings should be rejected, add validation in the Python backend:

if page_lang is not None and page_lang != "":
    msg.page_config_changed.lang = page_lang
Suggested change
if (lang) {
document.documentElement.lang = lang
}
if (lang !== undefined && lang !== null) {
document.documentElement.lang = lang
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit f7e90f7. Configure here.

Comment thread frontend/app/src/App.tsx
protobuf3 defaults unset string fields to "", which is falsy in JS.
Using if (lang) correctly skips the empty proto default so the
original index.html lang="en" (or a previously set value) is not
overwritten. Python backend already rejects empty strings.
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.

<html lang="en"> is hardcoded in index.html, causing unwanted browser translation prompts for non-English apps

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.