feat: add LanguageSwitcher component with community Chinese translation

#3
by xilanhua12138 - opened

Summary

Adds a reusable LanguageSwitcher.astro component that displays available translations in the article metadata section (alongside Authors, Affiliations, Published, PDF).

Changes

  • New: app/src/components/LanguageSwitcher.astro β€” a small, accessible nav component
  • Modified: app/src/components/Hero.astro β€” accepts optional translations and translationsLabel props
  • Modified: app/src/pages/index.astro β€” reads translations from article frontmatter
  • Modified: app/src/content/article.mdx β€” adds community Chinese translation link

How it works

Add a translations array to any article's frontmatter:

translationsLabel: "Available in"
translations:
  - lang: en
    label: English
    url: https://openevals-evaluation-guidebook.hf.space
    flag: "πŸ‡ΊπŸ‡Έ"
    current: true
  - lang: zh
    label: δΈ­ζ–‡
    url: https://xilanhua12138.github.io/evaluation-guidebook-cn/
    flag: "πŸ‡¨πŸ‡³"

The component renders a compact inline language switcher. Articles without a translations key are unaffected.

Community Chinese translation

This PR also links to a community Chinese translation of the Evaluation Guidebook:

The translation covers the complete article content and is deployed on GitHub Pages.

Preview

The language switcher appears as:

πŸ‡ΊπŸ‡Έ English / πŸ‡¨πŸ‡³ δΈ­ζ–‡

in the article header metadata section.

Thank you for reviewing this contribution!

The actual code changes are available at my fork: https://huggingface.co/spaces/xilanhua12138/evaluation-guidebook-pr

Files changed:

  • app/src/components/LanguageSwitcher.astro (new) β€” reusable language switcher component
  • app/src/components/Hero.astro (modified) β€” adds optional translations prop
  • app/src/pages/index.astro (modified) β€” reads translations from frontmatter
  • app/src/content/article.mdx (modified) β€” adds link to Chinese community translation

The LanguageSwitcher renders as:

πŸ‡ΊπŸ‡Έ English / πŸ‡¨πŸ‡³ δΈ­ζ–‡

View the full diff and changes at: https://huggingface.co/spaces/xilanhua12138/evaluation-guidebook-pr/tree/main/app/src

Sign up or log in to comment