Files
twenty/packages/twenty-docs/scripts/fix-translated-links.sh
T
Abdul Rahman d19b7f8485 Enable getting started translations (#21842)
## Summary

The Getting Started pages on the docs site (docs.twenty.com) were only
ever available in English, never translated into the other supported
languages.

**Root cause:** The Getting Started section (added in #19728) was never
added to the Crowdin source config (`crowdin-docs.yml`), so its `.mdx`
files were never uploaded for translation. Only `user-guide`,
`developers`, and `twenty-ui` were configured.

This also surfaced a related bug: because the pages had no translations,
the navigation generator fell back to the English page path for every
language, duplicating paths like `getting-started/introduction` across
all 14 language navs. Mintlify treats duplicate cross-language paths as
undefined behavior, which broke the language switcher (it always
redirected to `/getting-started/introduction`).

## Changes

- `.github/crowdin-docs.yml` — add `getting-started/**/*.mdx` as a
translation source so the pages get sent to Crowdin.
- `packages/twenty-docs/scripts/fix-translated-links.sh` — add
`getting-started` link-rewriting rules to match the other sections.
- `packages/twenty-docs/scripts/generate-docs-json.ts` — only include a
page in a non-default language when its translated file exists; drop
empty groups/tabs (removes the duplicate cross-language paths that broke
the switcher).
- `packages/twenty-docs/docs.json` — regenerated.



<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21842?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-19 14:16:17 +02:00

63 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Post-processing script to fix internal links in translated documentation
# This script adds the locale prefix to all internal documentation links
# Works for any language by automatically detecting language directories
set -e
if [ -d "packages/twenty-docs" ]; then
DOCS_DIR="packages/twenty-docs/l"
elif [ -d "l" ]; then
DOCS_DIR="l"
else
echo "❌ Error: Cannot find locales directory (l/)"
exit 1
fi
echo "🔧 Fixing internal links in translated documentation..."
for lang_dir in "$DOCS_DIR"/*/ ; do
lang_code=$(basename "$lang_dir")
if [ ! -d "$lang_dir" ] || [ -z "$(ls -A "$lang_dir")" ]; then
continue
fi
echo "📝 Processing $lang_code documentation..."
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|href=\"/getting-started/|href=\"/l/$lang_code/getting-started/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|href=\"/user-guide/|href=\"/l/$lang_code/user-guide/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|href=\"/developers/|href=\"/l/$lang_code/developers/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|href=\"/twenty-ui/|href=\"/l/$lang_code/twenty-ui/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|](/getting-started/|](/l/$lang_code/getting-started/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|](/user-guide/|](/l/$lang_code/user-guide/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|](/developers/|](/l/$lang_code/developers/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|](/twenty-ui/|](/l/$lang_code/twenty-ui/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|https://docs\.twenty\.com/getting-started/|https://docs.twenty.com/l/$lang_code/getting-started/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|https://docs\.twenty\.com/user-guide/|https://docs.twenty.com/l/$lang_code/user-guide/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|https://docs\.twenty\.com/developers/|https://docs.twenty.com/l/$lang_code/developers/|g" {} \;
find "$lang_dir" -name "*.mdx" -type f -exec sed -i.bak \
"s|https://docs\.twenty\.com/twenty-ui/|https://docs.twenty.com/l/$lang_code/twenty-ui/|g" {} \;
find "$lang_dir" -name "*.bak" -type f -delete
echo "$lang_code documentation links fixed"
done
echo "🎉 All translated links have been fixed!"