Heavily customized version of smokesignal - https://whtwnd.com/kayrozen.com/3lpwe4ymowg2t
1#!/bin/bash
2
3# Find duplicate translation keys across FTL files in the smokesignal i18n directory
4
5echo "🔍 Finding duplicate FTL keys in smokesignal project..."
6echo "=================================================="
7
8cd /root/smokesignal
9
10# Check for duplicates in each locale
11for locale in "en-us" "fr-ca"; do
12 echo ""
13 echo "📍 Checking locale: $locale"
14 echo "------------------------"
15
16 # Extract all keys from all .ftl files in this locale
17 temp_file="/tmp/ftl_keys_${locale}.txt"
18
19 # Find all .ftl files and extract keys (lines that start with a word followed by =)
20 find "i18n/$locale" -name "*.ftl" -exec grep -H "^[a-zA-Z][a-zA-Z0-9_-]*[[:space:]]*=" {} \; | \
21 sed 's/^\([^:]*\):\([^=]*\)=.*/\2|\1/' | \
22 sort > "$temp_file"
23
24 echo "Keys found: $(wc -l < "$temp_file")"
25
26 # Find duplicates
27 duplicates=$(cut -d'|' -f1 "$temp_file" | sort | uniq -d)
28
29 if [ ! -z "$duplicates" ]; then
30 echo "❌ DUPLICATE KEYS FOUND:"
31 for key in $duplicates; do
32 echo ""
33 echo " 🔑 Key: $key"
34 grep "^$key|" "$temp_file" | while IFS='|' read -r duplicate_key file_path; do
35 line_num=$(grep -n "^$duplicate_key[[:space:]]*=" "$file_path" | cut -d: -f1)
36 echo " 📄 $file_path:$line_num"
37 done
38 done
39 else
40 echo "✅ No duplicates found in $locale"
41 fi
42
43 # Clean up
44 rm -f "$temp_file"
45done
46
47echo ""
48echo "🏁 Duplicate check complete!"