#!/bin/sh
# Keeps German code out of this repository — the same rule as in the dashboard
# (its CLAUDE.md). The checker is borrowed from the dashboard this repository is
# a submodule of; CODE_LANGUAGE_ROOT points it at our files, and words only we
# may use (the Java class names of the .fls format) stand in
# scripts/code_language_allow.txt.
#
# Enable:  npm run hooks
# Bypass:  git commit --no-verify
top="$(git rev-parse --show-toplevel)"
super="$(git rev-parse --show-superproject-working-tree 2>/dev/null)"
checker="$super/scripts/check_code_language.py"
if [ -z "$super" ] || [ ! -f "$checker" ]; then
    echo "pre-commit: not inside the dashboard checkout, language check skipped"
    exit 0
fi
CODE_LANGUAGE_ROOT="$top" python3 "$checker" --changed HEAD || {
    echo
    echo "German code in the commit. Glossary: knowledge/plans/CODE_ENGLISH_REFACTOR.md §3 (dashboard)"
    echo "Commit anyway: git commit --no-verify"
    exit 1
}
