0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-14 13:58:53 +08:00
discourse/app/helpers/embed_helper.rb
Isaac Janzen b1f4499768
DEV: Extract embed post date title into i18n-aware helper (#38594)
Replaces the hardcoded `strftime` format in the embed comments view with
a helper method that uses the localized `datetime_formats.formats.long`
key.
2026-03-17 09:12:21 -05:00

28 lines
673 B
Ruby
Vendored

# frozen_string_literal: true
module EmbedHelper
def embed_post_date_title(dt)
dt.strftime I18n.t("datetime_formats.formats.long")
end
def embed_post_date(dt)
current = Time.now
if dt >= 1.day.ago
distance_of_time_in_words(dt, current)
else
if dt.year == current.year
dt.strftime I18n.t("datetime_formats.formats.short_no_year")
else
dt.strftime I18n.t("datetime_formats.formats.no_day")
end
end
end
def get_html(post)
key = "js.action_codes.#{post.action_code}"
cooked = (post.cooked.presence || I18n.t(key, when: nil).humanize)
raw PrettyText.format_for_email(cooked, post)
end
end