Sha256: 3d592d244f8d91d62f43e7ed355819faecd8f0d3f2ecf12df579eda06bab558c

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

require "rails"
module GovukDocumentTypes
  class TranslationsRailtie < ::Rails::Railtie
    initializer "govuk_document_types" do |app|
      GovukDocumentTypes::TranslationsRailtie.instance_eval do
        pattern = pattern_from app.config.i18n.available_locales
        add("rails/locale/#{pattern}.yml")
      end
    end

    def self.add(pattern)
      files = Dir[File.join(File.dirname(__FILE__), "../..", pattern)]
      I18n.load_path.concat(files)
    end

    def self.pattern_from(args)
      array = Array(args || [])
      array.blank? ? "*" : "{#{array.join ','}}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_document_types-3.0.0 lib/govuk_document_types/translations_railtie.rb
govuk_document_types-2.0.0 lib/govuk_document_types/translations_railtie.rb