Sha256: 7bc183c904796a589096879b5a12590c210c6377bf1c1b4a4117382ddaaa9fba
Contents?: true
Size: 1.07 KB
Versions: 12
Compression:
Stored size: 1.07 KB
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? schema(context) end def schema(context) schema_root(context) .push(@object_name, @attribute_name) .map { |e| e == :__context__ ? context : e } .join('.') end def schema_root(context) contextual_schema = case context when :legend config.localisation_schema_legend when :hint config.localisation_schema_hint when :label config.localisation_schema_label end (contextual_schema || config.localisation_schema_fallback).dup end end end end
Version data entries
12 entries across 12 versions & 1 rubygems