Sha256: 219d2e3f461cb1e853799f82b97d0129e77db7045ea1f0c035f96a2101bd7da4

Contents?: true

Size: 459 Bytes

Versions: 1

Compression:

Stored size: 459 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Traits
    module Localisation
    private

      def localised_text(context)
        key = localisation_key(context)

        return nil unless I18n.exists?(key)

        I18n.translate(key)
      end

      def localisation_key(context)
        return nil unless @object_name.present? && @attribute_name.present?

        ['helpers', context, @object_name, @attribute_name].join('.')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-1.1.0.beta.1 lib/govuk_design_system_formbuilder/traits/localisation.rb