Class: InertiaI18n::I18nTasks::Scanner
- Inherits:
-
I18n::Tasks::Scanners::FileScanner
- Object
- I18n::Tasks::Scanners::FileScanner
- InertiaI18n::I18nTasks::Scanner
- Defined in:
- lib/inertia_i18n/i18n_tasks/scanner.rb
Instance Method Summary collapse
Instance Method Details
#scan_file(path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/inertia_i18n/i18n_tasks/scanner.rb', line 9 def scan_file(path) # Scan file using InertiaI18n logic scanner = InertiaI18n::Scanner.new parser = scanner.parser_for_file(path) return [] unless parser return [] if parser.instance_of?(InertiaI18n::Parsers::BaseParser) # Extract keys: {static: [{key: 'foo', line: 1}], dynamic: [...]} results = parser.extract_keys(path) # Convert to i18n-tasks format: [ [key, Occurrence] ] results[:static].map do |usage| key = usage[:key] # Return the format i18n-tasks expects for key occurrences [ key, ::I18n::Tasks::Scanners::Results::Occurrence.new( path: path, line_num: usage[:line], pos: 1, line_pos: 1, line: "", raw_key: key ) ] end end |