Sha256: cf6a84d152fe18de3deed4b606cea5154df731c2072cc5786769243c18ceb9b9

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

# frozen_string_literal: true

module ThemeCheck
  class MatchingTranslations < JsonCheck
    severity :suggestion
    category :translation
    doc docs_url(__FILE__)

    def initialize
      @files = []
    end

    def on_file(file)
      return unless file.name.starts_with?("locales/")
      return unless file.content.is_a?(Hash)
      return if file.name == @theme.default_locale_json&.name

      @files << file
    end

    def on_end
      return unless @theme.default_locale_json&.content

      @files.each do |file|
        diff = LocaleDiff.new(@theme.default_locale_json.content, file.content)
        diff.add_as_offenses(self, template: file)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
theme-check-0.6.0 lib/theme_check/checks/matching_translations.rb
theme-check-0.5.0 lib/theme_check/checks/matching_translations.rb