Skip to content

Commit

Permalink
Added translations for frame resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilien Bausson committed Oct 6, 2023
1 parent eb73e2c commit 9bbc3a8
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 41 deletions.
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ GEM
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
libv8-node (18.16.0.0-arm64-darwin)
libv8-node (18.16.0.0-x86_64-darwin)
libv8-node (18.16.0.0-x86_64-linux)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand Down Expand Up @@ -237,6 +238,8 @@ GEM
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
omniauth (2.1.1)
Expand Down Expand Up @@ -480,6 +483,7 @@ GEM

PLATFORMS
arm64-darwin-22
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/frames_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def update
@frame = Frame.friendly.find(params[:id].to_s.downcase)
respond_to do |format|
if @frame.update(frame_params)
format.html { redirect_to room_path(@frame.room), notice: 'Le châssis a été mis à jour.' }
format.html { redirect_to room_path(@frame.room), notice: t(".flashes.updated") }
format.json { render :show, status: :ok, location: @frame }
else
format.html { render :edit }
Expand All @@ -47,7 +47,7 @@ def create

respond_to do |format|
if @frame.save
format.html { redirect_to frames_path, notice: 'Le châssis a été ajouté.' }
format.html { redirect_to frames_path, notice: t(".flashes.created") }
format.json { render :show, status: :created, location: @frame }
else
format.html { render :new }
Expand All @@ -71,7 +71,7 @@ def destroy
@frame = Frame.friendly.find(params[:id].to_s.downcase)
if @frame.destroy
respond_to do |format|
format.html { redirect_to frames_url, notice: 'Frame a bien été supprimé.' }
format.html { redirect_to frames_url, notice: t(".flashes.destroyed") }
format.json { head :no_content }
end
else
Expand All @@ -97,7 +97,7 @@ def network
@servers_per_frames = {}

@frames.each do |frame|
islet = "Vue réseau"
islet = t(".title")
@servers_per_frames[islet] ||= {}
@servers_per_frames[islet][0] ||= {}
@servers_per_frames[islet][0][frame.bay] ||= {}
Expand Down
22 changes: 15 additions & 7 deletions app/views/frames/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<%= form_for(@frame, html: { class: "form-horizontal", role: "form" }) do |f| %>
<% if @frame.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(@frame.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("errors.title", count: @frame.errors.count) %>
</h4>

<ul>
<% @frame.errors.full_messages.each do |msg| %>
Expand All @@ -13,7 +21,7 @@
<% 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>
Expand Down Expand Up @@ -42,22 +50,22 @@

<% if @frame.persisted? %>
<div class="form-group">
<%= f.label 'Baie couplée à', class: "col-sm-2 control-label" %>
<%= f.label t(".coupled_bay_label"), class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.object.other_frame.present? ? link_to(f.object.other_frame.name, frame_path(f.object.other_frame)) : "Aucune baie couplée" %>
<%= f.object.other_frame.present? ? link_to(f.object.other_frame.name, frame_path(f.object.other_frame)) : t(".no_coupled_bay") %>
</div>
</div>
<% end %>
<div class="form-group">
<%= f.label 'Baie', class: "col-sm-2 control-label" %>
<%= f.label Bay.model_name.human, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.select :bay_id, options_from_collection_for_select(Bay.all, :id, :detailed_name, @frame.bay_id), 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 %>
6 changes: 5 additions & 1 deletion app/views/frames/_show_complete_frame.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<div>
<div class="panel-islet">
<% if @room.present? %>
<div><h3>Salle <%= @room.name %> - Ilot <%= @frame.islet %></h3></div>
<div>
<h3>
<%= t(".title", room: @room, islet: @frame.islet) %>
</h3>
</div>
<% end %>

<div class="row">
Expand Down
10 changes: 6 additions & 4 deletions app/views/frames/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<%
breadcrumb_variables = {'Rooms' => overview_rooms_path,
breadcrumb_variables = { t("breadcrumb.rooms") => overview_rooms_path,
@frame.room.name => (@frame.present? ? room_path(@frame.room) : ''),
"Baie #{@frame.name}" => frame_path(@frame),
"Edition" => ''}
t("breadcrumb.bay.simple", name: @frame.name) => frame_path(@frame),
t("breadcrumb.edit") => ''}
%>
<%= render 'layouts/breadcrumb', breadcrumb_variables: breadcrumb_variables %>

<div class="page-header">
<h1>Modifier la baie <%= @frame.name %></h1>
<h1>
<%= t(".title", frame: @frame.name) %>
</h1>
</div>

<%= render 'form' %>
Expand Down
37 changes: 26 additions & 11 deletions app/views/frames/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: {'Paramètres' => modeles_url, 'Châssis' => ''} %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("breadcrumb.settings") => modeles_url,
t("breadcrumb.frames.label") => ''}
%>

<div class="container-fluid">

Expand All @@ -13,20 +16,32 @@
<div class="page-header">
<%= link_to new_frame_path, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
Ajouter un châssis
<%= t(".new_frame") %>
<% end %>
<h1>Tous les châssis</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>Matériels</th>
<th>Nombre de U</th>
<th>Room</th>
<th>Ilot</th>
<th>
<%= Frame.human_attribute_name(:name) %>
</th>
<th>
<%= Frame.human_attribute_name(:servers) %>
</th>
<th>
<%= Frame.human_attribute_name(:u) %>
</th>
<th>
<%= Frame.human_attribute_name(:room) %>
</th>
<th>
<%= Islet.model_name.human %>
</th>
<th></th>
<th></th>
</tr>
Expand All @@ -39,12 +54,12 @@
<td><%= frame.u %></td>
<td><%= frame.room.present? ? (link_to frame.room, frame.room) : frame.room %></td>
<td><%= frame.bay.present? ? frame.bay.islet : '' %></td>
<td><%= link_to 'Modifier', edit_frame_path(frame), class: 'btn btn-primary' %></td>
<td><%= link_to t("action.edit"), edit_frame_path(frame), class: 'btn btn-primary' %></td>
<td>
<%= link_to 'Supprimer',
<%= link_to t("action.delete"),
frame,
method: :delete,
data: { confirm: 'Ce châssis ne pourra pas être supprimé tant qu\'il sera associé à au moins un serveur. Voulez-vous continuer ?' },
data: { confirm: t(".delete_confirmation") },
class: 'btn btn-danger' %>
</td>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/frames/network.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

<% view_side = 'back' %>
<% settings = Frame.settings.merge({:min_height => view_side == 'back' ? 20 : 27}) %>
<% @room = "Vue réseau" %>
<% @room = t(".title") %>
<%= render 'rooms/action_buttons', view_side: params[:view] if formats != [:pdf] %>

<div id="<%= @room.try(:name).try(:parameterize).try(:underscore) %>">
<% @servers_per_frames.each do |islet, lanes| %>

<h3><%= "Vue réseau" %></h3>
<h3><%= t(".title") %></h3>
<div class="row">
<ul class="frames <%= view_side %>"
style="padding: 0;"
Expand Down
8 changes: 5 additions & 3 deletions app/views/frames/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<%
breadcrumb_variables = {'Salles' => overview_rooms_path,
"Nouveau chassis" => ''}
breadcrumb_variables = { t("breadcrumb.rooms") => overview_rooms_path,
t("breadcrumb.frames.new") => ''}
%>
<%= render 'layouts/breadcrumb', breadcrumb_variables: breadcrumb_variables %>

<div class="page-header">
<h1>Nouveau châssis</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
Expand Down
15 changes: 9 additions & 6 deletions app/views/frames/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<%
breadcrumb_variables = {'Salles' => overview_rooms_path, @room.name => ((@frame.present? || params[:islet].present?) ? room_path(@room, view: params[:view]) : '')}
breadcrumb_variables = {
t("breadcrumb.rooms") => overview_rooms_path,
@room.name => ((@frame.present? || params[:islet].present?) ? room_path(@room, view: params[:view]) : '')
}
if @frame.present? && @frame.bay.islet.name.present?
breadcrumb_variables["Ilot #{@frame.bay.islet.name}"] = room_path(@room, islet: @frame.bay.islet.name, view: params[:view])
breadcrumb_variables[t("breadcrumb.islet", name: @frame.bay.islet.name)] = room_path(@room, islet: @frame.bay.islet.name, view: params[:view])
elsif params[:islet].present?
breadcrumb_variables["Ilot #{params[:islet]}"] = ''
breadcrumb_variables[t("breadcrumb.islet", name: params[:islet])] = ''
end
breadcrumb_variables["Double baie #{@frame.bay}"] = room_path(@room, islet: @frame.bay.islet.name, 'bay-id': @frame.bay_id, view: params[:view]) if @frame.has_coupled_frame?
breadcrumb_variables["Baie #{@frame.name}"] = '' if @frame.present?
breadcrumb_variables[t("breadcrumb.bay.double", name: @frame.bay)] = room_path(@room, islet: @frame.bay.islet.name, 'bay-id': @frame.bay_id, view: params[:view]) if @frame.has_coupled_frame?
breadcrumb_variables[t("breadcrumb.bay.simple", name: @frame.name)] = '' if @frame.present?
%>
<%= render 'layouts/breadcrumb', breadcrumb_variables: breadcrumb_variables %>
<% provide(:title, "Baie #{@frame.name}") %>
<% provide(:title, t("breadcrumb.bay.simple", name: @frame.name)) %>

<div class="container-fluid" id="bay-container">
<%= render 'frames/show_complete_frame' %>
Expand Down
12 changes: 9 additions & 3 deletions app/views/servers/_modal_add_element_in_frame.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Ajouter un élément</h4>
<h4 class="modal-title" id="myModalLabel">
<%= t(".title") %>
</h4>
</div>
<div class="modal-body">
<%= form_for(Server.new(:name => "PatchPanel", :modele => Modele.where("name LIKE ?", '%Panel%').first, frame: (@frame ? @frame : nil)), html: { class: "form-horizontal", role: "form" }) do |f| %>
<% if @server.try(:errors).try(: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(@server.errors.count, "erreur", "erreurs") %> lors de la sauvegarde :</h4>
<h4>
<%= t("errors.title", count: @server.errors.count) %>
</h4>

<ul>
<% @server.errors.full_messages.each do |msg| %>
Expand Down Expand Up @@ -64,7 +68,9 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit 'Confirmer',class: "btn btn-primary" %>
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
<button type="button" class="btn btn-default" data-dismiss="modal">
<%= t("action.cancel") %>
</button>
</div>
</div>
<% end %>
Expand Down
57 changes: 57 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,82 @@
fr:
breadcrumb:
settings: Paramètres
frames:
label: Châssis
new: Nouveau châssis
rooms: Salles
bay:
simple: Baie %{name}
double: Double baie %{name}
edit: Edition
islet: Ilot %{name}
action:
edit: Modifier
delete: Supprimer
save: Enregistrer
close: Fermer
cancel: Annuler
errors:
title: "%{count} erreurs lors de la sauvegarde"
frames:
form:
coupled_bay_label: Baie couplée à
no_coupled_bay: Aucune baie couplée
show_complete_frame:
title: Salle %{room} - Ilot %{islet}
index:
new_frame: Ajouter un châssis
title: Tous les châssis
delete_confirmation: Ce châssis ne pourra pas être supprimé tant qu'il sera associé à au moins un serveur. Voulez-vous continuer ?
edit:
title: Modifier la baie %{frame}
update:
flashes:
updated: Le châssis a été mis à jour.
new:
title: Nouveau châssis
create:
flashes:
created: Le châssis a été ajouté.
destroy:
flashes:
destroyed: Frame a bien été supprimé.
network:
title: Vue réseau
servers:
modal_add_element_in_frame:
title: Ajouter un élément
activerecord:
models:
maintenance_contract: Contrat de maintenance
server: Serveur
maintainer: Mainteneur
contract_type: Type de contrat
islet: Ilot
bay: Baie
attributes:
maintenance_contract:
server_id: Serveur
start_date: Date de début
end_date: Date de fin
maintainer_id: Mainteneur
contract_type_id: Type de contrat
frame:
name: Nom
servers: Matériels
room: Salle
position: Position
server:
nom: Nom
numero: Numéro de série
modele_id: Modele
errors:
models:
user:
attributes:
email:
invalid: L'adresse email est invalide

devise:
registrations:
signed_up: 'Vous pouvez désormais vous connecter avec Cerbère'
Expand Down

0 comments on commit 9bbc3a8

Please sign in to comment.