Language switch
A small pill link with a globe icon that jumps between two language versions of a page, for example English and Arabic (right-to-left).
Examples
Default
Put it first inside .site-actions in the header. Add lang and hreflang so screen readers and search engines know the language of the target page.
Dropdown
For a site with more than two languages. The same pill opens a list with each language written in that language, and a check mark on the current one. It uses the standard Bootstrap dropdown, so it works with the keyboard and needs no extra JavaScript.
Only the English and Arabic pages come with the template. Point the other links at your own translated pages. In the header, put the dropdown first inside .site-actions and add dropdown-menu-end to the menu so it opens towards the page. Move aria-current="true" and the check icon to the language of the page you are on.
Icon-only dropdown
The same dropdown with just the globe. It saves space in a busy header. Add lang-switch--icon to the button and keep an aria-label, because there is no visible text.
In the site header the dropdown opens flush under the header with the same animation as the menu dropdowns. See index.html.
Classes and attributes
| Name | Purpose |
|---|---|
.lang-switch | The pill link. Contains the #i-globe icon and the language name written in that language. |
.lang-dropdown | Wrapper for the dropdown variation (together with Bootstrap's .dropdown). |
.lang-switch.dropdown-toggle | The pill as a button that opens the list. Contains the globe, the current language and the .lang-caret chevron. |
.dropdown-item + aria-current="true" | One language in the list. The current language gets a soft background and a check mark. |
.lang-switch--icon | Round icon-only version of the button. Needs an aria-label. |
lang, hreflang | Language code of the target page. |