<commit_before>require "test_helper"
require "i18n/tasks"

module Misc
  class I18nTest < ActiveSupport::TestCase
    def i18n
      @i18n ||= I18n::Tasks::BaseTask.new
    end

    def missing_keys
      i18n.missing_keys
    end

    def unused_keys
      i18n.unused_keys
    end

    def test_no_missing_keys
      assert_empty missing_keys, "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
    end

    def test_no_unused_keys
      assert_empty unused_keys, "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
    end
  end
end
<commit_msg>Test normalized i18n files<commit_after>require "test_helper"
require "i18n/tasks"

module Misc
  class I18nTest < ActiveSupport::TestCase
    def i18n
      @i18n ||= I18n::Tasks::BaseTask.new
    end

    def missing_keys
      @missing_keys ||= i18n.missing_keys
    end

    def unused_keys
      @unused_keys ||= i18n.unused_keys
    end

    def non_normalized_paths
      @non_normalized_paths ||= i18n.non_normalized_paths
    end

    def test_no_missing_keys
      assert_empty missing_keys, "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
    end

    def test_no_unused_keys
      assert_empty unused_keys, "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
    end

    def test_normalized
      assert_empty non_normalized_paths, "The following files need to be normalized:\n" \
        "#{non_normalized_paths.map { |path| "  #{path}" }.join("\n")}\n" \
        'Please run `i18n-tasks normalize` to fix'
    end
  end
end

{'fraction_non_alphanumeric': 0.0852760736196319, 'fraction_numerical': 0.03067484662576687, 'mean_word_length': 3.2253886010362693, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4702557', 'n_tokens_mistral': 594, 'n_tokens_neox': 566, 'n_words': 140}