Multi-Language Support
To support multiple languages on your Docusaurus site, follow the instructions below:
Add the following code to the
docusaurus.config.js
file, assuming you need to addSimplified Chinese
support:Part 1:
const config = {
i18n: {
defaultLocale: "en",
locales: ["en", "zh"],
localeConfigs: {
en: {
label: "English",
},
zh: {
label: "简体中文",
},
},
},
}Part 2:
themeConfig: {
navbar: {
items: [
{
type: "localeDropdown",
position: "right",
},
],
},
}In the project directory, run the following command:
yarn run write-translations -- --locale zh
This command will generate the translation-related files in the
i18n
folder, which need to be translated as needed.