Translated sites
This page explains how migrate a translated Docusaurus v1 site to Docusaurus v2.
i18n differences
Docusaurus v2 i18n is conceptually quite similar to Docusaurus v1 i18n with a few differences.
It is not tightly coupled to Crowdin, and you can use Git or another SaaS instead.
Different filesystem paths
On Docusaurus v2, localized content is generally found at website/i18n/[locale]
.
Docusaurus v2 is modular based on a plugin system, and each plugin is responsible to manage its own translations.
Each plugin has its own i18n subfolder, like: website/i18n/fr/docusaurus-plugin-content-blog
Updated translation APIs
With Docusaurus v1, you translate your pages with <translate>
:
const translate = require('../../server/translate.js').translate;
<h2>
<translate desc="the header description">
This header will be translated
</translate>
</h2>;
On Docusaurus v2, you translate your pages with <Translate>
import Translate from '@docusaurus/Translate';
<h2>
<Translate id="header.translation.id" description="the header description">
This header will be translated
</Translate>
</h2>;
The write-translations
CLI still works to extract translations from your code.
The code translations are now added to i18n/[locale]/code.json
using Chrome i18n JSON format.