mirror of
https://gitea.com/gitea/docs.git
synced 2026-06-30 16:14:23 +00:00
Add Chinese support (#13)
# Main changes and Some notices - Chines Docs should be put into corresponding versions' folders under `i18n/zh-cn/docusaurus-plugin-content-docs`. See [translate-markdown-files](https://docusaurus.io/docs/i18n/tutorial#translate-markdown-files) for reference. And also [srs-docs](https://github.com/ossrs/srs-docs) is a project that can be used as a reference. So changed the related paths in `loop_docs*` scripts. - The markdown files under `docs/<version>` and `i18n/zh-cn/docusaurus-plugin-content-docs/<version>` must have the same name to be referred as translated. Files inside docs are corresponding to `current` version. For example, `docs/administration/mail-templates.md` and `i18n/zh-cn/docusaurus-plugin-content-docs/current/administration/mail-templates.md`. Filename of `mail-templates.md` must be the same (cannot be `mail-templates.zh-cn.md` and `mail-templates.us-en.md`) So trim the `.en-us.md` and `.zh-cn.md` to `.md` to ensure the same names inside `loop_docs*` scripts. - Used `npx docusaurus write-translations --locale zh-cn` to do sidebar, footer, and header translations, so no need to keep `sideBarCN` anymore. [reference](https://docusaurus.io/docs/cli#docusaurus-write-translations-sitedir) - Local Tests for `en` and `zh-cn` are separeted, run the following on local respectly to test them ```bash # test en version npm run start # test zh-cn version npm run start -- --locale zh-cn ``` - If wants to test `en` and `zh-cn` both at the same time, run build and serve ``` npm run build npm run serve ``` - Added some indexed page, for example:   Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/13 Co-authored-by: HesterG <hestergong@gmail.com> Co-committed-by: HesterG <hestergong@gmail.com>
This commit is contained in:
@@ -8,45 +8,47 @@ else
|
||||
SED_INPLACE="sed -i ''"
|
||||
fi
|
||||
|
||||
$SED_INPLACE 's/</<⁠/' docs/zh-cn/installation/with-docker.zh-cn.md
|
||||
$SED_INPLACE 's/<empty/<⁠empty/' docs/zh-cn/installation/with-docker.zh-cn.md
|
||||
$SED_INPLACE 's/</<⁠/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/with-docker.zh-cn.md
|
||||
$SED_INPLACE 's/<empty/<⁠empty/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/with-docker.zh-cn.md
|
||||
|
||||
$SED_INPLACE 's/</<⁠/' docs/zh-cn/contributing/guidelines-backend.zh-cn.md
|
||||
$SED_INPLACE 's/</⁠/' docs/zh-cn/contributing/guidelines-backend.zh-cn.md
|
||||
$SED_INPLACE 's/<empty/<⁠empty/' docs/zh-cn/contributing/guidelines-backend.zh-cn.md
|
||||
$SED_INPLACE 's/</<⁠/' i18n/zh-cn/docusaurus-plugin-content-docs/current/contributing/guidelines-backend.zh-cn.md
|
||||
$SED_INPLACE 's/</⁠/' i18n/zh-cn/docusaurus-plugin-content-docs/current/contributing/guidelines-backend.zh-cn.md
|
||||
$SED_INPLACE 's/<empty/<⁠empty/' i18n/zh-cn/docusaurus-plugin-content-docs/current/contributing/guidelines-backend.zh-cn.md
|
||||
|
||||
$SED_INPLACE 's/<empty/<⁠empty/' docs/zh-cn/administration/config-cheat-sheet.zh-cn.md
|
||||
$SED_INPLACE 's/<empty/<⁠empty/' i18n/zh-cn/docusaurus-plugin-content-docs/current/administration/config-cheat-sheet.zh-cn.md
|
||||
|
||||
$SED_INPLACE 's/^url:.*//' docs/zh-cn/intro.md
|
||||
$SED_INPLACE 's/^title:.*/displayed_sidebar: siderBarCN/' docs/zh-cn/intro.md
|
||||
$SED_INPLACE 's/^slug:.*/slug: \/zh-cn\//' docs/zh-cn/intro.md
|
||||
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' docs/zh-cn/development/hacking-on-gitea.zh-cn.md
|
||||
$SED_INPLACE 's/^url:.*//' i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
|
||||
$SED_INPLACE 's/^slug:.*/slug: \//' i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
|
||||
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' i18n/zh-cn/docusaurus-plugin-content-docs/current/development/hacking-on-gitea.zh-cn.md
|
||||
|
||||
$SED_INPLACE 's/"version":.*/"version":"1.20-dev"/' static/latest-swagger.json
|
||||
|
||||
for file in `find ./docs/zh-cn/ -name "*.md"`; do
|
||||
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/current/ -name "*.md"`; do
|
||||
# note only works on linux, forget about it when attempting to run on macos
|
||||
# hide hugo toc
|
||||
$SED_INPLACE 's/{{< toc >}}//' $file
|
||||
$SED_INPLACE 's/{{< version >}}/1.18.2/g' $file
|
||||
$SED_INPLACE 's/{{< relref "doc/\/docs\/zh-cn/g' $file
|
||||
$SED_INPLACE 's/{{< relref "doc/i18n\/zh-cn\/docusaurus-plugin-content-docs\/current/g' $file
|
||||
$SED_INPLACE 's/" >}}//g' $file
|
||||
$SED_INPLACE 's/\*\*Table of Contents\*\*//' $file
|
||||
$SED_INPLACE 's/weight:/sidebar_position:/g' $file
|
||||
done
|
||||
|
||||
for file in docs/zh-cn/*; do
|
||||
for file in i18n/zh-cn/docusaurus-plugin-content-docs/current/*; do
|
||||
if [ -d $file ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$file" == "docs/zh-cn/intro.md" ]; then
|
||||
if [ "$file" == "i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md" ]; then
|
||||
continue
|
||||
fi
|
||||
rm $file
|
||||
done
|
||||
|
||||
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/current/ -name "*.zh-cn.md"`; do
|
||||
mv "${file}" "${file/.zh-cn/}"
|
||||
done
|
||||
|
||||
# for file in `find ./docs/zh-cn/ -name "*.md"`; do
|
||||
# for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/current/ -name "*.md"`; do
|
||||
# trimmed=$(echo $file | cut -f 2 -d '.')
|
||||
# mv $file .$trimmed.md
|
||||
# done
|
||||
|
||||
Reference in New Issue
Block a user