diff --git a/app/helpers/admin/users_helper.rb b/app/helpers/admin/users_helper.rb index d640fc08c..d52b2a0df 100644 --- a/app/helpers/admin/users_helper.rb +++ b/app/helpers/admin/users_helper.rb @@ -16,45 +16,46 @@ module Admin return if timestamp.blank? if timestamp.today? - "Today, #{timestamp.strftime('%d %b')}" + I18n.t("helpers.admin.user_helper.today", date: I18n.l(timestamp, format: :members)) elsif timestamp.yesterday? - "Yesterday, #{timestamp.strftime('%d %b')}" + I18n.t("helpers.admin.user_helper.yesterday", date: I18n.l(timestamp, format: :members)) else - timestamp.strftime("%d %b, %Y") + I18n.l(timestamp, format: :members_with_year) end end def cascading_high_level_roles(user) if user.super_admin? - "Super Admin" + I18n.t("views.admin.users.roles.Super Admin") elsif user.admin? - "Admin" + I18n.t("views.admin.users.roles.Admin") elsif user.single_resource_admin_for?(:any) - "Resource Admin" + I18n.t("views.admin.users.roles.Resource Admin") end end def format_role_tooltip(user) if user.super_admin? - "Super Admin" + I18n.t("views.admin.users.roles.Super Admin") elsif user.admin? - "Admin" + I18n.t("views.admin.users.roles.Admin") elsif user.single_resource_admin_for?(:any) - "Resource Admin: #{user.roles.pluck(:resource_type).compact.join(', ')}" + role = "Resource Admin: #{user.roles.pluck(:resource_type).compact.join(', ')}" + I18n.t("views.admin.users.roles.#{role}", default: role) end end def user_status(user) if user.suspended? - "Suspended" + I18n.t("views.admin.users.statuses.Suspended") elsif user.warned? - "Warned" + I18n.t("views.admin.users.statuses.Warned") elsif user.comment_suspended? - "Comment Suspended" + I18n.t("views.admin.users.statuses.Comment Suspended") elsif user.trusted? - "Trusted" + I18n.t("views.admin.users.statuses.Trusted") else - "Good Standing" + I18n.t("views.admin.users.statuses.Good Standing") end end @@ -83,16 +84,12 @@ module Admin # @param [Integer] The limit of organizations that we show # @return [String] def organization_tooltip(organization_names, count, imposed_limit: 0) - str = organization_names.first(imposed_limit).join(", ").to_s + str = organization_names.first(imposed_limit).join(I18n.t("helpers.admin.user_helper.org_join")).to_s return str unless count > imposed_limit - overflow = overflow_count(count, imposed_limit: imposed_limit) - if overflow == 1 - str + " & #{overflow_count(count, imposed_limit: imposed_limit)} other" - else - str + " & #{overflow_count(count, imposed_limit: imposed_limit)} others" - end + I18n.t("helpers.admin.user_helper.org_overflow", count: overflow_count(count, imposed_limit: imposed_limit), + orgs: str) end # Returns a string hex code representing the indicator color for the given status (also known as BASE_ROLE) diff --git a/app/views/admin/users/controls/_expand_search_button.html.erb b/app/views/admin/users/controls/_expand_search_button.html.erb index f940c5b98..a97ebaf44 100644 --- a/app/views/admin/users/controls/_expand_search_button.html.erb +++ b/app/views/admin/users/controls/_expand_search_button.html.erb @@ -1,4 +1,4 @@ - diff --git a/app/views/admin/users/controls/_export.html.erb b/app/views/admin/users/controls/_export.html.erb index 337387a3c..0a4d7c92a 100644 --- a/app/views/admin/users/controls/_export.html.erb +++ b/app/views/admin/users/controls/_export.html.erb @@ -1,3 +1,3 @@ - diff --git a/app/views/admin/users/controls/_search_field.html.erb b/app/views/admin/users/controls/_search_field.html.erb index 17e270bc6..2733344f7 100644 --- a/app/views/admin/users/controls/_search_field.html.erb +++ b/app/views/admin/users/controls/_search_field.html.erb @@ -1,6 +1,6 @@
<%= f.text_field :search, id: "search-#{context}", value: params[:search], class: "crayons-textfield mt-0", placeholder: placeholder, aria: { label: aria_label } %> -
diff --git a/app/views/admin/users/export.csv.erb b/app/views/admin/users/export.csv.erb index fa3eab4f5..4ce50609d 100644 --- a/app/views/admin/users/export.csv.erb +++ b/app/views/admin/users/export.csv.erb @@ -1,6 +1,6 @@ -<%- headers = ["Name", "Username", "Email address", "Status", "Joining date", "Last activity", "Organizations"] -%> +<%- headers = [t("views.admin.users.download.name"), t("views.admin.users.download.username"), t("views.admin.users.download.email"), t("views.admin.users.download.status"), t("views.admin.users.download.join"), t("views.admin.users.download.last_activity"), t("views.admin.users.download.orgs")] -%> <%= CSV.generate_line headers -%> <%- @users.each do |user| -%> - <%- row = [user.name, user.username, user.email, user_status(user), user.registered_at&.strftime("%d %b, %Y"), user.last_activity&.strftime("%d %b, %Y"), user.organizations.pluck(:name)] -%> + <%- row = [user.name, user.username, user.email, user_status(user), user.registered_at ? l(user.registered_at, format: :members_with_year) : '', user.last_activity ? l(user.last_activity, format: :members_with_year) : '', user.organizations.pluck(:name)] -%> <%= CSV.generate_line(row).html_safe -%> <%- end -%> \ No newline at end of file diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 237a01551..f3c294308 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -2,14 +2,14 @@
-

Members

+

<%= t("views.admin.users.heading") %>

<%= render "admin/users/index/controls" %>
<%= render "admin/users/index/applied_filters" %>
-

Members

+

<%= t("views.admin.users.table.compact_subtitle") %>