Skip to content

Commit

Permalink
Added translations for manufacturer resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilien Bausson committed Oct 11, 2023
1 parent db0dd87 commit 46125c7
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 28 deletions.
6 changes: 3 additions & 3 deletions app/controllers/manufacturers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create

respond_to do |format|
if @manufacturer.save
format.html { redirect_to @manufacturer, notice: 'Manufacturer was successfully created.' }
format.html { redirect_to @manufacturer, notice: t(".flashes.created") }
format.json { render :show, status: :created, location: @manufacturer }
else
format.html { render :new }
Expand All @@ -42,7 +42,7 @@ def create
def update
respond_to do |format|
if @manufacturer.update(manufacturer_params)
format.html { redirect_to @manufacturer, notice: 'Manufacturer was successfully updated.' }
format.html { redirect_to @manufacturer, notice: t(".flashes.updated") }
format.json { render :show, status: :ok, location: @manufacturer }
else
format.html { render :edit }
Expand All @@ -56,7 +56,7 @@ def update
def destroy
if @manufacturer.destroy
respond_to do |format|
format.html { redirect_to manufacturers_url, notice: 'Manufacturer a bien été supprimé.' }
format.html { redirect_to manufacturers_url, notice: t(".flashes.destroyed") }
format.json { head :no_content }
end
else
Expand Down
12 changes: 8 additions & 4 deletions app/views/manufacturers/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<%= form_for(@manufacturer, html: { class: "form-horizontal", role: "form" }) do |f| %>
<% if @manufacturer.errors.any? %>
<div class="alert alert-danger alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4><%= pluralize(@manufacturer.errors.count, "erreur", "erreurs") %> lors de la sauvegarde :</h4>
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">
<%= t("action.close") %>
</span></button>
<h4>
<%= t("form.errors.title", count: @manufacturer.errors.count) %>
</h4>

<ul>
<% @manufacturer.errors.full_messages.each do |msg| %>
Expand All @@ -27,10 +31,10 @@
<div class="form-group">
<%= f.label :documentation_url, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :documentation_url, placeholder: "https://url_du_frabricant.com/suite_de_l_url/%s/reste_s_il_y_a", class: "form-control" %>
<%= f.text_field :documentation_url, placeholder: t(".url_placeholder"), class: "form-control" %>
<span class="text-muted">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
<small>Information : il faut remplacer le numéro de série dans l'URL par <code>%s</code>.</small>
<small><%= t(".information").html_safe %></small>
</span>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions app/views/manufacturers/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<div class="page-header">
<%= link_to manufacturers_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to @manufacturer, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-info-sign"></span>
Voir
<%= t("action.show") %>
<% end %>
<h1>Editing manufacturer</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
22 changes: 14 additions & 8 deletions app/views/manufacturers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@
<div class="page-header">
<%= link_to new_manufacturer_path, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
Ajouter une manufacturer
<%= t(".new_manufacturer") %>
<% end %>
<h1>Fabricants</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Nom</th>
<th>Usage</th>
<th>
<%= Manufacturer.human_attribute_name(:name) %>
</th>
<th>
<%= Manufacturer.human_attribute_name(:usage) %>
</th>
<th></th>
<th></th>
</tr>
Expand All @@ -32,13 +38,13 @@
<tbody>
<%= content_tag_for(:tr, @manufacturers) do |manufacturer| %>
<td><%= manufacturer %></td>
<td><%= pluralize(manufacturer.modeles.count, 'modèle', 'modèles') %> </td>
<td><%= link_to 'Modifier', edit_manufacturer_path(manufacturer), class: 'btn btn-primary' %></td>
<td><%= Manufacturer.human_attribute_name(:modeles, count: manufacturer.modeles.count) %> </td>
<td><%= link_to t("action.edit"), edit_manufacturer_path(manufacturer), class: 'btn btn-primary' %></td>
<td>
<%= link_to 'Supprimer',
<%= link_to t("action.delete"),
manufacturer,
method: :delete,
data: { confirm: 'Ce mainteneur ne pourra pas être supprimé tant qu\'il sera associé à au moins un modèle. Voulez-vous continuer ?' },
data: { confirm: t(".delete_confirmation") },
class: 'btn btn-danger' %>
</td>
<% end %>
Expand Down
6 changes: 4 additions & 2 deletions app/views/manufacturers/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="page-header">
<%= link_to manufacturers_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<h1>New manufacturer</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
22 changes: 15 additions & 7 deletions app/views/manufacturers/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
<div class="page-header">
<%= link_to manufacturers_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to edit_manufacturer_path(@manufacturer), class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-pencil"></span>
Edit
<%= t("action.edit") %>
<% end %>
<h1>Voir manufacturer</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-body">
<dl class="dl-horizontal">
<dt>Nom :</dt>
<dt>
<%= Manufacturer.human_attribute_name(:name) %> :
</dt>
<dd><%= @manufacturer %></dd>

<dt>Description:</dt>
<dt>
<%= Manufacturer.human_attribute_name(:description) %> :
</dt>
<dd><%= @manufacturer.description %></dd>

<dt>Documentation URL:</dt>
<dt>
<%= Manufacturer.human_attribute_name(:documentation_url) %> :
</dt>
<dd><%= @manufacturer.documentation_url %></dd>
</dl>
</div>
</div>
</div>
</div>
8 changes: 8 additions & 0 deletions config/locales/activerecord.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ fr:
errors_count:
one: 1 erreur
other: "%{count} erreurs"
manufacturer:
name: Nom
usage: Usage
description: Description
documentation_url: Documentation URL
modeles:
one: 1 modèle
other: "%{count} modèles"
errors:
models:
user:
Expand Down
26 changes: 25 additions & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ fr:
edit: Modifier
delete: Supprimer
back: Retour
close: Fermer
show: Voir
breadcrumb:
settings: Paramètres
pages:
Expand Down Expand Up @@ -37,7 +39,29 @@ fr:
destroy:
flashes:
destroyed: Site a bien été supprimé.

manufacturers:
form:
url_placeholder: "https://url_du_frabricant.com/suite_de_l_url/%s/reste_s_il_y_a"
information: "Information : il faut remplacer le numéro de série dans l'URL par <code>%s</code>."
index:
new_manufacturer: Ajouter une manufacturer
title: Fabricants
delete_confirmation: Ce mainteneur ne pourra pas être supprimé tant qu'il sera associé à au moins un modèle. Voulez-vous continuer ?
show:
title: Voir manufacturer
new:
title: New manufacturer
create:
flashes:
created: Manufacturer was successfully created.
edit:
title: Editing manufacturer
update:
flashes:
updated: Manufacturer was successfully updated.
destroy:
flashes:
destroyed: Manufacturer a bien été supprimé.
devise:
registrations:
signed_up: 'Vous pouvez désormais vous connecter avec Cerbère'
Expand Down

0 comments on commit 46125c7

Please sign in to comment.