Automatically copy missing translations (#32)

* Automatically copy missing translations

* Added all translations to config.yaml
This commit is contained in:
Thomas Boerger 2016-12-25 08:03:40 +01:00 коммит произвёл Lunny Xiao
Родитель c1787504eb
Коммит 2950590874
5 изменённых файлов: 133 добавлений и 1 удалений

Просмотреть файл

@ -6,6 +6,8 @@ pipeline:
image: webhippie/hugo:latest
pull: true
commands:
- make trans-copy
- make clean
- make build

Просмотреть файл

@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIHBhdGg6IHNyYwoKcGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogd2ViaGlwcGllL2h1Z286bGF0ZXN0CiAgICBwdWxsOiB0cnVlCiAgICBjb21tYW5kczoKICAgICAgLSBtYWtlIGNsZWFuCiAgICAgIC0gbWFrZSBidWlsZAoKICBjaGVja3M6CiAgICBpbWFnZTogd2ViaGlwcGllL2xpbmtjaGVja2VyOmxhdGVzdAogICAgY29tbWFuZHM6CiAgICAgIC0gbGlua2NoZWNrZXIgLXYgaHR0cDovL2xvY2FsaG9zdDo4MDgwCgogIGRvY2tlcjoKICAgIGltYWdlOiBwbHVnaW5zL2RvY2tlcgogICAgcmVwbzogZ2l0ZWEvZG9jcwogICAgdGFnczogWyAnJHtUQUd9JyBdCiAgICB3aGVuOgogICAgICBldmVudDogdGFnCiAgICAgIGJyYW5jaDogcmVmcy90YWdzLyoKCiAgZG9ja2VyOgogICAgaW1hZ2U6IHBsdWdpbnMvZG9ja2VyCiAgICByZXBvOiBnaXRlYS9kb2NzCiAgICB0YWdzOiBbICdsYXRlc3QnIF0KICAgIHdoZW46CiAgICAgIGV2ZW50OiBwdXNoCiAgICAgIGJyYW5jaDogbWFzdGVyCgogIGdpdHRlcjoKICAgIGltYWdlOiBwbHVnaW5zL2dpdHRlcgoKc2VydmljZXM6CiAgc2VydmVyOgogICAgaW1hZ2U6IHdlYmhpcHBpZS9jYWRkeTpsYXRlc3QKICAgIGNvbW1hbmQ6IFsvdX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TXLaOFBni1Dvr2aj8GRypI5Z3tBlvAbog

Просмотреть файл

@ -9,6 +9,10 @@ all: build
clean:
rm -rf $(PUBLIC) $(THEME)
.PHONY: trans-copy
trans-copy:
@bash scripts/trans-copy
.PHONY: server
server: $(THEME)
hugo server

Просмотреть файл

@ -51,6 +51,7 @@ languages:
en-us:
weight: 0
languageName: English
zh-cn:
weight: 1
languageName: 中文(简体)
@ -81,3 +82,96 @@ languages:
url: https://github.com/go-gitea/
weight: 60
pre: github
zh-tw:
weight: 2
languageName: 中文(繁體)
menu:
page:
- name: 網站
url: https://gitea.io/zh-tw/
weight: 10
pre: home
- name: 文件
url: /zh-tw/
weight: 20
pre: question
post: active
- name: 部落格
url: https://blog.gitea.io/
weight: 30
pre: rss
- name: 程式碼
url: https://code.gitea.io/
weight: 40
pre: code
- name: 下载
url: https://dl.gitea.io/
weight: 50
pre: download
- name: GitHub
url: https://github.com/go-gitea/
weight: 60
pre: github
pt-br:
weight: 3
languageName: Português Brasileiro
menu:
page:
- name: Página inicial
url: https://gitea.io/pt-br/
weight: 10
pre: home
- name: Documentação
url: /pt-br/
weight: 20
pre: question
post: active
- name: Blog
url: https://blog.gitea.io/
weight: 30
pre: rss
- name: Código-fonte
url: https://code.gitea.io/
weight: 40
pre: code
- name: Downloads
url: https://dl.gitea.io/
weight: 50
pre: download
- name: GitHub
url: https://github.com/go-gitea/
weight: 60
pre: github
nl-nl:
weight: 4
languageName: Nederlands
menu:
page:
- name: Website
url: https://gitea.io/nl-nl/
weight: 10
pre: home
- name: Docs
url: /nl-nl/
weight: 20
pre: question
post: active
- name: Blog
url: https://blog.gitea.io/
weight: 30
pre: rss
- name: Code
url: https://code.gitea.io/
weight: 40
pre: code
- name: Downloads
url: https://dl.gitea.io/
weight: 50
pre: download
- name: GitHub
url: https://github.com/go-gitea/
weight: 60
pre: github

32
scripts/trans-copy Executable file
Просмотреть файл

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -e
#
# This script is used to copy the en-US content to our available locales as a
# fallback to always show all pages when displaying a specific locale that is
# missing some documents to be translated.
#
# Just execute the script without any argument and you will get the missing
# files copied into the content folder. We are calling this script within the CI
# server simply by `make trans-copy`.
#
declare -a LOCALES=(
"nl-nl"
"pt-br"
"zh-cn"
"zh-tw"
)
ROOT=$(realpath $(dirname $0)/..)
for SOURCE in $(find ${ROOT}/content -type f -iname *.en-us.md); do
for LOCALE in "${LOCALES[@]}"; do
DEST="${SOURCE%.en-us.md}.${LOCALE}.md"
if [[ ! -f ${DEST} ]]; then
echo "Creating fallback for ${DEST#${ROOT}/content/}"
cp ${SOURCE} ${DEST}
fi
done
done