lib/i18n/tasks/missing_keys.rb in i18n-tasks-0.2.22 vs lib/i18n/tasks/missing_keys.rb in i18n-tasks-0.3.0.rc1
- old
+ new
@@ -1,25 +1,28 @@
module I18n::Tasks
module MissingKeys
# @param [:missing_from_base, :missing_from_locale, :eq_base] type (default nil)
# @return [KeyGroup]
def missing_keys(opts = {})
- type = opts[:type]
locales = non_base_locales(opts[:locales])
- if type
- if type == :missing_from_base
- keys_missing_from_base
- else
- locales.map { |locale| send("keys_#{type}", locale) }.reduce(:+) || KeyGroup.new([])
- end
+ type = opts[:type]
+ unless type
+ types = opts[:types] || missing_keys_types
+ opts = opts.except(:types).merge(locales: locales)
+ return types.map { |t| missing_keys(opts.merge(type: t)) }.reduce(:+)
+ end
+ if type == :missing_from_base
+ keys_missing_from_base
else
- missing_keys(type: :missing_from_base) +
- missing_keys(type: :eq_base, locales: locales) +
- missing_keys(type: :missing_from_locale, locales: locales)
+ locales.map { |locale| send("keys_#{type}", locale) }.reduce(:+) || KeyGroup.new([])
end
end
+ def missing_keys_types
+ @missing_keys_types ||= [:missing_from_base, :eq_base, :missing_from_locale]
+ end
+
def untranslated_keys(locales = nil)
I18n::Tasks.warn_deprecated("#untranslated_keys. Please use #missing_keys instead")
missing_keys(locales: locales)
end
@@ -27,11 +30,11 @@
def keys_missing_from_base
@keys_missing_from_base ||= begin
KeyGroup.new(
used_keys.keys.reject { |k|
key = k.key
- key_value?(key, base_locale) || pattern_key?(key) || ignore_key?(key, :missing)
+ k.expr? || key_value?(key, base_locale) || ignore_key?(key, :missing)
}.map(&:clone_orphan), type: :missing_from_base, locale: base_locale)
end
end
# @return [KeyGroup] keys missing (nil or blank?) in locale but present in base
@@ -47,10 +50,10 @@
# @return [KeyGroup] keys missing value (but present in base)
def keys_eq_base(locale)
@keys_eq_base ||= KeyGroup.new(
traverse_map_if(data[base_locale]) { |key, base_value|
- key if base_value == t(locale, key) && !ignore_key?(key, :eq_base, locale)
+ key if base_value == t(key, locale) && !ignore_key?(key, :eq_base, locale)
}, type: :eq_base, locale: locale)
end
end
end