-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add translations for ActiveRecord models #180
Conversation
Hey, @mgrachev! Sorry I haven't responded sooner. Could you add some tests for this? Maybe something like this, in it "honors model translations" do
allow(I18n).to receive(:translate).with("customer").and_return("user")
visit admin_customers_path
sidebar = find(".sidebar__list")
expect(sidebar).to have_link("Users")
expect(page).to have_header("Users")
end |
@@ -11,7 +11,7 @@ as defined by the DashboardManifest. | |||
<% DashboardManifest::DASHBOARDS.each do |resource| %> | |||
<li> | |||
<%= link_to( | |||
resource.to_s.titleize, | |||
resource.to_s.classify.constantize.model_name.human(default: resource.to_s.titleize), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to pluralize this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The user decides how to display the model name through a file locale. In default pluralization.
@@ -8,4 +8,14 @@ | |||
|
|||
expect(active_link.text).to eq "Customers" | |||
end | |||
|
|||
it "displays translated name of model" do | |||
allow(Customer.model_name).to receive(:human).and_return('Users') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Added test |
Please, restart the build on CircleCI |
Hi. Added translation support for ActiveRecord models in the sidebar and on the index page (header).
File locale must be of such content: