Add Chinese support #13

Merged
lunny merged 13 commits from HesterG/gitea-docusaurus:add-chinese-support into main 2023-05-26 06:30:14 +00:00
15 changed files with 263 additions and 151 deletions

View File

@ -21,11 +21,11 @@ jobs:
- name: prepare nightly docs
run: |
make prepare-latest
#prepare-latest-zh-cn
make prepare-latest-zh-cn
- name: prepare 1.19 docs
run: |
make prepare\#19
#prepare-zh-cn\#19
make prepare-zh-cn\#19
- name: cleanup before build
run: |
rm static/_*

4
.gitignore vendored
View File

@ -25,4 +25,6 @@ versioned_docs/
static/_headers
static/_redirects
static/latest-swagger.json
static/19-swagger.json
static/19-swagger.json
i18n/zh-cn/docusaurus-plugin-content-docs/current
i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19

View File

@ -27,12 +27,13 @@ prepare-latest: clone_main
bash loop_docs.sh
.PHONY: prepare-latest-zh-cn
prepare-latest-zh-cn: clone_main
cp -r .tmp/upstream-docs-latest/docs/static/* static/
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/doc/ docs/zh-cn/
cp .tmp/upstream-docs-latest/docs/content/page/index.zh-cn.md docs/zh-cn/intro.md
prepare-latest-zh-cn:
# clone_main
# cp -r .tmp/upstream-docs-latest/docs/static/* static/
mkdir -p i18n/zh-cn/docusaurus-plugin-content-docs/current
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/doc/ i18n/zh-cn/docusaurus-plugin-content-docs/current/
cp .tmp/upstream-docs-latest/docs/content/page/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
bash loop_docs-zh-cn.sh
rm docs/zh-cn/help/search.zh-cn.md || true
.PHONY: clone_\#%
clone_\#%: create_dir
@ -48,15 +49,17 @@ prepare\#%: clone_\#%
cp .tmp/upstream-docs-$*/docs/content/page/index.en-us.md versioned_docs/version-1.$*/intro.md
cp .tmp/upstream-docs-$*/templates/swagger/v1_json.tmpl static/$*-swagger.json
bash loop_docs-$*.sh
rm versioned_docs/version-1.$*/help/search.en-us.md || true
rm versioned_docs/version-1.$*/help/search.md || true
.PHONY: prepare-zh-cn\#%
prepare-zh-cn\#%: clone_\#%
cp -r .tmp/upstream-docs-$*/docs/static/* static/
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/doc/ versioned_docs/version-1.$*/zh-cn/
cp .tmp/upstream-docs-19/docs/content/page/index.zh-cn.md versioned_docs/version-1.$*/zh-cn/intro.md
prepare-zh-cn\#%:
# clone_\#%
# cp -r .tmp/upstream-docs-$*/docs/static/* static/
mkdir -p i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/doc/ i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/
cp .tmp/upstream-docs-19/docs/content/page/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/intro.md
bash loop_docs-$*-zh-cn.sh
rm versioned_docs/version-1.$*/zh-cn/help/search.zh-cn.md || true
rm i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/help/search.md || true
.PHONY: install
install:

View File

@ -13,3 +13,28 @@ make build
make clean
make serve
```
## Test en version
```
npm run start
```
## Test zh-cn version
```
npm run start -- --locale zh-cn
```
## Translate presets for zh-cn version
```
npx docusaurus write-translations --locale zh-cn
```
## Test both zh-cn and en versions
```
npm run build
npm run serve
```

View File

@ -25,7 +25,16 @@ const config = {
i18n: {
defaultLocale: 'en',
locales: ['en'/*, 'zh-cn', 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
locales: ['en', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
localeConfigs: {
'en': {
label: 'English',
htmlLang: 'en-US',
},
'zh-cn': {
label: '中文',
},
},
},
presets: [
@ -71,7 +80,7 @@ const config = {
"@easyops-cn/docusaurus-search-local",
{
hashed: false,
language: ["en"],
language: ["en", "zh"],
highlightSearchTermsOnTargetPage: true,
explicitSearchResultPath: true,
indexBlog: false,
@ -113,10 +122,10 @@ const config = {
type: 'search',
position: 'right',
},
/* {
{
type: 'localeDropdown',
position: 'right',
},*/
},
{
type: 'docsVersionDropdown',
position: 'right',

View File

@ -0,0 +1,29 @@
{
"sidebar.docs.category.Installation": {
"message": "安装"
},
"sidebar.docs.category.Administration": {
"message": "管理"
},
"sidebar.docs.category.Usage": {
"message": "使用"
},
"sidebar.docs.category.actions": {
"message": "Actions"
},
"sidebar.docs.category.packages": {
"message": "软件包"
},
"sidebar.docs.category.Development": {
"message": "开发"
},
"sidebar.docs.category.Contributing": {
"message": "贡献"
},
"sidebar.docs.category.Help": {
"message": "帮助"
},
"sidebar.docs.doc.What is Gitea?": {
"message": "Gitea是什么?"
}
}

View File

@ -0,0 +1,26 @@
{
"sidebar.docs.category.Installation": {
"message": "安装"
},
"sidebar.docs.category.Administration": {
"message": "管理"
},
"sidebar.docs.category.Usage": {
"message": "使用"
},
"sidebar.docs.category.Packages": {
"message": "软件包"
},
"sidebar.docs.category.Development": {
"message": "开发"
},
"sidebar.docs.category.Contributing": {
"message": "贡献"
},
"sidebar.docs.category.Help": {
"message": "帮助"
},
"sidebar.docs.doc.What is Gitea?": {
"message": "Gitea是什么?"
}
}

View File

@ -0,0 +1,34 @@
{
"link.title.Docs": {
"message": "文档",
"description": "The title of the footer links column with title=Docs in the footer"
},
"link.title.Community": {
"message": "社区",
"description": "The title of the footer links column with title=Community in the footer"
},
"link.title.More": {
"message": "更多",
"description": "The title of the footer links column with title=More in the footer"
},
"link.item.label.Tutorial": {
"message": "教程",
"description": "The label of footer link with label=Tutorial linking to /"
},
"link.item.label.Code": {
"message": "开源代码",
"description": "The label of footer link with label=Code linking to https://github.com/go-gitea/gitea"
},
"link.item.label.Stack Overflow": {
"message": "Stack Overflow",
"description": "The label of footer link with label=Stack Overflow linking to https://stackoverflow.com/questions/tagged/gitea"
},
"link.item.label.Discord": {
"message": "Discord",
"description": "The label of footer link with label=Discord linking to https://discord.gg/gitea"
},
"link.item.label.Twitter": {
"message": "Twitter",
"description": "The label of footer link with label=Twitter linking to https://twitter.com/giteaio"
}
}

View File

@ -0,0 +1,14 @@
{
"title": {
"message": "Gitea"
},
"item.label.Docs": {
"message": "开源文档"
},
"item.label.Code": {
"message": "代码"
},
"item.label.Support": {
"message": "支持"
}
}

View File

@ -8,44 +8,47 @@ else
SED_INPLACE="sed -i ''"
fi
$SED_INPLACE 's/</<&#8288;/' versioned_docs/version-1.19/zh-cn/installation/with-docker.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' versioned_docs/version-1.19/zh-cn/installation/with-docker.zh-cn.md
$SED_INPLACE 's/</<&#8288;/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/installation/with-docker.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/installation/with-docker.zh-cn.md
$SED_INPLACE 's/</<&#8288;/' versioned_docs/version-1.19/zh-cn/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/</&#8288;/' versioned_docs/version-1.19/zh-cn/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' versioned_docs/version-1.19/zh-cn/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/</<&#8288;/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/</&#8288;/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' versioned_docs/version-1.19/zh-cn/administration/config-cheat-sheet.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/administration/config-cheat-sheet.zh-cn.md
$SED_INPLACE 's/^url:.*//' versioned_docs/version-1.19/zh-cn/intro.md
$SED_INPLACE 's/^title:.*/displayed_sidebar: siderBarCN/' versioned_docs/version-1.19/zh-cn/intro.md
$SED_INPLACE 's/^slug:.*/slug: \/zh-cn\//' versioned_docs/version-1.19/zh-cn/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' versioned_docs/version-1.19/zh-cn/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/^url:.*//' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/"version":.*/"version":"1.19.0"/' static/19-swagger.json
for file in `find ./versioned_docs/version-1.19/zh-cn/ -name "*.md"`; do
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/ -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.19.0/g' $file
$SED_INPLACE 's/{{< relref "doc/\/docs\/zh-cn/g' $file
$SED_INPLACE 's/{{< relref "doc/i18n\/zh-cn\/docusaurus-plugin-content-docs\/version-1.19/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 versioned_docs/version-1.19/zh-cn/*; do
for file in i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/*; do
if [ -d $file ]; then
continue
fi
if [ "$file" == "versioned_docs/version-1.19/zh-cn/intro.md" ]; then
if [ "$file" == "i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/intro.md" ]; then
continue
fi
rm $file
done
# for file in `find ./versioned_docs/version-1.19/zh-cn/ -name "*.md"`; do
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/ -name "*.zh-cn.md"`; do
mv "${file}" "${file/.zh-cn/}"
done
# for file in `find ./version ed_docs/version-1.19/zh-cn/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done

View File

@ -10,7 +10,6 @@ fi
$SED_INPLACE 's/<empty/<&#8288;empty/' versioned_docs/version-1.19/administration/config-cheat-sheet.en-us.md
$SED_INPLACE 's/^url:.*//' versioned_docs/version-1.19/intro.md
$SED_INPLACE 's/^title:.*/displayed_sidebar: defaultSidebar/' versioned_docs/version-1.19/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' versioned_docs/version-1.19/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' versioned_docs/version-1.19/development/hacking-on-gitea.en-us.md
@ -20,7 +19,7 @@ for file in `find ./versioned_docs/version-1.19/ -name "*.md"`; do
# hide hugo toc
$SED_INPLACE 's/{{< toc >}}//' $file
$SED_INPLACE 's/{{< version >}}/1.19.3/g' $file
$SED_INPLACE 's/{{< relref "doc/\/docs/g' $file
$SED_INPLACE 's/{{< relref "doc/versioned_docs\/version-1.19/g' $file
$SED_INPLACE 's/" >}}//g' $file
$SED_INPLACE 's/\*\*Table of Contents\*\*//' $file
$SED_INPLACE 's/weight:/sidebar_position:/g' $file
@ -38,3 +37,7 @@ for file in versioned_docs/version-1.19/*; do
fi
rm $file
done
for file in `find ./versioned_docs/version-1.19/ -name "*.en-us.md"`; do
mv "${file}" "${file/.en-us/}"
done

View File

@ -8,45 +8,47 @@ else
SED_INPLACE="sed -i ''"
fi
$SED_INPLACE 's/</<&#8288;/' docs/zh-cn/installation/with-docker.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' docs/zh-cn/installation/with-docker.zh-cn.md
$SED_INPLACE 's/</<&#8288;/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/with-docker.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/with-docker.zh-cn.md
$SED_INPLACE 's/</<&#8288;/' docs/zh-cn/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/</&#8288;/' docs/zh-cn/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' docs/zh-cn/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/</<&#8288;/' i18n/zh-cn/docusaurus-plugin-content-docs/current/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/</&#8288;/' i18n/zh-cn/docusaurus-plugin-content-docs/current/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' i18n/zh-cn/docusaurus-plugin-content-docs/current/contributing/guidelines-backend.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;empty/' docs/zh-cn/administration/config-cheat-sheet.zh-cn.md
$SED_INPLACE 's/<empty/<&#8288;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

View File

@ -13,7 +13,6 @@ $SED_INPLACE 's/<empty/<&#8288;empty/' docs/contributing/guidelines-backend.en-u
$SED_INPLACE 's/</<&#8288;/' docs/contributing/guidelines-backend.en-us.md
$SED_INPLACE 's/</&#8288;/' docs/contributing/guidelines-backend.en-us.md
$SED_INPLACE 's/^url:.*//' docs/intro.md
$SED_INPLACE 's/^title:.*/displayed_sidebar: defaultSidebar/' docs/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' docs/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' docs/development/hacking-on-gitea.en-us.md
@ -23,7 +22,7 @@ for file in `find ./docs/ -name "*.md"`; do
# hide hugo toc
$SED_INPLACE 's/{{< toc >}}//' $file
$SED_INPLACE 's/{{< version >}}/main-nightly/g' $file
$SED_INPLACE 's/{{< relref "doc/\/docs/g' $file
$SED_INPLACE 's/{{< relref "doc/i18n\/en\/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
@ -39,3 +38,7 @@ for file in docs/*; do
fi
rm $file || true
done
for file in `find ./docs/ -name "*.en-us.md"`; do
mv "${file}" "${file/.en-us/}"
done

View File

@ -1,146 +1,87 @@
module.exports = {
defaultSidebar: [
docs: [
{
type: 'link',
type: 'doc',
id: 'intro',
label: 'What is Gitea?',
href: '/next/'
},
{
type: 'category',
label: 'Installation',
link: {
"type": "generated-index"
},
items: [
{
{
type: 'autogenerated',
dirName: 'installation',
}
}
]
},
{
type: 'category',
label: 'Administration',
link: {
"type": "generated-index"
},
items: [
{
{
type: 'autogenerated',
dirName: 'administration',
}
}
]
},
{
type: 'category',
label: 'Usage',
link: {
"type": "generated-index"
},
items: [
{
type: 'autogenerated',
dirName: 'usage',
}
{
type: 'autogenerated',
dirName: 'usage',
}
]
},
{
type: 'category',
label: 'Development',
link: {
"type": "generated-index"
},
items: [
{
{
type: 'autogenerated',
dirName: 'development',
}
}
]
},
{
type: 'category',
label: 'Contributing',
link: {
"type": "generated-index"
},
items: [
{
{
type: 'autogenerated',
dirName: 'contributing',
}
}
]
},
{
type: 'category',
label: 'Help',
link: {
"type": "generated-index"
},
items: [
{
{
type: 'autogenerated',
dirName: 'help',
}
}
]
},
]/*,
siderBarCN: [
{
type: 'link',
label: 'Gitea是什么',
href: 'zh-cn/next/'
},
{
type: 'category',
label: '安装',
items: [
{
type: 'autogenerated',
dirName: 'zh-cn/installation',
}
]
},
{
type: 'category',
label: '管理',
items: [
{
type: 'autogenerated',
dirName: 'zh-cn/administration',
}
]
},
{
type: 'category',
label: '使用',
items: [
{
type: 'category',
label: '软件包管理',
items: [
{
type: 'autogenerated',
dirName: 'zh-cn/usage/packages',
}
]
},
{
type: 'autogenerated',
dirName: 'zh-cn/usage',
}
]
},
{
type: 'category',
label: '开发',
items: [
{
type: 'autogenerated',
dirName: 'zh-cn/development',
}
]
},
{
type: 'category',
label: '贡献',
items: [
{
type: 'autogenerated',
dirName: 'zh-cn/contributing',
}
]
},
{
type: 'category',
label: '帮助',
items: [
{
type: 'autogenerated',
dirName: 'zh-cn/help',
}
]
},
],*/
]
};

View File

@ -1,13 +1,16 @@
{
"defaultSidebar": [
"docs": [
{
"type": "link",
"label": "What is Gitea?",
"href": "/"
"type": "doc",
"id": "intro",
"label": "What is Gitea?"
},
{
"type": "category",
"label": "Installation",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
@ -18,6 +21,9 @@
{
"type": "category",
"label": "Administration",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
@ -28,6 +34,9 @@
{
"type": "category",
"label": "Usage",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "category",
@ -48,6 +57,9 @@
{
"type": "category",
"label": "Development",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
@ -58,6 +70,9 @@
{
"type": "category",
"label": "Contributing",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
@ -68,6 +83,9 @@
{
"type": "category",
"label": "Help",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",