Sha256: c3c67b0e47f2bdbc65e01a07285abe1950b96e927a3aa8a1766e5b0f088010ba

Contents?: true

Size: 719 Bytes

Versions: 32

Compression:

Stored size: 719 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

32 entries across 32 versions & 1 rubygems

Version Path
card-1.96.8 lib/card/set/i18n_scanner.rb
card-1.96.7 lib/card/set/i18n_scanner.rb
card-1.96.6 lib/card/set/i18n_scanner.rb
card-1.96.5 lib/card/set/i18n_scanner.rb
card-1.96.4 lib/card/set/i18n_scanner.rb
card-1.96.3 lib/card/set/i18n_scanner.rb
card-1.96.2 lib/card/set/i18n_scanner.rb
card-1.96.1 lib/card/set/i18n_scanner.rb
card-1.96.0 lib/card/set/i18n_scanner.rb
card-1.95.3 lib/card/set/i18n_scanner.rb
card-1.95.2 lib/card/set/i18n_scanner.rb
card-1.95.1 lib/card/set/i18n_scanner.rb
card-1.95.0 lib/card/set/i18n_scanner.rb
card-1.94.1 lib/card/set/i18n_scanner.rb
card-1.94.0 lib/card/set/i18n_scanner.rb
card-1.93.13 lib/card/set/i18n_scanner.rb
card-1.93.12 lib/card/set/i18n_scanner.rb
card-1.93.11 lib/card/set/i18n_scanner.rb
card-1.93.10 lib/card/set/i18n_scanner.rb
card-1.93.9 lib/card/set/i18n_scanner.rb