-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: setup translation infra (#2549)
* docs: setup translation infra * Update netlify.toml * chore: reuse vitepress-translation-helper for docs * chore: update the translation guide in contributing doc * Update CONTRIBUTING.md
- Loading branch information
Showing
7 changed files
with
488 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,65 @@ Always try to provide as much information as possible. If you are reporting a bu | |
### Feature requests | ||
|
||
Lay out the reasoning behind it and propose an API for it. Ideally, you should have a practical example to prove the utility of the feature you're requesting. | ||
|
||
## Contributing Docs | ||
|
||
All the documentation files can be found in `packages/docs`. It contains the English markdown files while translation(s) are stored in their corresponding `<lang>` sub-folder(s): | ||
|
||
- [`zh`](https://github.com/vuejs/pinia/tree/v2/packages/docs/zh): Chinese translation. | ||
|
||
Besides that, the `.vitepress` sub-folder contains the config and theme, including the i18n information. | ||
|
||
Contributing to the English docs is the same as contributing to the source code. You can create a pull request to our GitHub repo. However, if you would like to contribute to the translations, there are two options and some extra steps to follow: | ||
|
||
### Translate in a `<lang>` sub-folder and host it on our official repo | ||
|
||
If you want to start translating the docs in a _new_ language: | ||
|
||
1. Create the corresponding `<lang>` sub-folder for your translation. | ||
2. Modify the i18n configuration in the `.vitepress` sub-folder. | ||
3. Translate the docs and run the doc site to self-test locally. | ||
4. Create a checkpoint for your language by running `pnpm run docs:translation:update <lang> [<commit>]`. A checkpoint is the hash and date of the latest commit when you do the translation. The checkpoint information is stored in the status file `packages/docs/.vitepress/translation-status.json`. _It's crucial for long-term maintenance since all the further translation sync-ups are based on their previous checkpoints._ | ||
5. Commit all the changes and create a pull request to our GitHub repo. | ||
|
||
> [!TIP] | ||
> When you create the checkpoint, please remember to pass the second "commit" argument as `v2` since that's the base branch of Pinia now. | ||
We will have a paragraph at the top of each translation page that shows the translation status. That way, users can quickly determine if the translation is up-to-date or lags behind the English version. | ||
|
||
Speaking of the up-to-date translation, we also need good long-term maintenance for every language. If you want to _update_ an existing translation: | ||
|
||
1. See what translation you need to sync up with the original docs. There are two popular ways: | ||
1. Via the [GitHub Compare](https://github.com/vuejs/pinia/compare/) page, only see the changes in `packages/docs/*` from the checkpoint hash to `v2` branch. You can find the checkpoint hash for your language via the translation status file `packages/docs/.vitepress/translation-status.json`. The compare page can be directly opened with the hash as part of the URL, e.g. https://github.com/vuejs/pinia/compare/c67a5c9...v2 | ||
2. Via a local command: `pnpm run docs:translation:compare <lang> v2`. | ||
2. Create your own branch and start the translation update, following the previous comparison. | ||
3. Create a checkpoint for your language by running `pnpm run docs:translation:update <lang> v2`. | ||
4. Commit all the changes and create a pull request to our GitHub repo. | ||
|
||
<!-- TODO: add an example once we have got one --> | ||
|
||
> [!TIP] | ||
> Before you create the new checkpoint, please remember fetch the latest v2 branch ahead. | ||
### Self-host the translation | ||
|
||
You can also host the translation on your own. To create one, fork our GitHub repo and change the content and site config in `packages/docs`. To long-term maintain it, we _highly recommend_ a similar way that we do above for our officially hosted translations: | ||
|
||
- Ensure you maintain the _checkpoint_ properly. Also, ensure the _translation status_ is well-displayed on the top of each translation page. | ||
- Utilize the diff result between the latest official repository and your own checkpoint to guide your translation. | ||
|
||
Tip: you can add the official repo as a remote to your forked repo. This way, you can still run `pnpm run docs:translation:update <lang> [<commit>]` and `npm run docs:translation:compare <lang> [<commit>]` to get the checkpoint and diff result: | ||
|
||
```bash | ||
# prepare the upstream remote | ||
git remote add upstream [email protected]:vuejs/pinia.git | ||
git fetch upstream v2 | ||
|
||
# set the checkpoint | ||
pnpm run docs:translation:update <lang> upstream/v2 | ||
|
||
# get the diff result | ||
pnpm run docs:translation:compare <lang> upstream/v2 | ||
``` | ||
|
||
<!-- TODO: add an example once we have got one --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[build] | ||
command = "pnpm run docs" | ||
command = "pnpm run docs:build" | ||
ignore = "./scripts/docs-check.sh" | ||
publish = "packages/docs/.vitepress/dist" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"zh": { | ||
"hash": "c67a5c9", | ||
"date": "2023-12-07" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.