-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalidate-translations.sh
More file actions
executable file
·131 lines (111 loc) · 3.52 KB
/
Copy pathvalidate-translations.sh
File metadata and controls
executable file
·131 lines (111 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# validate-translations.sh
# Validates translated documentation files for common issues
# Usage: ./scripts/validate-translations.sh [--fix]
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
ERRORS=0
WARNINGS=0
echo "=========================================="
echo " Translation Validation Script"
echo "=========================================="
echo ""
# Function to check Portuguese accents
check_portuguese_accents() {
local file="$1"
local issues=0
# Check for unaccented -cao words (should be -ção)
if grep -qE '\b[a-zA-Z]+cao\b' "$file" 2>/dev/null; then
echo -e "${RED}ERROR:${NC} $file contains unaccented -cao words (should be -ção)"
grep -nE '\b[a-zA-Z]+cao\b' "$file" | head -5
((issues++))
fi
# Check for unaccented -coes words (should be -ções)
if grep -qE '\b[a-zA-Z]+coes\b' "$file" 2>/dev/null; then
echo -e "${RED}ERROR:${NC} $file contains unaccented -coes words (should be -ções)"
grep -nE '\b[a-zA-Z]+coes\b' "$file" | head -5
((issues++))
fi
# Check for common unaccented words
if grep -qwE 'voce|versao|metodo|secao|opcao|sessao|Portugues' "$file" 2>/dev/null; then
echo -e "${RED}ERROR:${NC} $file contains common unaccented Portuguese words"
grep -nwE 'voce|versao|metodo|secao|opcao|sessao|Portugues' "$file" | head -5
((issues++))
fi
return $issues
}
# Function to check language selector consistency
check_language_selector() {
local file="$1"
local expected_langs=("English" "한국어" "中文" "日本語" "Español" "Português")
local issues=0
for lang in "${expected_langs[@]}"; do
if ! grep -q "$lang" "$file" 2>/dev/null; then
echo -e "${YELLOW}WARNING:${NC} $file missing language selector for: $lang"
((issues++))
fi
done
return $issues
}
# Function to check AI disclaimer
check_ai_disclaimer() {
local file="$1"
local dir=$(dirname "$file")
local issues=0
# Skip English files (no disclaimer needed)
if [[ "$dir" == "docs" || "$dir" == "./docs" ]]; then
return 0
fi
if ! grep -q "🤖" "$file" 2>/dev/null; then
echo -e "${YELLOW}WARNING:${NC} $file missing AI translation disclaimer"
((issues++))
fi
return $issues
}
# Main validation
echo "Checking Portuguese translations..."
echo "-----------------------------------"
for file in docs/pt-BR/plugin-*.md; do
if [[ -f "$file" ]]; then
check_portuguese_accents "$file"
ERRORS=$((ERRORS + $?))
fi
done
echo ""
echo "Checking language selectors..."
echo "------------------------------"
for file in docs/plugin-*.md docs/*/plugin-*.md; do
if [[ -f "$file" ]]; then
check_language_selector "$file"
WARNINGS=$((WARNINGS + $?))
fi
done
echo ""
echo "Checking AI disclaimers..."
echo "--------------------------"
for file in docs/*/plugin-*.md; do
if [[ -f "$file" ]]; then
check_ai_disclaimer "$file"
WARNINGS=$((WARNINGS + $?))
fi
done
echo ""
# Summary
echo "=========================================="
echo " Validation Summary"
echo "=========================================="
if [[ $ERRORS -eq 0 && $WARNINGS -eq 0 ]]; then
echo -e "${GREEN}All checks passed!${NC}"
exit 0
elif [[ $ERRORS -eq 0 ]]; then
echo -e "${YELLOW}Warnings: $WARNINGS${NC}"
echo -e "${GREEN}Errors: 0${NC}"
exit 0
else
echo -e "${RED}Errors: $ERRORS${NC}"
echo -e "${YELLOW}Warnings: $WARNINGS${NC}"
exit 1
fi