Fix various Expressive Code translation issues#1708
Merged
HiDeoo merged 3 commits intowithastro:mainfrom Apr 5, 2024
Merged
Conversation
🦋 Changeset detectedLatest commit: cb31acc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
1 task
hippotastic
approved these changes
Apr 3, 2024
Contributor
hippotastic
left a comment
There was a problem hiding this comment.
Thank you for these fixes! Looks great to me!
delucis
approved these changes
Apr 5, 2024
Comment on lines
+38
to
+46
| /** | ||
| * Get the BCP-47 language tag for the given locale. | ||
| * @param locale Locale string or `undefined` for the root locale. | ||
| */ | ||
| export function localeToLang(config: StarlightConfig, locale: string | undefined): string { | ||
| const lang = locale ? config.locales?.[locale]?.lang : config.locales?.root?.lang; | ||
| const defaultLang = config.defaultLocale?.lang || config.defaultLocale?.locale; | ||
| return lang || defaultLang || 'en'; | ||
| } |
Member
There was a problem hiding this comment.
Should this maybe live in packages/starlight/integrations/shared/?
Member
Author
There was a problem hiding this comment.
Oh, right, totally forgot about that directory. I'll update that and merge the PR. 👍
Merged
HiDeoo
added a commit
to HiDeoo/starlight
that referenced
this pull request
Apr 5, 2024
* main: (111 commits) Fix various Expressive Code translation issues (withastro#1708) Fix nested aside title rendering issue (withastro#1703) I18n(pt-PT): Add resources pages (withastro#1678) Add SST Ion & Font Awesome to site showcase (withastro#1710) [ci] format Add SudoVanilla to showcase (withastro#1702) i18n(fr): Update `resources-showcase` (withastro#1697) [i18nIgnore] docs: update `starlight-links-validator` to version `0.7.1` (withastro#1696) [ci] format [ci] release (withastro#1688) [ci] format Update Russian translation (withastro#1616) [ci] format Adds `starlight` icon to Starlight (withastro#1698) Update Icons.ts with Farcaster Purple for SocialIcons (withastro#1622) Remove duplicate from showcase example in `contributing.md` (withastro#1692) i18n(zh-cn): Update `showcase.mdx` (withastro#1689) [ci] format i18n(zh-cn): Update configuration.mdx (withastro#1691) i18n(ko-KR): update `showcase.mdx` (withastro#1690) ...
HiDeoo
added a commit
to HiDeoo/starlight
that referenced
this pull request
Apr 8, 2024
* main: [ci] format [ci] release (withastro#1714) Fix various Expressive Code translation issues (withastro#1708) Fix nested aside title rendering issue (withastro#1703) I18n(pt-PT): Add resources pages (withastro#1678) Add SST Ion & Font Awesome to site showcase (withastro#1710)
Yoxnear
pushed a commit
to Yoxnear/starlight-custom
that referenced
this pull request
Jul 23, 2025
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com> Co-authored-by: Hippo <6137925+hippotastic@users.noreply.github.com>
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.
What kind of changes does this PR include?
Description
This PR fixes various issues with the UI strings translation in Expressive Code. I identified two issues:
The Expressive Code
getBlockLocale()function usespathToLocale()which can returnundefined. This function states the following:Altho, it looks like the default locale was never configured in the Expressive Code configuration.
The translation loading mechanism for Expressive Code did not properly handle all possible configuration: monolingual, multilingual, with or without a root locale, etc.
This pull request attempts to fix these 2 issues and also add a few tests to ensure that the expected translations are properly loaded in Expressive Code as we did not have any tests for this part of the codebase.
I would love to get @hippotastic 's feedback on this PR obviously.