Language navigation Nunjucks macro options
Use options to customise the appearance, content and behaviour of this component when using a macro, for example, changing the text.
Also see the guidance on the Language navigation component page, which shows these options in use within each example.
Some options are required for the macro to work; these are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| items | array | Required. The languages to display within the language navigation. See macro options for items. |
| aria |
string | Plain text label identifying the navigation landmark to screen readers. Write it in the language of the current page. Defaults to “Language”. |
| classes | string | Classes to add to the language navigation container. |
| attributes | object | HTML attributes to add to the language navigation container. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Name of the language, written in that language (for example, “Cymraeg” for Welsh). If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML to use for the language item. If html is provided, the text option will be ignored.
|
| lang | string |
Required.
The language tag for the language item text (for example, cy for Welsh). Added as a lang attribute so that assistive technologies pronounce the language name correctly.
|
| href |
string |
The language tag for the linked page (for example, cy for Welsh). Added as an hreflang attribute for search engines and other machine readers. Defaults to lang when omitted.
|
| dir | string |
The text direction of the script the language name is written in (ltr for left-to-right scripts or rtl for right-to-left). Set this on every item if the navigation includes scripts written in different directions.
|
| href | string | Link to the current page in this language. |
| current | boolean |
Whether this is the language of the current page. Defaults to true when href is not provided.
|
| language |
string | Visually hidden text after a language link to indicate what the link will do. Write it in the language of the link (for example, “Change the language to English”). |
| classes | string | Classes to add to the language item anchor. |
| attributes | object | HTML attributes to add to the language item anchor. |