Skip to content

Fix attribution section for #1368#1411

Open
Ryan-z-Feng-ccsf wants to merge 3 commits into
processing:mainfrom
Ryan-z-Feng-ccsf:main
Open

Fix attribution section for #1368#1411
Ryan-z-Feng-ccsf wants to merge 3 commits into
processing:mainfrom
Ryan-z-Feng-ccsf:main

Conversation

@Ryan-z-Feng-ccsf
Copy link
Copy Markdown

@Ryan-z-Feng-ccsf Ryan-z-Feng-ccsf commented May 27, 2026

Resolves #1368

Changes

This PR implements a robust multilingual fallback mechanism for the remix metadata (attributions and code history) in the localized Examples pages.

Implementation details and decisions:

Logic Extraction: Created getFallbackRemixData in src/pages/_utils.ts to cleanly separate the data-fetching logic from the UI layout (ExampleLayout.astro).

Dynamic Path Resolution: If a localized example is missing its remix data, the utility dynamically replaces the current locale prefix with the English one (e.g., "zh-Hans/02_.../description.mdx" -> "en/02_.../description.mdx") and fetches the corresponding English metadata via getCollection.

Early Returns & Safe Fallbacks: The function safely exits and returns existing data if the page is already in English or if the localized data is already populated.

Unit Testing: Added comprehensive test cases in test/pages/_utils.test.ts to ensure the fallback safely retrieves English attribution data when localized versions are empty, and degrades safely when no data exists at all.

Documentation Update: Added a note to docs/localization.md to clarify to future translators that they no longer need to copy or include the remix metadata block into localized .mdx files.

Screenshots of the change

image Screenshot 2026-05-26 174601

PR Checklist

[x] I have read the Contributor Guidelines and followed the instructions.

[x] I have added tests to cover my changes (if applicable).

[x] My changes do not introduce any new errors or warnings.

(Note: Thanks to @pgzcoa for the collaboration and initial issue tracking!)

Co-authored-by: pgzcoa <patriciaguerrero01@gmail.com>
@Ryan-z-Feng-ccsf Ryan-z-Feng-ccsf changed the title fix attribution section for #1368 Fix attribution section for #1368 May 27, 2026
Added note about translating Example pages and remix metadata.
@Ryan-z-Feng-ccsf Ryan-z-Feng-ccsf marked this pull request as ready for review May 27, 2026 21:06
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.

The "attribution" section is not falling back to English on translated pages

1 participant