Skip to content

Commit

Permalink
Abstract away SearchMethodsForLocalizationMessagesRule
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Aug 27, 2024
1 parent 65d8c7a commit 23cfe1d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ NaturalLanguageTranslationScanner >> projectName [
{ #category : 'private' }
NaturalLanguageTranslationScanner >> scanProjectMethodsCollectingTranslationsIn: stringsToTranslate [

| searchRule |
searchRule := RBParseTreeLintRule new.
searchRule matcher
matches: '`#string localized'
do: [ :node :answer | stringsToTranslate add: node receiver value ];
matches: '`#string localizedWithAll: `@values'
do: [ :node :answer | stringsToTranslate add: node receiver value ].
searchRule runOnEnvironment: environment
( SearchMethodsForLocalizationMessagesRule collectingTranslationsIn: stringsToTranslate )
runOnEnvironment: environment
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Class {
#name : 'SearchMethodsForLocalizationMessagesRule',
#superclass : 'RBParseTreeLintRule',
#instVars : [
'stringsToTranslate'
],
#category : 'Buoy-Development-Tools-Pharo-12',
#package : 'Buoy-Development-Tools-Pharo-12'
}

{ #category : 'instance creation' }
SearchMethodsForLocalizationMessagesRule class >> collectingTranslationsIn: aCollection [

^ self new initializeCollectingTranslationsIn: aCollection
]

{ #category : 'initialization' }
SearchMethodsForLocalizationMessagesRule >> initialize [

super initialize.
matcher
matches: '`#string localized'
do: [ :node :answer | stringsToTranslate add: node receiver value ];
matches: '`#string localizedWithAll: `@values'
do: [ :node :answer | stringsToTranslate add: node receiver value ]
]

{ #category : 'initialization' }
SearchMethodsForLocalizationMessagesRule >> initializeCollectingTranslationsIn: aCollection [

stringsToTranslate := aCollection
]

{ #category : 'accessing' }
SearchMethodsForLocalizationMessagesRule >> name [

^ 'Search methods for localization messages'
]

0 comments on commit 23cfe1d

Please sign in to comment.