Skip to main content

This is a draft (version 0.5.0). The National Information Technology Agency (NITA) plans to make GGDS official guidance for government websites after independent accessibility testing. What this means

Ghana Government Design System Design system for Government of Ghana websites – home Search

Navigation

Language switcher

Links to the same page in other languages, each named in its own language.

When to use

  • When the page is published in more than one language: English and Twi, Ewe, Ga, Hausa or Dagbani, for example.

When not to use

  • When only some pages are translated: link to the translated page from the text instead, and say which language it is in.
  • With automatic translation that no speaker has checked. Government information must be accurate in every language it is published in.

How to use

  • Put it at the top of every page, above or in the header, in the same place on every page.
  • Name each language in that language ("Eʋegbe", not "Ewe"), so people who do not read English can find theirs.
  • Link each language to the same page in that language, not to the homepage.
  • Set <html lang> to the page's language on every page, and lang on any passage in another language.
  • GGDS's own text, such as "Skip to main content" and "There is a problem", comes in each language from GGDS, as far as speakers have translated it: see Languages in the developers' guide. Until then it is shown in English.
  • The names of the languages GGDS lists have not yet been checked by speakers. Check them with a speaker before you publish.

Accessibility

What GGDS does

  • Each link has lang, so a screen reader reads the language's name in that language, and hreflang.
  • The current language is bold, not a link style, and is announced as current (aria-current="true").
  • Every link is at least 44px tall.

What you need to do

  • Set lang on the page, so screen readers and translation tools use the right language (WCAG 3.1.1).
  • Do not use flags for languages: a flag is a country, not a language, and Ghana has many languages.

Example: Language switcher

Open this example on its own page

HTML code for “Language switcher”
HTML
<nav class="ggds-language-switcher" aria-label="Choose a language">
  <ul class="ggds-language-switcher__list">
    <li><a class="ggds-language-switcher__link" href="/" lang="en" hreflang="en" aria-current="true">English</a></li>
    <li><a class="ggds-language-switcher__link" href="/tw/" lang="tw" hreflang="tw">Twi</a></li>
    <li><a class="ggds-language-switcher__link" href="/ee/" lang="ee" hreflang="ee">Eʋegbe</a></li>
    <li><a class="ggds-language-switcher__link" href="/gaa/" lang="gaa" hreflang="gaa">Gã</a></li>
    <li><a class="ggds-language-switcher__link" href="/ha/" lang="ha" hreflang="ha">Hausa</a></li>
    <li><a class="ggds-language-switcher__link" href="/dag/" lang="dag" hreflang="dag">Dagbanli</a></li>
  </ul>
</nav>
JSX (React)
<nav className="ggds-language-switcher" aria-label="Choose a language">
  <ul className="ggds-language-switcher__list">
    <li><a className="ggds-language-switcher__link" href="/" lang="en" hreflang="en" aria-current="true">English</a></li>
    <li><a className="ggds-language-switcher__link" href="/tw/" lang="tw" hreflang="tw">Twi</a></li>
    <li><a className="ggds-language-switcher__link" href="/ee/" lang="ee" hreflang="ee">Eʋegbe</a></li>
    <li><a className="ggds-language-switcher__link" href="/gaa/" lang="gaa" hreflang="gaa">Gã</a></li>
    <li><a className="ggds-language-switcher__link" href="/ha/" lang="ha" hreflang="ha">Hausa</a></li>
    <li><a className="ggds-language-switcher__link" href="/dag/" lang="dag" hreflang="dag">Dagbanli</a></li>
  </ul>
</nav>

Use it

Stylesheet
ggds.css includes it. To load only the parts you use: core.css, then components/navigation.css (0.9 KB with gzip, minified), which also holds breadcrumbs, pagination and tab links.
JavaScript
None needed.

HTML

Copy the HTML under each example above. It works in any website.

Astro

With @ggds/astro:

JavaScript
import LanguageSwitcher from '@ggds/astro/LanguageSwitcher.astro';

<LanguageSwitcher languages={[{ code: 'en', href: '/' }, { code: 'tw', href: '/tw/' }]} current="en" />

React and Next.js

No React component: switch the HTML under an example to JSX (React) and copy it.

Django

With ggds-django ({% load ggds %}):

Django template
{% ggds_language_switcher %}

Classes and states

Classes for language switcher
ClassWhat it does
.ggds-language-switcherThe languages this page is in.
.ggds-language-switcher__listOne link per language.
.ggds-language-switcher__linkA language, named in that language, with lang and hreflang. The current one has aria-current="true".

Accessibility tests

Automated, on every change

These run each time GGDS changes. A change that fails one is not accepted.

  • WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
  • No sideways scrolling on a 320px screen, also with a wide font, on every example
  • Every approved colour pair meets its contrast minimum, for every institution theme
  • No inline scripts or styles, so it runs under a strict Content Security Policy
  • Behaviour test: “the language switcher names each language in its own language”
  • Behaviour test: “no horizontal scrolling at 320px”
  • Behaviour test: “no horizontal scrolling at 320px with a wide font”

By people, with assistive technology

Automated tests find only some of the barriers people meet. These checks are still to be done.

Manual accessibility checks for language switcher
CheckResultNotes
Keyboard onlyNot tested yetWaiting for the external audit with disabled people (decision D-09).
NVDA screen reader with Firefox or Chrome (Windows)Not tested yetWaiting for the external audit with disabled people (decision D-09).
JAWS screen reader with Chrome (Windows)Not tested yetWaiting for the external audit with disabled people (decision D-09).
VoiceOver screen reader with Safari (iPhone)Not tested yetWaiting for the external audit with disabled people (decision D-09).
TalkBack screen reader with Chrome (Android)Not tested yetWaiting for the external audit with disabled people (decision D-09).
Zoom to 400%, and increased text spacingNot tested yetWaiting for the external audit with disabled people (decision D-09).
Windows contrast themes (forced colours)Not tested yetWaiting for the external audit with disabled people (decision D-09).
Voice control (Voice Access or Dragon)Not tested yetWaiting for the external audit with disabled people (decision D-09).

Changes

Changes to language switcher, newest first
VersionChange
0.4.0New components: back link, side navigation, contents list ("On this page"), language switcher, phase banner, cookie banner and character count, in HTML, Django, React and (except the character count) Astro. All are alpha: tested automatically, not yet on a live website. The cookie banner needs no JavaScript: its buttons send a form, and both choices look the same.
0.1.0Added.

Every change, in What’s new

Back to top

Something wrong, unclear or missing? Report a problem with this page or suggest a change to it on GitHub. You need a GitHub account.