#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

TARGETS=(
  "$ROOT_DIR/app/src/main/java/de/trainingstagebuch/app/ui/screens"
  "$ROOT_DIR/app/src/main/java/de/trainingstagebuch/app/ui/ErrorFeedback.kt"
  "$ROOT_DIR/app/src/main/java/de/trainingstagebuch/app/viewmodel"
)

# Guard against introducing hardcoded user-facing UI strings in Compose/viewmodel state handling.
PATTERN='Text\(\s*"[^"]*[[:alpha:]][^"]*"\s*\)|label\s*=\s*"[^"]*[[:alpha:]][^"]*"|title\s*=\s*"[^"]*[[:alpha:]][^"]*"'

if rg -n --pcre2 "$PATTERN" "${TARGETS[@]}"; then
  echo ""
  echo "Hardcoded UI strings gefunden. Bitte auf stringResource()/UiText umstellen."
  exit 1
fi

echo "i18n guard ok: keine hardcoded UI strings gefunden."
