#!/bin/bash # Find duplicate translation keys across FTL files in the smokesignal i18n directory echo "🔍 Finding duplicate FTL keys in smokesignal project..." echo "==================================================" cd /root/smokesignal # Check for duplicates in each locale for locale in "en-us" "fr-ca"; do echo "" echo "📍 Checking locale: $locale" echo "------------------------" # Extract all keys from all .ftl files in this locale temp_file="/tmp/ftl_keys_${locale}.txt" # Find all .ftl files and extract keys (lines that start with a word followed by =) find "i18n/$locale" -name "*.ftl" -exec grep -H "^[a-zA-Z][a-zA-Z0-9_-]*[[:space:]]*=" {} \; | \ sed 's/^\([^:]*\):\([^=]*\)=.*/\2|\1/' | \ sort > "$temp_file" echo "Keys found: $(wc -l < "$temp_file")" # Find duplicates duplicates=$(cut -d'|' -f1 "$temp_file" | sort | uniq -d) if [ ! -z "$duplicates" ]; then echo "❌ DUPLICATE KEYS FOUND:" for key in $duplicates; do echo "" echo " 🔑 Key: $key" grep "^$key|" "$temp_file" | while IFS='|' read -r duplicate_key file_path; do line_num=$(grep -n "^$duplicate_key[[:space:]]*=" "$file_path" | cut -d: -f1) echo " 📄 $file_path:$line_num" done done else echo "✅ No duplicates found in $locale" fi # Clean up rm -f "$temp_file" done echo "" echo "🏁 Duplicate check complete!"