From f5f44bdab9d3f907038dec4003d9a7668555e097 Mon Sep 17 00:00:00 2001 From: Sol Fisher Romanoff Date: Fri, 18 Nov 2022 16:38:41 +0200 Subject: [PATCH] Add support for internationalization --- lib/pleroma/web/static_fe/static_fe_view.ex | 23 +++++--------- .../web/templates/layout/static_fe.html.eex | 2 +- .../static_fe/static_fe/_attachment.html.eex | 2 +- .../static_fe/static_fe/_notice.html.eex | 6 ++-- .../static_fe/static_fe/conversation.html.eex | 2 +- .../static_fe/static_fe/error.html.eex | 2 +- .../static_fe/static_fe/profile.html.eex | 30 +++++++++---------- 7 files changed, 30 insertions(+), 37 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index c85689c8b..e2013d697 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -33,21 +33,14 @@ def time_ago(date) do minutes = now.minute - date.minute seconds = now.second - date.second cond do - years > 1 -> to_string(years) <> " years ago" - years > 0 -> "1 year ago" - months > 1 -> to_string(months) <> " months ago" - months > 0 -> "1 month ago" - days > 13 -> to_string(trunc(days / 7)) <> " weeks ago" - days > 6 -> "1 week ago" - days > 1 -> to_string(days) <> " days ago" - days > 0 -> "1 day ago" - hours > 1 -> to_string(hours) <> " hours ago" - hours > 0 -> "1 hour ago" - minutes > 1 -> to_string(minutes) <> " minutes ago" - minutes > 0 -> "1 minute ago" - seconds > 1 -> to_string(seconds) <> " seconds ago" - seconds > 0 -> "1 second ago" - true -> "now" + years > 0 -> ngettext("1 year ago", "%{count} years ago", years) + months > 0 -> ngettext("1 month ago", "%{count} months ago", months) + days > 6 -> ngettext("1 week ago", "%{count} weeks ago", trunc(days / 7)) + days > 0 -> ngettext("1 day ago", "%{count} days ago", days) + hours > 0 -> ngettext("1 hour ago", "%{count} hours ago", hours) + minutes > 0 -> ngettext("1 minute ago", "%{count} minutes ago", minutes) + seconds > 0 -> ngettext("1 second ago", "%{count} seconds ago", seconds) + true -> gettext("now") end end diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index bcb160b10..3d55393f0 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -26,7 +26,7 @@