Skip to content

Commit

Permalink
refactor i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Jan 17, 2025
1 parent 32befe4 commit 82938e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/avo/discreet_information.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Avo::DiscreetInformation
extend PropInitializer::Properties
include ActionView::Helpers::TagHelper

prop :resource, reader: :public

Expand All @@ -18,12 +19,22 @@ def items
private

def timestamp_item(item)
return if record.created_at.blank? && record.updated_at.blank?

time_format = "%Y-%m-%d %H:%M:%S"
created_at = record.created_at.strftime(time_format)
updated_at = record.updated_at.strftime(time_format)

created_at_tag = if record.created_at.present?
I18n.t("avo.created_at_timestamp", created_at:)
end

updated_at_tag = if record.updated_at.present?
I18n.t("avo.updated_at_timestamp", updated_at:)
end

DiscreetInformationItem.new(
tooltip: I18n.t("avo.discreet_information_timestamps_html", created_at:, updated_at:),
tooltip: tag.div([created_at_tag, updated_at_tag].compact.join(tag.br), style: "text-align: right;"),
icon: "heroicons/outline/clock"
)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/dummy/config/locales/avo.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ en:
delete_item: Delete %{item}
detach_item: detach %{item}
details: details
discreet_information_timestamps_html: "<div style=\"text-align: right;\">Created at %{created_at} <br/>Updated at %{updated_at}</div>"
created_at_timestamp: "Created at %{created_at}"
updated_at_timestamp: "Updated at %{updated_at}"
download: Download
download_file: Download file
download_item: Download %{item}
Expand Down

0 comments on commit 82938e2

Please sign in to comment.