How the semantic-commit command detects project language
mainThe semantic-commit command automatically determines whether to generate commit messages in Portuguese (pt) or English (en) using a scoring algorithm. It analyzes several signals to decide the language:
- CommitLint Configuration (+3 points): If
subject-caseis disabled (set to[0]) incommitlint.config.*, it strongly suggests Portuguese support. - Git Log Analysis (up to +2 points): It checks the last 20 commits. If a significant portion contains Portuguese linguistic markers (e.g.,
ção,ões,agem), points are awarded. - README.md Content (+1 point): It scans the first few lines of the
README.mdfor Portuguese markers. - Changed Files Content (+1 point): It scans the
git diffof current changes for Portuguese comments or strings.
Threshold: A score of 3 or more triggers Portuguese mode (pt). Otherwise, it defaults to English (en).
# Example of scoring logic (conceptual)
# 3 points or more = Portuguese mode
# Less than 3 = English mode