Sha256: 488bca435fb3049fcb8ab95f46d6dc6b6aafe9431d0c87aef2c7d4f0648a14ec

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 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.available_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

1 entries across 1 versions & 1 rubygems

Version Path
everythingbehind-i18n-0.1.1.1 lib/i18n/test_helper.rb