Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grab label_for helper from Pals
Browse files Browse the repository at this point in the history
jeremyf committed Dec 15, 2023
1 parent 373e794 commit e81126b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,10 @@ module ApplicationHelper
include GroupNavigationHelper
include SharedSearchHelper

def label_for(term:, record_class: nil)
locale_for(type: 'labels', term: term, record_class: record_class)
end

def hint_for(term:, record_class: nil)
hint = locale_for(type: 'hints', term: term, record_class: record_class)

@@ -16,8 +20,8 @@ def locale_for(type:, term:, record_class:)
@term = term.to_s
@record_class = record_class.to_s.downcase
work_or_collection = @record_class == 'collection' ? 'collection' : 'defaults'
default_locale = t("simple_form.#{type}.#{work_or_collection}.#{@term}")
locale = t("hyrax.#{@record_class}.#{type}.#{@term}")
default_locale = t("simple_form.#{type}.#{work_or_collection}.#{@term}").html_safe
locale = t("hyrax.#{@record_class}.#{type}.#{@term}").html_safe

return default_locale if missing_translation(locale)

@@ -27,4 +31,14 @@ def locale_for(type:, term:, record_class:)
def missing_translation(value)
value.include?('translation missing')
end

def markdown(text)
options = %i[
hard_wrap autolink no_intra_emphasis tables fenced_code_blocks
disable_indented_code_blocks strikethrough lax_spacing space_after_headers
quote footnotes highlight underline
]
text ||= ""
Markdown.new(text, *options).to_html.html_safe
end
end

0 comments on commit e81126b

Please sign in to comment.