Skip to content

Commit d9fd873

Browse files
superdav42claude
andcommitted
Reduce locales to en + es for faster builds
Building 115 locales takes 1+ hour. Only build locales with actual translations. Add parallel-build.sh for future use. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 750bc7b commit d9fd873

2 files changed

Lines changed: 108 additions & 12 deletions

File tree

docusaurus.config.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@ const config = {
2121
defaultLocale: 'en',
2222
locales: [
2323
'en',
24-
'af', 'am', 'ar', 'as', 'az', 'azb', 'be', 'bg', 'bn', 'bs',
25-
'ca', 'ceb', 'ckb', 'cs', 'cy', 'da', 'de', 'el', 'eo', 'es',
26-
'et', 'eu', 'fa', 'fi', 'fil', 'fr', 'ga', 'gd', 'gl', 'gu',
27-
'ha', 'he', 'hi', 'hmn', 'hr', 'ht', 'hu', 'hy', 'id', 'ig',
28-
'is', 'it', 'ja', 'jv', 'ka', 'kk', 'km', 'kn', 'ko', 'ku',
29-
'ky', 'la', 'lb', 'lo', 'lt', 'lv', 'mg', 'mi', 'mk', 'ml',
30-
'mn', 'mr', 'ms', 'mt', 'my', 'ne', 'nl', 'no', 'ny', 'or',
31-
'pa', 'pl', 'ps', 'pt', 'pt-BR', 'ro', 'ru', 'rw', 'sd', 'si',
32-
'sk', 'sl', 'sn', 'snd', 'so', 'sq', 'sr', 'st', 'su', 'sv',
33-
'sw', 'ta', 'te', 'tg', 'th', 'tk', 'tl', 'tr', 'tt', 'ug',
34-
'uk', 'ur', 'uz', 'vi', 'xh', 'yi', 'yo', 'zh-Hans', 'zh-Hant',
35-
'zu',
24+
'es',
25+
// Additional locales - uncomment as translations are added
26+
// 'af', 'am', 'ar', 'as', 'az', 'azb', 'be', 'bg', 'bn', 'bs',
27+
// 'ca', 'ceb', 'ckb', 'cs', 'cy', 'da', 'de', 'el', 'eo',
28+
// 'et', 'eu', 'fa', 'fi', 'fil', 'fr', 'ga', 'gd', 'gl', 'gu',
29+
// 'ha', 'he', 'hi', 'hmn', 'hr', 'ht', 'hu', 'hy', 'id', 'ig',
30+
// 'is', 'it', 'ja', 'jv', 'ka', 'kk', 'km', 'kn', 'ko', 'ku',
31+
// 'ky', 'la', 'lb', 'lo', 'lt', 'lv', 'mg', 'mi', 'mk', 'ml',
32+
// 'mn', 'mr', 'ms', 'mt', 'my', 'ne', 'nl', 'no', 'ny', 'or',
33+
// 'pa', 'pl', 'ps', 'pt', 'pt-BR', 'ro', 'ru', 'rw', 'sd', 'si',
34+
// 'sk', 'sl', 'sn', 'snd', 'so', 'sq', 'sr', 'st', 'su', 'sv',
35+
// 'sw', 'ta', 'te', 'tg', 'th', 'tk', 'tl', 'tr', 'tt', 'ug',
36+
// 'uk', 'ur', 'uz', 'vi', 'xh', 'yi', 'yo', 'zh-Hans', 'zh-Hant',
37+
// 'zu',
3638
],
3739
localeConfigs: {
3840
ar: {label: 'العربية', direction: 'rtl'},

scripts/parallel-build.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Parallel Docusaurus build script
5+
# Builds multiple locales in parallel to speed up the build process
6+
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
DOCS_DIR="$(dirname "$SCRIPT_DIR")"
9+
BUILD_DIR="$DOCS_DIR/build"
10+
PARALLEL_JOBS="${PARALLEL_JOBS:-4}" # Number of parallel builds
11+
12+
cd "$DOCS_DIR"
13+
14+
# Get all configured locales from docusaurus.config.js
15+
LOCALES=$(node -e "
16+
const config = require('./docusaurus.config.js');
17+
console.log(config.i18n.locales.join(' '));
18+
")
19+
20+
DEFAULT_LOCALE=$(node -e "
21+
const config = require('./docusaurus.config.js');
22+
console.log(config.i18n.defaultLocale);
23+
")
24+
25+
echo "=== Parallel Docusaurus Build ==="
26+
echo "Locales: $LOCALES"
27+
echo "Default: $DEFAULT_LOCALE"
28+
echo "Parallel jobs: $PARALLEL_JOBS"
29+
echo ""
30+
31+
# Create temp directory for parallel builds
32+
TEMP_BUILD_DIR=$(mktemp -d)
33+
trap "rm -rf $TEMP_BUILD_DIR" EXIT
34+
35+
# Build function for a single locale
36+
build_locale() {
37+
local locale=$1
38+
local out_dir="$TEMP_BUILD_DIR/$locale"
39+
40+
echo "[START] Building locale: $locale"
41+
42+
if npx docusaurus build --locale "$locale" --out-dir "$out_dir" 2>&1 | grep -E "^\[(SUCCESS|ERROR)\]|error|Error" || true; then
43+
echo "[DONE] $locale"
44+
else
45+
echo "[DONE] $locale"
46+
fi
47+
}
48+
49+
export -f build_locale
50+
export TEMP_BUILD_DIR
51+
export DOCS_DIR
52+
53+
# Run builds in parallel
54+
START_TIME=$(date +%s)
55+
56+
echo "$LOCALES" | tr ' ' '\n' | xargs -P "$PARALLEL_JOBS" -I {} bash -c 'build_locale "$@"' _ {}
57+
58+
END_TIME=$(date +%s)
59+
ELAPSED=$((END_TIME - START_TIME))
60+
61+
echo ""
62+
echo "=== Merging builds ==="
63+
64+
# Merge all builds into final build directory
65+
rm -rf "$BUILD_DIR"
66+
mkdir -p "$BUILD_DIR"
67+
68+
for locale_dir in "$TEMP_BUILD_DIR"/*/; do
69+
locale=$(basename "$locale_dir")
70+
echo "Merging $locale..."
71+
72+
if [[ "$locale" == "$DEFAULT_LOCALE" ]]; then
73+
# Default locale goes to root
74+
cp -r "$locale_dir"/* "$BUILD_DIR/" 2>/dev/null || true
75+
else
76+
# Other locales go to their subdirectory
77+
if [[ -d "$locale_dir/$locale" ]]; then
78+
cp -r "$locale_dir/$locale" "$BUILD_DIR/" 2>/dev/null || true
79+
fi
80+
fi
81+
done
82+
83+
# Copy shared assets (from default locale build)
84+
if [[ -d "$TEMP_BUILD_DIR/$DEFAULT_LOCALE/assets" ]]; then
85+
cp -r "$TEMP_BUILD_DIR/$DEFAULT_LOCALE/assets" "$BUILD_DIR/" 2>/dev/null || true
86+
fi
87+
if [[ -d "$TEMP_BUILD_DIR/$DEFAULT_LOCALE/img" ]]; then
88+
cp -r "$TEMP_BUILD_DIR/$DEFAULT_LOCALE/img" "$BUILD_DIR/" 2>/dev/null || true
89+
fi
90+
91+
echo ""
92+
echo "=== Build complete ==="
93+
echo "Total time: ${ELAPSED}s"
94+
echo "Output: $BUILD_DIR"

0 commit comments

Comments
 (0)