feat: allow setting calendar for i18n date formatting (#6430)

* feat: allow setting calendar for i18n date formatting

* fix TS

* add test
This commit is contained in:
Joshua Chen 2022-04-08 22:34:34 +08:00 committed by GitHub
parent 3e110054d7
commit 7941a46be3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 12 deletions

View file

@ -124,6 +124,8 @@ The i18n configuration object to [localize your site](../i18n/i18n-introduction.
Example:
<!-- cSpell:ignore فارسی -->
```js title="docusaurus.config.js"
module.exports = {
i18n: {
@ -134,11 +136,13 @@ module.exports = {
label: 'English',
direction: 'ltr',
htmlLang: 'en-US',
calendar: 'gregory',
},
fr: {
label: 'Français',
direction: 'ltr',
htmlLang: 'fr-FR',
fa: {
label: 'فارسی',
direction: 'rtl',
htmlLang: 'fa-IR',
calendar: 'persian',
},
},
},
@ -148,6 +152,7 @@ module.exports = {
- `label`: the label to use for this locale
- `direction`: `ltr` (default) or `rtl` (for [right-to-left languages](https://developer.mozilla.org/en-US/docs/Glossary/rtl) like Arabic, Hebrew, etc.)
- `htmlLang`: BCP 47 language tag to use in `<html lang="...">` and in `<link ... hreflang="...">`
- `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`).
### `noIndex` {#noindex}