lib/i18n/tasks/missing_keys.rb in i18n-tasks-0.2.1 vs lib/i18n/tasks/missing_keys.rb in i18n-tasks-0.2.2

- old
+ new

@@ -1,33 +1,23 @@ module I18n::Tasks::MissingKeys - # missing keys, i.e. key that are in the code but are not in the base locale data - # @return Array{Hash} - def keys_missing_base_value + # @return Array missing keys, i.e. key that are in the code but are not in the base locale data + def keys_missing_from_base find_source_keys.reject { |key| key_value?(key, base_locale) || pattern_key?(key) || ignore_key?(key, :missing) - }.map { |key| {locale: base_locale, type: :none, key: key} } + } end - # present in base locale, but untranslated in another locale - # @return Array{Hash} - def keys_missing_translation(locale) - trn = data[locale] - r = [] - traverse data[base_locale] do |key, base_value| - value_in_locale = t(trn, key) - if value_in_locale.blank? && !ignore_key?(key, :missing) - r << {locale: locale, key: key, type: :blank, base_value: base_value} - elsif value_in_locale == base_value && !ignore_key?(key, :eq_base, locale) - r << {locale: locale, key: key, type: :eq_base, base_value: base_value} - end + # @return Array keys missing value (but present in base) + def keys_missing_value(locale) + traverse_map_if data[base_locale] do |key, base_value| + key if !key_value?(key, locale) && !ignore_key?(key, :missing) end - r end - # sort first by locale, then by type - # @return Array{Hash} - def sort_keys(keys) - keys.sort { |a, b| - (l = a[:locale] <=> b[:locale]).zero? ? a[:type] <=> b[:type] : l - } + # @return Array keys missing value (but present in base) + def keys_where_value_eq_base(locale) + traverse_map_if data[base_locale] do |key, base_value| + key if base_value == t(locale, key) && !ignore_key?(key, :eq_base, locale) + end end + end \ No newline at end of file