120 add option to remove translation keys that only exists on kanta translations table#131
Merged
vincentvanbush merged 9 commits intodevelopfrom Oct 24, 2025
Conversation
…translation-keys-that-only-exists-on-kanta__translations-table Merge with latest gwttext verion
…ality (#120) Add stale translation detection system with a modular architecture: - New service structure for stale messages detection - Added fuzzy matching algorithm to detect similar messages based on edit distance - Implemented message merging to preserve translations from stale messages Enhanced UI with bulk operations: - Dashboard now shows stale and mergeable message counts - Added bulk merge and delete operations for stale translations - Updated translations table with merge/delete actions Added comprehensive test coverage for stale detection and message merging.
…remove-translation-keys-that-only-exists-on-kanta__translations-table
vincentvanbush
requested changes
Oct 23, 2025
lib/kanta_web/live/translations/translations_live/components/messages_table/messages_table.ex
Show resolved
Hide resolved
lib/kanta_web/live/translations/translations_live/components/messages_table/messages_table.ex
Show resolved
Hide resolved
jk-lamb
commented
Oct 23, 2025
Contributor
Author
jk-lamb
left a comment
There was a problem hiding this comment.
All of the requested changes applied.
- Replace Keyword.merge chain on empty list with direct keyword list syntax
- Move require Logger to module level and remove debug logging from event handlers
- Unify MessagesExtractor.call() API to return {:ok, result} for consistency with StaleDetection.call()
- Fix unused variable warnings by prefixing with underscore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Add stale translation detection system with fuzzy matching and merge functionality. This feature allows users to identify translations that exist in the database but are no longer in PO files, and provides tools to either merge them with similar messages (preserving translations) or delete them entirely through the UI.
Type of Change
Related Issues
Closes #120 #127 #130
Changes Made
Core Functionality
StaleDetectionserviceKanta.Translations.merge_messages/2to preserve translations when merging stale messages with active onesUI Enhancements
Testing
StaleDetectionservice (Kanta.PoFiles.Services.StaleDetectionTest)Testing
Test Environment
Test Cases
Test Commands Run
Documentation
Code Quality
Backward Compatibility
Breaking Changes
None. This is a purely additive feature that doesn't modify existing APIs or database schema.
Performance Impact
Performance Notes
The fuzzy matching algorithm uses Jaro distance calculation which is O(n*m) complexity, but it's only triggered on-demand when users navigate to the stale translations view. The results are presented in the UI for user action, not executed automatically. Matches are scoped by domain and context to reduce the comparison space.
Translation Management Impact
Translation Impact Notes
Security Considerations
Additional Notes
Key Implementation Details
Fuzzy Matching Algorithm:
The fuzzy matching uses Jaro distance (
String.jaro_distance/2) to calculate similarity between messages. The threshold is configurable (default 0.8 similarity ratio), allowing users to control how strict the matching should be. Matches are scoped by domain and context for relevance.Modular Architecture:
Kanta.PoFiles.Services.StaleDetection- Main service module withcall/1functionKanta.PoFiles.Services.StaleDetection.FuzzyMatch- Struct representing a fuzzy match resultKanta.PoFiles.Services.StaleDetection.Result- Structured result type for detection operationsKanta.PoFiles.MessagesExtractorAgent- GenServer that caches stale detection results for UI performanceCaching Strategy:
The
MessagesExtractorAgentruns stale detection on startup and caches the result. The UI callsget_stale_detection_result()to get cached results (fast) orget_stale_detection_result(true)to force recalculation after merge/delete operations.UI Workflow:
Screenshots/Examples
Stale Detection API Usage
Recommended: Using MessagesExtractorAgent (with caching)
Direct Service Call (lower-level API)
Result Structure
Message Merging Example
Dashboard Integration
Checklist
Reviewer Notes
Please pay special attention to:
lib/kanta/po_files/services/stale_detection.ex- verify the Jaro distance implementation and domain/context scopinglib/kanta/translations/messages/messages.ex(merge_messages/2function) - verify that translations are correctly moved and edge cases are handledtest/kanta/po_files/services/stale_detection_test.exsandtest/kanta/translations/messages/merge_test.exs