Skip to content

Commit ad15605

Browse files
authored
feat(theme-classic): use lang attribute in navbar locale dropdown items (facebook#7942)
1 parent b4279df commit ad15605

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

packages/docusaurus-theme-classic/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default function LocaleDropdownNavbarItem({
3434
})}`;
3535
return {
3636
label: localeConfigs[locale]!.label,
37+
lang: localeConfigs[locale]!.htmlLang,
3738
to,
3839
target: '_self',
3940
autoAddBaseUrl: false,

packages/docusaurus-types/src/i18n.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export type I18nLocaleConfig = {
1111
/** The label displayed for this locale in the locales dropdown. */
1212
label: string;
1313
/**
14-
* BCP 47 language tag to use in `<html lang="...">` and in
15-
* `<link ... hreflang="...">`
14+
* BCP 47 language tag to use in:
15+
* - `<html lang="...">` (or any other DOM tag name)
16+
* - `<link ... hreflang="...">`
1617
*/
1718
htmlLang: string;
1819
/** Used to select the locale's CSS and html meta attribute. */

website/docs/api/docusaurus.config.js.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ module.exports = {
157157
- `localeConfigs`: Individual options for each locale.
158158
- `label`: The label displayed for this locale in the locales dropdown.
159159
- `direction`: `ltr` (default) or `rtl` (for [right-to-left languages](https://developer.mozilla.org/en-US/docs/Glossary/rtl) like Farsi, Arabic, Hebrew, etc.). Used to select the locale's CSS and HTML meta attribute.
160-
- `htmlLang`: BCP 47 language tag to use in `<html lang="...">` and in `<link ... hreflang="...">`
160+
- `htmlLang`: BCP 47 language tag to use in `<html lang="...">` (or any other DOM tag name) and in `<link ... hreflang="...">`
161161
- `calendar`: the [calendar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar) used to calculate the date era. Note that it doesn't control the actual string displayed: `MM/DD/YYYY` and `DD/MM/YYYY` are both `gregory`. To choose the format (`DD/MM/YYYY` or `MM/DD/YYYY`), set your locale name to `en-GB` or `en-US` (`en` means `en-US`).
162162
- `path`: Root folder that all plugin localization folders of this locale are relative to. Will be resolved against `i18n.path`. Defaults to the locale's name. Note: this has no effect on the locale's `baseUrl`—customization of base URL is a work-in-progress.
163163

0 commit comments

Comments
 (0)