Text in links not fully translated
Created by: Na0na0
In /app/views/administrate/application/index.html.erb every links is not translated fully.
For example, when generating a link to create a new resource from a model named SubCategory:
<div>
<%= link_to(
t(
"administrate.actions.new_resource",
name: page.resource_name.titleize.downcase
),
[:new, namespace, page.resource_path],
class: "button",
) if valid_action?(:new) && show_action?(:new, new_resource) %>
</div>
in french, this will output something like this:
<a class="button" href="/admin/sub_categories/new">Création sub category</a>
The word create will be translated correctly, but not the resource name sub category.
The very useful display_resource_name
helper, which calls human
which itself calls translate
could help achieve that.
t(
"administrate.actions.new_resource",
name: display_resource_name(resource_name).downcase
)
output in french:
<a class="button" href="/admin/sub_categories/new">Création sous catégorie</a>
Hooray!
That way, if our resource name is translated in your_locale.activerecord.models.your_model
, it will be translated correctly and we can still handle format in your_locale.administrate.actions.new_resource
.
I haven't had time to check the other views yet, but would you be interested in a pull request? I'm running a similar fix using 0.8.1 in production, it probably won't introduce breaking change on master.
Have a nice day and thanks for this gem, it works great!