lib/babelyoda.rb in babelyoda-2.0.4 vs lib/babelyoda.rb in babelyoda-2.0.5

- old
+ new

@@ -199,32 +199,37 @@ combined_keyset = Babelyoda::Keyset.new('babelyoda.verify') spec.strings_files.each do |filename| dev_lang_strings = Babelyoda::Strings.new(filename, spec.development_language).read combined_keyset.merge!(dev_lang_strings) spec.localization_languages.each do |language| - lang_strings = Babelyoda::Strings.new(filename, language).read + lang_strings = Babelyoda::Strings.new(File.localized(filename, language), language).read combined_keyset.merge!(lang_strings) end end - $logger.info "#{spec.development_language}: #{combined_keyset.keys.size} keys" - total_missing_count = combined_keyset.keys.size - - present = {} - spec.localization_languages.each do |language| - present[language] = Babelyoda::Keyset.new("babelyoda.verify.#{language}") - end combined_keyset.drop_empty! + + count = {} + spec.all_languages.each { |lang| count[lang.to_sym] = 0} + combined_keyset.keys.each_value do |key| - spec.localization_languages.each do |lang| - present[lang.to_sym].merge_key!(key) if key.values.has_key?(lang.to_sym) + spec.all_languages.each do |lang| + count[lang.to_sym] += 1 if key.values.has_key?(lang.to_sym) end end + + total_count = count[spec.development_language.to_sym] + $logger.info "#{spec.development_language}: #{total_count} keys" + + all_found = true spec.localization_languages.each do |language| - count = present[language].keys.size - total_missing_count -= count - $logger.error "#{language}: #{combined_keyset.keys.size - count} keys (#{count} translations missing)" if count > 0 + lang_count = count[language.to_sym] + missing_count = total_count - lang_count + if missing_count > 0 + $logger.error "#{language}: #{lang_count} keys (#{missing_count} translations missing)" + all_found = false + end end - exit 1 if total_missing_count > 0 + exit 1 unless all_found end namespace :remote do desc "List remote keysets"