Accessible i18n Pipeline: Metadata, Screen Readers, EU Rules
In this article
This guide walks you through building an internationalization (i18n) pipeline that is accessible to screen reader users and compliant with EU accessibility rules. You'll learn how to structure language metadata, handle translations, and test your output—so your content works for everyone, in every language.
What You'll Need
- A basic understanding of HTML, CSS, and JavaScript (or your framework of choice).
- Access to your codebase and a way to deploy changes.
- A translation management system or a simple JSON/PO file structure.
- A screen reader for testing (NVDA, VoiceOver, or TalkBack).
- Familiarity with your target EU markets and their language requirements.
Step-by-Step
- Define language metadata in your HTML. Start with the
langattribute on the<html>element. Use the correct ISO 639-1 code (e.g.,en,fr,de). For regional variants, use the full tag likeen-GBorfr-CA. This is the single most important step for screen readers—it tells them which pronunciation and character set to use. - Set the
dirattribute for RTL languages. If your pipeline supports Arabic or Hebrew, adddir="rtl"to the<html>element. Ensure your CSS uses logical properties (likemargin-inline-start) instead of physical ones (likemargin-left) so layouts flip automatically. - Use a standard i18n framework. Choose a library like i18next, react-i18next, or Vue I18n. These handle variable interpolation, pluralization, and date/number formatting. They also let you load translations asynchronously, which is essential for performance.
- Organize translation files with fallbacks. Store translations in JSON files per locale (e.g.,
en.json,fr.json). Always have a fallback locale (usually English) so that missing keys don't break the UI. In your i18n config, setfallbackLngto your default language. - Handle dynamic content and placeholders. For strings with variables, use placeholders like . Never concatenate strings manually—this breaks word order in other languages. For plurals, use the framework's plural rules; for example, in English: one item vs. many items , but in Russian there are three forms.
- Ensure screen reader announcements for language switches. When the user changes the language, update the
langattribute on the<html>element dynamically. Usearia-live="polite"on a status region to announce the change, e.g., "Language changed to French." - Provide accessible labels for language selectors. The language switcher should have an accessible name, like "Select language." Use a native
<select>element with a<label>, or a button witharia-haspopup="listbox". Ensure the current language is indicated witharia-current="true". - Translate all UI text, including ARIA labels. Don't forget alt text, button labels, and form placeholders. Use your i18n function for these too. For example, in React:
t('search.placeholder'). - Test with screen readers in multiple languages. Use NVDA (Windows) with different language packs, VoiceOver (macOS/iOS), and TalkBack (Android). Verify that the screen reader correctly switches voice and pronunciation when the
langattribute changes. - Comply with EU accessibility rules. The European Accessibility Act (EAA) and EN 301 549 require that public sector websites and apps meet WCAG 2.1 AA. This includes providing text alternatives, adaptable content, and compatibility with assistive technologies. Your i18n pipeline must not introduce barriers—for example, don't hide translated content with
display:noneif it's meant to be read. - Implement automated checks. Add a linter rule to ensure every string is wrapped in a translation function. Use a tool like i18next-scanner to extract keys and detect missing translations. In CI/CD, run a script that fails if any locale is missing a key.
- Document your pipeline. Create a README that explains how to add a new language, how to handle plural rules, and how to test accessibility. This helps future developers maintain the system.
Common Mistakes
- Forgetting the
langattribute on dynamic content. If you inject HTML with a different language, wrap it in an element with the correctlangattribute. - Using physical CSS properties for RTL. This breaks layouts when switching to Arabic or Hebrew.
- Hardcoding strings in components. This makes translation impossible and creates inconsistencies.
- Ignoring pluralization rules. English has two forms, but other languages have more. Always use the framework's pluralization.
- Not testing with real screen readers. Automated tools can't catch pronunciation issues or missing announcements.
Tips
- Use a translation management platform like Crowdin or Lokalise to collaborate with translators and keep keys organized.
- Cache translations in the browser to reduce load times. Use a service worker or local storage.
- Set the
content-languagemeta tag for SEO, but remember that thelangattribute is what screen readers use. - Use a language detector for initial locale, but always let the user override it.
- Provide a visual indicator of the current language in the UI, not just for screen readers.
Troubleshooting
- Screen reader reads the wrong language. Check that the
langattribute is correctly set on the<html>element and that it updates on language change. Also verify that the screen reader's language pack is installed. - Translations not loading. Check the network tab for 404 errors. Ensure your fallback locale is set, and that the JSON file paths are correct.
- RTL layout looks broken. Review your CSS for physical properties. Use the browser's RTL testing tools or add
dir="rtl"manually to see the issue. - Missing keys in production. Run a build-time check to compare key sets across locales. If a key is missing, the fallback will be used, but you should be notified.
- Screen reader doesn't announce language change. Ensure the
aria-liveregion is present in the DOM before the change and that the text is changed after thelangattribute is updated.
Frequently Asked Questions
Do I need to set the lang attribute on every element?
No, only on the <html> element and on any element that contains content in a different language. This is sufficient for screen readers.
Can I use machine translation for my pipeline?
Yes, but you must review it for accuracy and cultural nuances. Machine translation can be a starting point, but human review is essential for quality and accessibility.
How do I handle languages with different text directions?
Set dir="rtl" on the root element and use logical CSS properties. Your i18n framework should also handle this automatically if configured.
What is the European Accessibility Act and does it apply to me?
The EAA is an EU directive that requires products and services to be accessible to people with disabilities. It applies to most public-facing websites and apps, regardless of your company's location, if you serve EU citizens.
How do I test screen reader support for multiple languages?
Install the appropriate language packs for your screen reader. For NVDA, go to Settings > Language and select the language. Then navigate your site and listen for correct pronunciation.
Should I use a polyfill for the lang attribute?
No, the lang attribute is fully supported in all modern browsers and assistive technologies. No polyfill needed.