Skip to content

Commit

Permalink
275817 - Use i18n islet resource (nanego#79)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximilien Bausson <[email protected]>
Co-authored-by: Nicolas Brousse <[email protected]>
  • Loading branch information
3 people committed Dec 20, 2023
1 parent 1990847 commit 8273c5c
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 40 deletions.
6 changes: 3 additions & 3 deletions app/controllers/islets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create

respond_to do |format|
if @islet.save
format.html { redirect_to islets_url, notice: 'Islet was successfully created.' }
format.html { redirect_to islets_url, notice: t('.flashes.created') }
format.json { render :show, status: :created, location: @islet }
else
format.html { render :new }
Expand All @@ -68,7 +68,7 @@ def create
def update
respond_to do |format|
if @islet.update(islet_params)
format.html { redirect_to islets_url, notice: 'Islet was successfully updated.' }
format.html { redirect_to islets_url, notice: t('.flashes.updated') }
format.json { render :show, status: :ok, location: @islet }
else
format.html { render :edit }
Expand All @@ -82,7 +82,7 @@ def update
def destroy
if @islet.destroy
respond_to do |format|
format.html { redirect_to islets_url, notice: 'Islet a bien été supprimé.' }
format.html { redirect_to islets_url, notice: t('.flashes.destroyed') }
format.json { head :no_content }
end
else
Expand Down
18 changes: 9 additions & 9 deletions app/views/islets/_export_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Exports <span class="caret"></span>
<%= t('export_button.label') %> <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">

<li class="dropdown-submenu pull-left">
<%= link_to islet_path(islet, format: 'pdf', view: 'front', bg: ''), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Export PDF
<%= t('export_button.exports.pdf') %>
<% end %>
<ul class="dropdown-menu dropdown-menu-left">
<li>
<%= link_to islet_path(islet, format: 'pdf', view: 'front', bg: ''), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Face avant
<%= t('export_button.faces.front') %>
<% end %>
</li>
<li>
<%= link_to islet_path(islet, format: 'pdf', view: 'back', bg: ''), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Face arrière
<%= t('export_button.faces.back') %>
<% end %>
</li>
<li>
<%= link_to islet_path(islet, format: 'pdf', view: 'front', bg: 'cablage'), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Cablage - Face avant
<%= t('export_button.faces.front_wiring') %>
<% end %>
</li>
<li>
<%= link_to islet_path(islet, format: 'pdf', view: 'back', bg: 'cablage'), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Cablage - Face arrière
<%= t('export_button.faces.back_wiring') %>
<% end %>
</li>
</ul>
</li>

<li><%= link_to islet_path(islet, format: 'txt', view: '', bg: '') do %>
<span class="glyphicon glyphicon-text-background" aria-hidden="true"></span>
Export Txt
<%= t('export_button.exports.txt') %>
<% end %>
</li>

<li><%= link_to islet_path(islet, format: 'pdf', view: 'front', bg: '', debug: '1'), target: :_blank do %>
<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
Impression
<%= t('export_button.exports.print') %>
<% end %>
</li>

<li role="separator" class="divider"></li>

<li><%= link_to ports_path(room_id: islet.room.id, islet: islet.name) do %>
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
Liste des ports
<%= t('export_button.port_list') %>
<% end %>
</li>

Expand Down
8 changes: 4 additions & 4 deletions app/views/islets/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% if @islet.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(@islet.errors.count, "erreur", "erreurs") %> lors de la sauvegarde :</h4>
<h4><%= t("form.errors.title", count: @islet.errors.count) %></h4>

<ul>
<% @islet.errors.full_messages.each do |msg| %>
Expand All @@ -13,20 +13,20 @@
<% end %>

<div class="form-group">
<%= f.label 'Nom', class: "col-sm-2 control-label" %>
<%= f.label :name, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :name, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label 'Salle', class: "col-sm-2 control-label" %>
<%= f.label :room, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.select :room_id, options_from_collection_for_select(Room.order(:position), :id, :name_with_site, @islet.room_id), class: "form-control" %>
</div>
</div>

<div class="form-group">
<%= f.label 'Position', class: "col-sm-2 control-label" %>
<%= f.label :position, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :position, class: "form-control" %>
</div>
Expand Down
10 changes: 6 additions & 4 deletions app/views/islets/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("inventories") => modeles_url,
'Ilôts' => sites_path,
Islet.model_name.human.pluralize => sites_path,
"#{@islet} - #{@islet.room}" => ''
} %>

<div class="container">
<div class="page-header">
<%= link_to islets_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t('action.back') %>
<% end %>
<%= link_to @islet, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-info-sign"></span>
Voir
<%= t("action.show") %>
<% end %>
<h1>Modification îlot <%= "#{@islet.name} - #{@islet.room}"%> </h1>
<h1>
<%= t('.title', name: @islet.name, room: @islet.room) %>
</h1>
</div>

<%= render 'form' %>
Expand Down
39 changes: 27 additions & 12 deletions app/views/islets/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: { t("inventories") => islets_url, 'Ilots' => '' } %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t('inventories') => islets_url,
Islet.model_name.human.pluralize => ''
} %>

<div class="container-fluid">

Expand All @@ -13,20 +16,32 @@
<div class="page-header">
<%= link_to new_islet_path, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
Ajouter un ilot
<%= t('.add_islet') %>
<% end %>
<h1>Ilots</h1>
<h1>
<%= Islet.model_name.human.pluralize %>
</h1>
</div>

<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Site</th>
<th>Salle</th>
<th>Ilot</th>
<th>Position</th>
<th>Nombre de châssis</th>
<th>
<%= Site.model_name.human %>
</th>
<th>
<%= Room.model_name.human %>
</th>
<th>
<%= Islet.model_name.human %>
</th>
<th>
<%= Islet.human_attribute_name(:position) %>
</th>
<th>
<%= Frame.model_name.human.pluralize %>
</th>
<th></th>
</tr>
</thead>
Expand All @@ -43,14 +58,14 @@
<%= link_to islet, islet_path(islet) %>
</b></td>
<td><%= islet.position %></td>
<td><%= islet.frames.count.to_s + ' chassis' %></td>
<td><%= Islet.human_attribute_name(:frames_count, count: islet.frames.count) %></td>
<td class="text-right">
<%= render partial: "islets/export_button", locals: { islet: islet } %>
<%= link_to 'Modifier', edit_islet_path(islet), class: 'btn btn-primary' %>
<%= link_to 'Supprimer',
<%= link_to t("action.edit"), edit_islet_path(islet), class: 'btn btn-primary' %>
<%= link_to t("action.delete"),
islet,
method: :delete,
data: { confirm: 'Cet ilôt ne pourra pas être supprimé tant qu\'il sera associé à au moins une baie. Voulez-vous continuer ?' },
data: { confirm: t('.delete_confirmation') },
class: 'btn btn-danger' %>
</td>
<% end %>
Expand Down
10 changes: 6 additions & 4 deletions app/views/islets/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("inventories") => modeles_url,
'Ilôts' => islets_path,
"Nouvel ilôt" => ''
Islet.model_name.human.pluralize => islets_path,
t(".title") => ''
} %>

<div class="container">
<div class="page-header">
<%= link_to islets_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<h1>Nouvel îlot</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym "RESTful"
# end

ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable "châssis"
end
11 changes: 10 additions & 1 deletion config/locales/activerecord.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ fr:
room: Salle
islet: Ilot
bay: Baies
frame: Châssis
frame:
one: Châssis
other: Châssis
modele: Modèle
category: Catégorie
architecture: Architecture
Expand All @@ -34,6 +36,13 @@ fr:
other: Types de RAM

attributes:
islet:
name: Nom
room: Salle
position: Position
frames_count:
one: 1 châssis
other: '%{count} châssis'
maintenance_contract:
server_id: Serveur
start_date: Date de début
Expand Down
33 changes: 30 additions & 3 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fr:
false: Non
form:
errors:
title: '%{count} erreurs lors de la sauvegarde :'
title: "%{count} erreurs lors de la sauvegarde :"
submit: Valider
action:
edit: Modifier
Expand All @@ -15,8 +15,35 @@ fr:
save: Enregistrer
cancel: Annuler
confirm: Are you sure ?
breadcrumb:
disk_type: Disk type
export_button:
label: Exports
exports:
pdf: Export pdf
txt: Export Txt
print: Impression
faces:
front: Face avant
back: Face arrière
front_wiring: Cablage - Face avant
back_wiring: Cablage - Face arrière
port_list: Liste des ports
islets:
index:
add_islet: Ajouter un ilot
delete_confirmation: Cet ilôt ne pourra pas être supprimé tant qu'il sera associé à au moins une baie. Voulez-vous continuer ?
new:
title: Nouvel îlot
create:
flashes:
created: L'ilôt a bien été créé.
edit:
title: Modification îlot %{name} - %{room}
update:
flashes:
updated: L'ilôt a bien été modifié.
destroy:
flashes:
destroyed: L'ilôt a bien été supprimé.
pages:
params_menu:
location:
Expand Down

0 comments on commit 8273c5c

Please sign in to comment.