diff --git a/CHANGELOG.md b/CHANGELOG.md index a5d4ce1013..14a07eda61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * [#251] [FEATURE] Raise a helpful error when an attribute is missing from `ATTRIBUTE_TYPES` +* [#298] [FEATURE] Support ActiveRecord model I18n translations * [#231] [UI] Fix layout issue on show page where a long label next to an empty value would cause following fields on the page to be mis-aligned. * [#259] [BUGFIX] Make installation generator more robust diff --git a/app/helpers/administrate/application_helper.rb b/app/helpers/administrate/application_helper.rb index 189aa75df9..9834493f7d 100644 --- a/app/helpers/administrate/application_helper.rb +++ b/app/helpers/administrate/application_helper.rb @@ -4,5 +4,17 @@ def render_field(field, locals = {}) locals.merge!(field: field) render locals: locals, partial: field.to_partial_path end + + def display_resource_name(resource_name) + resource_name. + to_s. + classify. + constantize. + model_name. + human( + count: 0, + default: resource_name.to_s.pluralize.titleize, + ) + end end end diff --git a/app/views/administrate/application/_sidebar.html.erb b/app/views/administrate/application/_sidebar.html.erb index 08d875cb7a..74f5141d80 100644 --- a/app/views/administrate/application/_sidebar.html.erb +++ b/app/views/administrate/application/_sidebar.html.erb @@ -11,7 +11,7 @@ as defined by the DashboardManifest. <% DashboardManifest::DASHBOARDS.each do |resource| %>
  • <%= link_to( - resource.to_s.titleize, + display_resource_name(resource), [Administrate::NAMESPACE, resource], class: "sidebar__link sidebar__link--#{nav_link_state(resource)}" ) %> diff --git a/app/views/administrate/application/index.html.erb b/app/views/administrate/application/index.html.erb index c99dd6baa9..2d7d8c9a4f 100644 --- a/app/views/administrate/application/index.html.erb +++ b/app/views/administrate/application/index.html.erb @@ -21,7 +21,9 @@ It renders the `_table` partial to display details about the resources. [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table %> -<% content_for(:title) { page.resource_name.pluralize.titleize } %> +<% content_for(:title) do %> + <%= display_resource_name(page.resource_name) %> +<% end %> <% content_for(:search) do %>