Sha256: 084bb20c73f5d7e08c334eb988158c1bc29cdacde50e6eaaff401e7fa3cf33b6

Contents?: true

Size: 727 Bytes

Versions: 43

Compression:

Stored size: 727 Bytes

Contents

# lib/my_custom_scanner.rb
require "i18n/tasks/scanners/file_scanner"
class Card
  module Set
    class I18nScanner < ::I18n::Tasks::Scanners::FileScanner
      include ::I18n::Tasks::Scanners::RelativeKeys
      include ::I18n::Tasks::Scanners::OccurrenceFromPosition

      # @return [Array<[absolute key, Results::Occurrence]>]
      def scan_file path
        text = read_file(path)

        text.scan(/[^\w._-]tr[( ]\s*["':](\w+)/).map do |_match|
          occurrence = occurrence_from_position(
            path, text, Regexp.last_match.offset(0).first
          )
          [absolute_key(".#{_match[0]}", path), occurrence]
        end
      end
    end
    ::I18n::Tasks.add_scanner "Card::Set::I18nScanner"
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
card-1.108.1 lib/card/set/i18n_scanner.rb
card-1.108.0 lib/card/set/i18n_scanner.rb
card-1.107.0 lib/card/set/i18n_scanner.rb
card-1.106.0 lib/card/set/i18n_scanner.rb
card-1.105.6 lib/card/set/i18n_scanner.rb
card-1.105.5 lib/card/set/i18n_scanner.rb
card-1.105.4 lib/card/set/i18n_scanner.rb
card-1.105.3 lib/card/set/i18n_scanner.rb
card-1.105.2.pre1 lib/card/set/i18n_scanner.rb
card-1.105.2 lib/card/set/i18n_scanner.rb
card-1.105.1 lib/card/set/i18n_scanner.rb
card-1.105.0 lib/card/set/i18n_scanner.rb
card-1.104.2 lib/card/set/i18n_scanner.rb
card-1.104.1 lib/card/set/i18n_scanner.rb
card-1.104.0 lib/card/set/i18n_scanner.rb
card-1.103.4 lib/card/set/i18n_scanner.rb
card-1.103.3 lib/card/set/i18n_scanner.rb
card-1.103.2 lib/card/set/i18n_scanner.rb
card-1.103.1 lib/card/set/i18n_scanner.rb
card-1.103.0 lib/card/set/i18n_scanner.rb