Sha256: ccf389b8aa1f08a934db417f7602109e40ab96a6fb9863f94e0be507af98d3f0

Contents?: true

Size: 793 Bytes

Versions: 3

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true
require 'set'

module I18n
  module Tasks
    module UnusedKeys
      def unused_keys(locales: nil, strict: nil)
        locales = Array(locales).presence || self.locales
        locales.map { |locale| unused_tree(locale: locale, strict: strict) }.compact.reduce(:merge!)
      end

      # @param [String] locale
      # @param [Boolean] strict if true, do not match dynamic keys
      def unused_tree(locale: base_locale, strict: nil)
        used_key_names = used_tree(strict: true).key_names
        collapse_plural_nodes! data[locale].select_keys { |key, _node|
          !ignore_key?(key, :unused) &&
              (strict || !used_in_expr?(key)) &&
              !used_key_names.include?(depluralize_key(key, locale))
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n-tasks-0.9.6 lib/i18n/tasks/unused_keys.rb
i18n-tasks-0.9.5 lib/i18n/tasks/unused_keys.rb
i18n-tasks-0.9.4 lib/i18n/tasks/unused_keys.rb