Prism: Candidate keys and parser fixes#684
Merged
Merged
Conversation
623b51a to
92ad3a1
Compare
a608416 to
6cd927d
Compare
- Adds separate used_keys_ruby_prism_spec, catching some errors in the used_tree layer after the parser. - Separates haml and slim specs into separate files. - Fixes visitor to skip calls to translate methods on non-I18n classes. - Removes candidate keys for views and mailers - Adds candidate keys for model_name.human and human_attribute_name.
6cd927d to
aed38d5
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the Prism-based translation scanner by fixing parser bugs, improving test organization, and adding candidate key support for Rails model methods. It ensures that only I18n module translation calls are processed, separates test specs by template type for better organization, and extends candidate key functionality to ActiveRecord model humanization methods while restricting them to controllers only.
- Fixes Prism visitor to skip
translatecalls on non-I18n receivers (e.g.,Service.translate(:key)) - Adds candidate keys for
model_name.humanandhuman_attribute_nameActiveRecord methods - Restricts candidate keys generation to controllers only (removes from views and mailers)
- Separates HAML and Slim specs into dedicated test files
- Adds comprehensive Ruby Prism spec file to catch parser layer errors
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/used_keys_slim_spec.rb | Removes HAML tests, keeping only Slim-specific tests; renames spec to "UsedKeysSlim" |
| spec/used_keys_haml_spec.rb | New file containing HAML-specific tests moved from Slim spec |
| spec/used_keys_ruby_prism_spec.rb | New comprehensive spec testing Ruby Prism parser with fixtures, including model method tests |
| spec/used_keys_erb_prism_spec.rb | Updates test expectations to include candidate_keys for all occurrences |
| spec/support/keys_and_occurrences.rb | Adds candidate_keys parameter to test helper methods |
| spec/prism_scanner_spec.rb | Adds ::I18n.t test case and candidate_keys expectations for model methods |
| lib/i18n/tasks/scanners/ruby_scanner.rb | Adds File.expand_path for JRuby compatibility in prism_parse_file |
| lib/i18n/tasks/scanners/prism_scanners/visitor.rb | Adds receiver check to skip non-I18n translate calls; adds candidate_keys to model methods |
| lib/i18n/tasks/scanners/prism_scanners/nodes.rb | Implements support_candidate_keys? method hierarchy; updates full_key logic for candidate_keys |
| lib/i18n/tasks/scanners/occurrence_from_position.rb | Adds candidate_keys parameter to occurrence_from_position method |
| lib/i18n/tasks/scanners/erb_ast_scanner.rb | Passes through candidate_keys when creating occurrences from ERB code and comments |
| CHANGES.md | Documents fixes for non-I18n receiver processing, candidate keys for model methods, and used_tree integration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
glebm
approved these changes
Nov 24, 2025
bart-westenenk-bex
pushed a commit
to bookingexperts/i18n-tasks
that referenced
this pull request
Dec 10, 2025
- Adds separate used_keys_ruby_prism_spec, catching some errors in the used_tree layer after the parser. - Separates haml and slim specs into separate files. - Fixes visitor to skip calls to translate methods on non-I18n classes. - Removes candidate keys for views and mailers - Adds candidate keys for model_name.human and human_attribute_name.
bart-westenenk-bex
pushed a commit
to bookingexperts/i18n-tasks
that referenced
this pull request
Dec 10, 2025
- Adds separate used_keys_ruby_prism_spec, catching some errors in the used_tree layer after the parser. - Separates haml and slim specs into separate files. - Fixes visitor to skip calls to translate methods on non-I18n classes. - Removes candidate keys for views and mailers - Adds candidate keys for model_name.human and human_attribute_name.
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.
in the used_tree layer after the parser.