docusaurus/packages/docusaurus-init/templates/classic/docs/translate-your-site.md
besemuna b99a4031c6
feat(v2): Improve the initial templates #4302 (#4320)
* feat: add getting started doc at classic inital templates

* fix: improve the contents of getting started page

* fix: fix slug routing

* fix: rename gettingStarted to getting-started and re-adjust the content

* feat: add markdown-features docs

* feat: add a page on how to create a simple document

* feat: add a page on how to create pages

* feat: add create a post doc

* feat: add thank you page with whats next

* feat : update sidebar.js

* feat : add introduction content

* feat : add self hosting content

* feat : add GitHub pages content

* fix : remove automatically deploying with github actions content

* feat : add deploying to netlify

* feat : add Translate your site

* add : Manage versions

* fix : formatted docs with prettier

* Revert "fix : formatted docs with prettier"

This reverts commit af8c0b48

* run prettier to init templates with fixes

* complete new init template

* rename manage-docs-versions

* change wording

* refresh config file

* rework init template homepage

* minor changes

Co-authored-by: Lisa Chandra <52909743+lisa761@users.noreply.github.com>
Co-authored-by: Javid <singularity.javid@gmail.com>
Co-authored-by: ShinteiMai <stevenhanselgo@gmail.com>
Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-03-17 15:59:01 +01:00

1.6 KiB

title
Translate your site

Let's translate docs/getting-started.md to French.

Configure i18n

Modify docusaurus.config.js to add support for the fr locale:

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'fr'],
  },
};

Translate a doc

Copy the docs/getting-started.md file to the i18n/fr directory:

mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/

cp docs/getting-started.md i18n/fr/docusaurus-plugin-content-docs/current/getting-started.md

Translate i18n/fr/docusaurus-plugin-content-docs/current/getting-started.md in French.

Start your localized site

Start your site on the French locale:

npm run start -- --locale fr

Your localized site is accessible at http://localhost:3000/fr/ and the Getting Started page is translated.

:::warning

In development, you can only use one locale at a same time.

:::

Add a Locale Dropdown

To navigate seamlessly across languages, add a locale dropdown.

Modify the docusaurus.config.js file:

module.exports = {
  themeConfig: {
    navbar: {
      items: [
        // highlight-start
        {
          type: 'localeDropdown',
        },
        // highlight-end
      ],
    },
  },
};

The locale dropdown now appears in your navbar:

Locale Dropdown

Build your localized site

Build your site for a specific locale:

npm run build -- --locale fr

Or build your site to include all the locales at once:

npm run build