Repository navigation
Show the proper title of the programming language in code samples - #5896
Merged
Merged
Conversation
added 4 commits
October 18, 2026 00:03
Map common programming languages and their aliases (case-insensitive) to localizable titles, e.g. "js" to "JavaScript", instead of capitalizing the first letter of the raw value via CSS. Titles can be overridden via overrideLocalizedStrings (PROGRAMMING_LANGUAGE_*); unknown languages keep their first letter capitalized.
…ht case-insensitively
- "bash" and "zsh" keep their own name instead of "Shell" (as before this PR)
- Drop PROGRAMMING_LANGUAGE_C/GO/JAVA/SWIFT: no aliases, same as the fallback
- Comment every PROGRAMMING_LANGUAGE_* string, like other grouped strings
- Lower-case the language before Shiki resolves it, so "TS" is highlighted
- Re-capture markdown/codeBlock/contrast{,.fluent,.fluent.dark} snap-3 with
the current comment color (#656d76)
The title is now "Python" in the DOM instead of "python" upper-cased by a
`::first-letter` rule, so the browser shapes it as one text run and the
anti-aliasing of the "t" differs in 6 pixels. Re-capture snap-8 and snap-9
of part-grouping/{fluent,fluent.dark,copilot,copilot.dark}.html.
Eugene (OEvgeny)
marked this pull request as ready for review
October 18, 2026 18:09
Eugene (OEvgeny)
requested review from
William Wong (compulim),
Chris Whitten (cwhitten) and
Thomas Durnford (tdurnford)
as code owners
October 18, 2026 18:09
William Wong (compulim)
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Fixed
js, now show their proper names, which can be overridden viaoverrideLocalizedStrings(PROGRAMMING_LANGUAGE_*), in PR #5896, by @OEvgenyTS, in PR #5896, by @OEvgenyDescription
The titles of collapsible code blocks and of the "View code" dialog were the raw
programmingLanguageof the message, capitalized only by CSS, sojavascriptshowed as "Javascript" and the dialog was labelled "Code sample: javascript". Common languages and their aliases (case-insensitive) now map to localizable titles, e.g.jsto "JavaScript" andpyto "Python"; other languages, such asbash, keep their first letter capitalized. The language is also lower-cased for the highlighter, soTSis highlighted likets.Design
PROGRAMMING_LANGUAGE_*), so hosts can override them viaoverrideLocalizedStrings; languages whose title is just the capitalized name, such as Go, have no string.Specific Changes
component/src/hooks/internal/useLocalizeProgrammingLanguage.ts: new internal hook that maps a language or alias to its localized titleStackedLayout.tsxandMarkdownTextContent.tsx: use the hook for the titles of the code block and the "View code" dialogCodeBlockContent.module.cssandViewCodeDialog.module.css: removed thetext-transformcapitalizationapi/src/localization/en-US.json: added 20PROGRAMMING_LANGUAGE_*stringsbundle/src/codeHighlighter/ShikiComposer.tsx: lower-cases the language before highlighting__tests__/html2/activity/programmingLanguageTitle.html: lowercase, uppercase, alias, overridden, and unknown languages in collapsible code blocks and the "View code" dialogmarkdown/codeBlock/contrast*andactivity/collapsible*snapshots, which also pick up the final comment color from Ensure 4.5:1 contrast for syntax-highlighted code and keep code blocks when messages are already in the store #5893CHANGELOG.mdReview Checklist
z-index)package.jsonandpackage-lock.jsonreviewed