This repository was archived by the owner on Apr 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 597
Expand file tree
/
Copy pathmake_lang
More file actions
executable file
·50 lines (43 loc) · 1.62 KB
/
make_lang
File metadata and controls
executable file
·50 lines (43 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# coding=utf-8
# Powered by https://github.com/alan3344/website
# Automatically create translation directory structure, files to be translated,
# and `React Translate/translate()` tags for the project
lang=$1
override=$2
color() {
echo "\033[0;$1m${@:2}\033[0m"
}
if [[ "$@" =~ "-h" ]] || [[ "$@" =~ "--help" ]]; then
echo Usage: "$(color 33 ./mkdir_lang) <$(color 32 language)> [$(color 31 --override)]"
echo " $(color 32 language) \t$(color 33 Required) The language name."
echo " $(color 31 --override) \t$(color 33 Optional) Override the existing files."
echo " $(color 33 -h --help) \t$(color 33 Optional) Show this help message."
echo
echo "$(color 33 Example): $(color 32 ./mkdir_lang) $(color 31 zh-CN)"
exit 0
fi
if [ -z "$lang" ]; then
echo "$(color 31 Error): $(color 33 language) is required."
echo "Try '$(color 32 ./mkdir_lang --help)' for more information."
exit 1
fi
if [ "$override" = "--override" ]; then
override="--override"
else
override=""
fi
mkdir -p i18n/$lang/docusaurus-plugin-content-blog/
mkdir -p i18n/$lang/docusaurus-plugin-content-docs/
mkdir -p i18n/$lang/docusaurus-plugin-content-pages/
mkdir -p i18n/$lang/docusaurus-theme-classic/
npx docusaurus write-translations --locale $lang $override
if [ "$override" = "--override" ]; then
override=""
else
override="-n"
fi
cp -r $override blog/* i18n/$lang/docusaurus-plugin-content-blog/
cp -r $override docs/* i18n/$lang/docusaurus-plugin-content-docs/
cp -r $override src/pages/* i18n/$lang/docusaurus-plugin-content-pages/
cp -r $override src/theme/* i18n/$lang/docusaurus-theme-classic/