DEV Community

Discussion on: NextJS add lang attribute to HTML tag

Collapse
 
maxfindel profile image
Max F. Findel

Thanks for sharing this. Do you know about the best practices for language toggles and selects in the realm of a11y?

Collapse
 
vhs profile image
vhs

Make them discoverable by placing them in the header or footer with each language labeled twice: once in the current locale and again in the original format. Look here for accessible select menus and at Headless UI for guardrails. Finally, Jacob Neilson has some pointed advice worth consuming.

Collapse
 
dailydevtips1 profile image
Chris Bongers

Hi Max,

I haven't gotten that far in to tell you in detail, but perhaps @inhuofficial or @abbeyperini can shed some light on this?

Collapse
 
abbeyperini profile image
Abbey Perini

Hey! I haven't built a language select, only written some i18next code, but there are some good resources out there:

Looks like one of the main gotchas is you should only use flags if you're having the user select countries - many languages are spoken in multiple countries and many countries have multiple languages spoken within their borders. Otherwise, making the component accessible depends on the HTML element you choose to use.

Thread Thread
 
maxfindel profile image
Max F. Findel

Oh wow, thanks for all the resources! I'm gonna look into i18next ๐Ÿ‘
I totally agree with the flags vs languages. I prefer to use the ISO abbreviations :)