Skip to content

Refactor: Centralized Regex Patterns and Type-Safe i18n Implementation#60

Merged
thomas-vilte merged 1 commit into
masterfrom
dev
Dec 21, 2025
Merged

Refactor: Centralized Regex Patterns and Type-Safe i18n Implementation#60
thomas-vilte merged 1 commit into
masterfrom
dev

Conversation

@thomas-vilte
Copy link
Copy Markdown
Owner

@thomas-vilte thomas-vilte commented Dec 21, 2025

Overview

This PR implements a significant refactoring of the internal regex handling and internationalization (i18n) systems. I centralized all regular expressions into a dedicated package and replaced generic map-based translation data with structured types to enhance maintainability and runtime stability.

Key Changes

  • Regex Centralization: I created the internal/regex package, consolidating patterns for Conventional Commits, SemVer, GitHub/Jira links, and Go modules. This eliminates redundant regexp.MustCompile calls across the codebase.
  • Type-Safe Translations: I refactored the i18n.GetMessage method and its callers to use specific struct types instead of map[string]interface{}. This ensures that translation templates receive the correct fields at compile-time.
  • Standardized Progress Events: I introduced a concrete ProgressData struct in the models package to replace generic maps in ProgressEvent, providing a consistent schema for PR and commit generation feedback.
  • Localization Updates: I expanded the English and Spanish translation files to include missing keys for release management, editor handling, and Gemini API validation.
  • Cleanup: I removed the deprecated .mailmap file and corrected repository casing in the version checker to match the canonical GitHub path.

Technical Impact

  • Performance: Pre-compiling regex patterns in a single package reduces initialization overhead and memory allocations during command execution.
  • Robustness: Transitioning to structured data for i18n prevents common runtime bugs where translation keys are missing or incorrectly typed in the template data.
  • Maintainability: Centralizing patterns like GitHubClosedLink and JiraTicket makes it easier to update logic for different VCS or ticket providers in one place.

@thomas-vilte thomas-vilte changed the title refactor: centralize regex and enhance i18n type safety Refactor: Centralized Regex Patterns and Type-Safe i18n Implementation Dec 21, 2025
@thomas-vilte thomas-vilte added infra Infrastructure and DevOps refactor Code restructuring or cleaning without functional changes labels Dec 21, 2025
@thomas-vilte thomas-vilte merged commit 287291d into master Dec 21, 2025
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra Infrastructure and DevOps refactor Code restructuring or cleaning without functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant