Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i18n for screen reader section labels #2249

Merged
merged 4 commits into from
Dec 28, 2022
Merged

Conversation

yanthomasdev
Copy link
Member

What kind of changes does this PR include?

  • Translated content
  • Changes to the docs site code

Description

This PR adds a new rehype plugin to translate the screen reader anchor labels injected by rehype-autolink-headings. If the current language doesn't have a translation yet, it will fallback to English.

PT-BR (translated) ES (fallback)
image image

@yanthomasdev yanthomasdev added i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! a11y Anything to do with improving accessibility labels Dec 28, 2022
@netlify
Copy link

netlify bot commented Dec 28, 2022

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 73e3391
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/63ac63557a46430009884e22
😎 Deploy Preview https://deploy-preview-2249--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot removed the i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! label Dec 28, 2022
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Clever solution! Shame rehype-autolink-headings doesn’t provide file etc. as context to its different methods so we could just plug this in there. Made a small naming suggestion & refactor recommendation.

LOVE that this is your first PR back — i18n + a11y in one go 🙌

src/i18n/util.ts Outdated Show resolved Hide resolved
src/i18n/util.ts Outdated Show resolved Hide resolved
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

LGTM! Welcome back @Yan-Thomas 🚀

@yanthomasdev yanthomasdev merged commit b29c071 into main Dec 28, 2022
@yanthomasdev yanthomasdev deleted the i18n-autolink-headings branch December 28, 2022 15:44
delucis added a commit that referenced this pull request Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Anything to do with improving accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make screen reader section labels translatable
2 participants