Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f8081c7

Browse files
authoredJan 2, 2023
Add translation guide (#279)
* docs: add translation guide * docs(i18n/translation): update typo * docs(contributing): fix contributing docs script error
1 parent b3ea5a2 commit f8081c7

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
 

‎CONTRIBUTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ Following are brief descriptions of the repository architecture:
9494
- [examples](https://github.com/nvh95/jest-preview/tree/main/examples/): contains examples of how to integrate Jest Preview with various libraries and frameworks.
9595
- [website](https://github.com/nvh95/jest-preview/tree/main/website/): contains code for [www.jest-preview.com](https://www.jest-preview.com/)
9696

97+
## Translation Contributing
98+
99+
- See [TRANSLATION.md](https://github.com/nvh95/jest-preview/tree/main/TRANSLATION.md)
100+
97101
## Submit a PR
98102

99103
So you have decided to contribute code back to upstream by opening a pull request. You've invested a good chunk of time, and we appreciate it. We will do our best to work with you and get the PR looked at.

‎TRANSLATION.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Translation Contributing
2+
3+
## How
4+
5+
We use [docusaurus](https://docusaurus.io/) to build our document. See [Docusaurus I18n Guide](https://docusaurus.io/docs/i18n/introduction)
6+
7+
## Add a new language (Optional)
8+
9+
### Add dropdown item in navbar
10+
11+
Open site config: `/website/docusaurus.config.js`. Add new language in `i18n.locales`.
12+
13+
### Initialize language folder
14+
15+
In `/website`
16+
17+
```sh
18+
npm run write-translations -- --locale <language>
19+
```
20+
21+
This will create the preset files by docusaurus in `/website/i18n/<language>`.
22+
23+
## Translate
24+
25+
### Start the site
26+
27+
In `/website`
28+
29+
```sh
30+
npm run start -- --locale <language>
31+
```
32+
33+
> **Note**
34+
>
35+
> - Each locale is a distinct standalone single-page application: it is not possible to start the Docusaurus sites in all locales at the same time.
36+
> - The static files may not be shown. Don't worry about that. It works fine in production.
37+
38+
### Homepage
39+
40+
Modify `/website/i18n/<language>/code.json` where id start with `home.`
41+
42+
### Footer and navbar
43+
44+
Modify files in `/website/i18n/<language>/docusaurus-theme-classic`
45+
46+
### Docs
47+
48+
1. Modify `/website/i18n/<language>/docusaurus-plugin-content-docs/current.json` for directory title.
49+
2. Copy your docs Markdown files from `docs/` to `/website/i18n/<language>/docusaurus-plugin-content-docs/current`, and translate them.
50+
51+
### Blog
52+
53+
No translation needed for now :P

‎website/docusaurus.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ const config = {
9797
{
9898
type: 'localeDropdown',
9999
position: 'right',
100+
dropdownItemsAfter: [
101+
{
102+
type: 'html',
103+
value: '<hr style="margin: 0.3rem 0;">',
104+
},
105+
{
106+
href: 'https://github.com/nvh95/jest-preview/tree/main/TRANSLATION.md',
107+
label: 'Help Us Translate',
108+
},
109+
],
100110
},
101111
],
102112
},

0 commit comments

Comments
 (0)
Please sign in to comment.