From ce22d079b8f7ad784b35bfefe015df40ab9ad0d0 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Wed, 7 Oct 2020 19:41:41 +0200 Subject: [PATCH] add i18n test for 100 unused and missing keys #31 --- config/i18n-tasks.yml | 9 ++++++--- test/i18n_test.rb | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 98c2c19..a432c0b 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -1,9 +1,9 @@ # i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks # The "main" locale. -base_locale: en +base_locale: de ## All available locales are inferred from the data by default. Alternatively, specify them explicitly: -locales: [en, de] +locales: [de] ## Reporting locale, default: en. Available: en, ru. # internal_locale: en @@ -98,12 +98,15 @@ search: # - '{devise,simple_form}.*' ## Consider these keys used: -# ignore_unused: +ignore_unused: + - 'datetime.distance_in_words.dativ.*' + - 'activerecord.attributes.user.*' # - 'activerecord.attributes.*' # - '{devise,kaminari,will_paginate}.*' # - 'simple_form.{yes,no}' # - 'simple_form.{placeholders,hints,labels}.*' # - 'simple_form.{error_notification,required}.:' +# Alternatively, mark them in your code with # i18n-tasks-use t('activerecord.models.user') ## Exclude these keys from the `i18n-tasks eq-base' report: # ignore_eq_base: diff --git a/test/i18n_test.rb b/test/i18n_test.rb index a521dab..3beab6c 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -6,15 +6,29 @@ class I18nTest < ActiveSupport::TestCase def setup @i18n = I18n::Tasks::BaseTask.new @missing_keys = @i18n.missing_keys - @unused_keys = @i18n.unused_keys + @unused_keys = @i18n.unused_keys + end + + # Drive this down + def test_no_more_than_100_missing_keys + assert @missing_keys.leaves.count < 100, + "Missing #{@missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them" + end + + # Drive this down + def test_no_more_than_100_unused_keys + assert @unused_keys.leaves.count < 100, + "#{@unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them" end def test_no_missing_keys + skip "dream on" assert_empty @missing_keys, "Missing #{@missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them" end def test_no_unused_keys + skip "dream on" assert_empty @unused_keys, "#{@unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them" end