cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 馃崈
charm
leaflet
readability
golang
1---
2sidebar_position: 2
3---
4
5# Translate your site
6
7Let's translate `docs/intro.md` to French.
8
9## Configure i18n
10
11Modify `docusaurus.config.js` to add support for the `fr` locale:
12
13```js title="docusaurus.config.js"
14export default {
15 i18n: {
16 defaultLocale: 'en',
17 locales: ['en', 'fr'],
18 },
19};
20```
21
22## Translate a doc
23
24Copy the `docs/intro.md` file to the `i18n/fr` folder:
25
26```bash
27mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/
28
29cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.md
30```
31
32Translate `i18n/fr/docusaurus-plugin-content-docs/current/intro.md` in French.
33
34## Start your localized site
35
36Start your site on the French locale:
37
38```bash
39npm run start -- --locale fr
40```
41
42Your localized site is accessible at [http://localhost:3000/fr/](http://localhost:3000/fr/) and the `Getting Started` page is translated.
43
44:::caution
45
46In development, you can only use one locale at a time.
47
48:::
49
50## Add a Locale Dropdown
51
52To navigate seamlessly across languages, add a locale dropdown.
53
54Modify the `docusaurus.config.js` file:
55
56```js title="docusaurus.config.js"
57export default {
58 themeConfig: {
59 navbar: {
60 items: [
61 // highlight-start
62 {
63 type: 'localeDropdown',
64 },
65 // highlight-end
66 ],
67 },
68 },
69};
70```
71
72The locale dropdown now appears in your navbar:
73
74
75
76## Build your localized site
77
78Build your site for a specific locale:
79
80```bash
81npm run build -- --locale fr
82```
83
84Or build your site to include all the locales at once:
85
86```bash
87npm run build
88```