Skip to content

Commit

Permalink
Added translations for card type resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilien Bausson committed Oct 13, 2023
1 parent db0dd87 commit 57b0830
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 32 deletions.
6 changes: 3 additions & 3 deletions app/controllers/card_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def create

respond_to do |format|
if @card_type.save
format.html {redirect_to({action: 'index'}, notice: 'card_type was successfully created.')}
format.html {redirect_to({action: 'index'}, notice: t(".flashes.created"))}
format.json {render :show, status: :created, location: @card_type}
else
format.html {render :new}
Expand All @@ -34,7 +34,7 @@ def create
def update
respond_to do |format|
if @card_type.update(card_type_params)
format.html {redirect_to({action: 'index'}, notice: 'card_type was successfully updated.')}
format.html {redirect_to({action: 'index'}, notice: t(".flashes.updated"))}
format.json {render :show, status: :ok, location: @card_type}
else
format.html {render :edit}
Expand All @@ -48,7 +48,7 @@ def update
def destroy
if @card_type.destroy
respond_to do |format|
format.html { redirect_to({action: 'index'}, notice: 'card_type a bien été supprimé.') }
format.html { redirect_to({action: 'index'}, notice: t(".flashes.destroyed")) }
format.json { head :no_content }
end
else
Expand Down
22 changes: 13 additions & 9 deletions app/views/card_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<% if @card_type.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(@card_type.errors.count, "erreur", "erreurs") %> lors de la sauvegarde :</h4>
<span aria-hidden="true">&times;</span><span class="sr-only">
<%= t("action.close") %>
</span></button>
<h4>
<%= t("form.errors.title", count: @card_type.errors.count) %>
</h4>

<ul>
<% @card_type.errors.full_messages.each do |msg| %>
Expand All @@ -20,44 +24,44 @@
</div>
</div>
<div class="form-group">
<%= f.label 'Type de port', class: "col-sm-2 control-label" %>
<%= f.label :port_type, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.select :port_type_id, PortType.all.map {|pt| [pt.name, pt.id]}, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label 'Nombre de ports', class: "col-sm-2 control-label" %>
<%= f.label :port_quantity_label, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :port_quantity, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label 'Colonnes', class: "col-sm-2 control-label" %>
<%= f.label :columns, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :columns, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label 'Lignes', class: "col-sm-2 control-label" %>
<%= f.label :rows, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :rows, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label 'Nbr max de ports alignés', class: "col-sm-2 control-label" %>
<%= f.label :max_aligned_ports, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :max_aligned_ports, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label 'Numéro du premier port', class: "col-sm-2 control-label" %>
<%= f.label :first_position, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.select :first_position, [0, 1], class: "form-control" %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit "Enregistrer", class: "btn btn-primary" %>
<%= f.submit t("action.save"), class: "btn btn-primary" %>
</div>
</div>
<% end %>
8 changes: 5 additions & 3 deletions app/views/card_types/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<div class="page-header">
<%= link_to card_types_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to @card_type, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-info-sign"></span>
Voir la carte
<%= t(".show_card") %>
<% end %>
<h1>Modifier une carte</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
26 changes: 17 additions & 9 deletions app/views/card_types/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_card_type_path, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
Ajouter une carte
<%= t(".add_card") %>
<% end %>
<h1>Types de cartes</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>
<%= CardType.human_attribute_name(:name) %>
</th>
<th>
<%= CardType.human_attribute_name(:usage) %>
</th>
<th></th>
<th></th>
<th></th>
Expand All @@ -33,14 +39,16 @@
<tbody>
<%= content_tag_for(:tr, @card_types) do |card_type| %>
<td style="<%= "font-weight:bold;" if card_type.max_aligned_ports %>"><%= card_type %></td>
<td><%= pluralize card_type.servers.count, 'serveur' %></td>
<td><%= card_type.port_quantity %> ports</td>
<td><%= link_to 'Modifier', edit_card_type_path(card_type), class: 'btn btn-primary' %></td>
<td><%= CardType.human_attribute_name(:servers, count: card_type.servers.count) %></td>
<td>
<%= link_to 'Supprimer',
<%= CardType.human_attribute_name(:port_quantity, count: card_type.port_quantity) %>
</td>
<td><%= link_to t("action.edit"), edit_card_type_path(card_type), class: 'btn btn-primary' %></td>
<td>
<%= link_to t("action.delete"),
card_type,
method: :delete,
data: { confirm: 'Ce type de carte ne pourra pas être supprimé tant qu\'il sera associé à au moins un serveur (via une carte). Voulez-vous continuer ?' },
data: { confirm: t(".delete_confirmation") },
class: 'btn btn-danger' %>
</td>
<% end %>
Expand Down
6 changes: 4 additions & 2 deletions app/views/card_types/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="page-header">
<%= link_to card_types_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<h1>Nouvelle carte</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
20 changes: 14 additions & 6 deletions app/views/card_types/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
<div class="page-header">
<%= link_to card_types_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to edit_card_type_path(@card_type), class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-pencil"></span>
Edit
<%= t("action.edit") %>
<% end %>
<h1>Voir card type</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<dl class="dl-horizontal">
<dt>Nom :</dt>
<dt>
<%= CardType.human_attribute_name(:name) %> :
</dt>
<dd><%= @card_type %></dd>

<dt>Type de port :</dt>
<dt>
<%= CardType.model_name.human %> :
</dt>
<dd><%= @card_type.port_type.try(:name) %></dd>

<dt>Nombre de ports :</dt>
<dt>
<%= CardType.human_attribute_name(:port_quantity_label) %> :
</dt>
<dd><%= @card_type.port_quantity %></dd>

</dl>
16 changes: 16 additions & 0 deletions config/locales/activerecord.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ fr:
errors_count:
one: 1 erreur
other: "%{count} erreurs"
card_type:
name: Nom
usage: Usage
servers:
zero: 0 serveurs
one: 1 serveur
other: "%{count} serveurs"
port_quantity_label: Nombre de ports
port_quantity:
one: 1 port
other: "%{count} ports"
port_type: Type de port
columns: Colonnes
rows: Lignes
max_aligned_ports: Nombre max de ports alignés
first_position: Numéro du premier port
errors:
models:
user:
Expand Down
23 changes: 23 additions & 0 deletions 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
save: Enregistrer
breadcrumb:
settings: Paramètres
pages:
Expand Down Expand Up @@ -37,6 +39,27 @@ fr:
destroy:
flashes:
destroyed: Site a bien été supprimé.
card_types:
index:
title: Types de cartes
add_card: Ajouter une carte
delete_confirmation: Ce type de carte ne pourra pas être supprimé tant qu'il sera associé à au moins un serveur (via une carte). Voulez-vous continuer ?
show:
title: Voir card type
new:
title: Nouvelle carte
create:
flashes:
created: card_type was successfully created.
edit:
show_card: Voir la carte
title: Modifier une carte
update:
flashes:
updated: card_type was successfully updated.
destroy:
flashes:
destroyed: card_type a bien été supprimé.

devise:
registrations:
Expand Down

0 comments on commit 57b0830

Please sign in to comment.