Sha256: e76a57c1f85512f9ddf509046228c71a2628c4d17705c65d54a2682baa2ca7f4

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

module I18nAdminUtils
  class SearchTranslation
    def self.search
      results = []
      dirs = ["#{Rails.root}/app"]
      dirs.each do |dir|
        Dir.glob("#{dir}/**/*.*").each do |filename|
          File.open(filename).read.scan(/t\(("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')\)/).each do |result|
            results << result[0][1...-1]
          end
        end
      end
      check_results(results)
    end

    def self.check_results(results)
      missing = []
      results.each do |result|
        locale = 'en'
        I18nAdminUtils::Config.locales.each do |locale|
          if I18nAdminUtils::Config.translation_model.where(:locale => locale, :key => result).first.nil?
            missing << {:locale => locale, :key => result}
          end
        end
      end
      missing
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n_admin_utils-0.0.1 lib/i18n_admin_utils/search_translation.rb