Sha256: 712fdf41bbeb317e7cfd946031231ef3acedfa99640a5cf5a4174cf2b06f781e

Contents?: true

Size: 925 Bytes

Versions: 2

Compression:

Stored size: 925 Bytes

Contents

module I18n
  module TestHelper
    def assert_all_locales_have_translations_available_to_the_default_locale(message = "All translations should be available in all locales")
      default_locale = I18n.default_locale.to_sym
      locales_to_check = I18n.locales - [default_locale]

      required_translations = I18n.available_translations(default_locale)

      locales_to_check.each do |target_locale|
        defined_translations = I18n.available_translations(target_locale.to_sym)
        missing_translations = required_translations - defined_translations
                
        if missing_translations.any?
          missing_translations_for_output = missing_translations.map{|parts| " * #{parts.join('.')}" }.join("\n")
          raise Test::Unit::AssertionFailedError.new("#{message} - Missing translations for #{target_locale.inspect}:\n#{missing_translations_for_output}")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
everythingbehind-i18n-0.1.2 lib/i18n/test_helper.rb
everythingbehind-i18n-0.1.3 lib/i18n/test_helper.rb