Skip to content

Commit

Permalink
Added translations for stack resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilien Bausson committed Oct 12, 2023
1 parent db0dd87 commit d95024d
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 25 deletions.
6 changes: 3 additions & 3 deletions app/controllers/stacks_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 @stack.save
format.html { redirect_to stacks_path, notice: 'Stack was successfully created.' }
format.html { redirect_to stacks_path, notice: t(".flashes.created") }
format.json { render :show, status: :created, location: @stack }
else
format.html { render :new }
Expand All @@ -42,7 +42,7 @@ def create
def update
respond_to do |format|
if @stack.update(stack_params)
format.html { redirect_to stacks_path, notice: 'Stack was successfully updated.' }
format.html { redirect_to stacks_path, notice: t(".flashes.updated") }
format.json { render :show, status: :ok, location: @stack }
else
format.html { render :edit }
Expand All @@ -56,7 +56,7 @@ def update
def destroy
if @stack.destroy
respond_to do |format|
format.html { redirect_to stacks_url, notice: 'Stack a bien été supprimé.' }
format.html { redirect_to stacks_url, notice: t(".flashes.destroyed") }
format.json { head :no_content }
end
else
Expand Down
14 changes: 9 additions & 5 deletions app/views/stacks/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<%= form_for(@stack, html: { class: "form-horizontal", role: "form" }) do |f| %>
<% if @stack.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(@stack.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: @stack.errors.count) %>
</h4>

<ul>
<% @stack.errors.full_messages.each do |msg| %>
Expand All @@ -13,20 +17,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 'Couleur', class: "col-sm-2 control-label" %>
<%= f.label :color, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :color, class: "form-control" %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit 'Valider', class: "btn btn-primary" %>
<%= f.submit t("form.submit"), class: "btn btn-primary" %>
</div>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/stacks/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="page-header">
<%= link_to stacks_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.edit") %>
<% end %>
<h1>Modifier une stack</h1>
</div>
Expand Down
27 changes: 18 additions & 9 deletions app/views/stacks/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, 'Salles' => ''} %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("breadcrumb.settings") => modeles_url,
t("breadcrumb.rooms") => "" }
%>

<div class="container-fluid">

Expand All @@ -13,17 +16,23 @@
<div class="page-header">
<%= link_to new_stack_path, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
Ajouter un stack
<%= t(".new_stack") %>
<% end %>
<h1>Stacks</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>Couleur</th>
<th>
<%= Stack.human_attribute_name(:name) %>
</th>
<th>
<%= Stack.human_attribute_name(:color) %>
</th>
<th></th>
<th></th>
<th></th>
Expand All @@ -34,13 +43,13 @@
<%= content_tag_for(:tr, @stacks) do |stack| %>
<td><%= stack.name %></td>
<td><%= stack.color %></td>
<td><%= pluralize stack.servers.count, 'machine' %></td>
<td><%= link_to 'Modifier', edit_stack_path(stack), class: 'btn btn-default' %></td>
<td><%= Stack.human_attribute_name(:servers, count: stack.servers.count) %></td>
<td><%= link_to t("action.edit"), edit_stack_path(stack), class: 'btn btn-default' %></td>
<td>
<%= link_to 'Supprimer',
<%= link_to t("action.delete"),
stack,
method: :delete,
data: { confirm: 'Ce stack 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
6 changes: 4 additions & 2 deletions app/views/stacks/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="page-header">
<%= link_to stacks_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<h1>Nouvelle stack</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
16 changes: 11 additions & 5 deletions app/views/stacks/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<div class="page-header">
<%= link_to stacks_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to edit_stack_path(@stack), class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-pencil"></span>
Modifier
<%= t("action.edit") %>
<% end %>
<h1>Stack</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

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

<dl class="dl-horizontal">
<dt>Couleur :</dt>
<dt>
<%= Stack.human_attribute_name(:color) %> :
</dt>
<dd><%= @stack.color %></dd>
</dl>
6 changes: 6 additions & 0 deletions config/locales/activerecord.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ fr:
errors_count:
one: 1 erreur
other: "%{count} erreurs"
stack:
name: Nom
color: Couleur
servers:
one: "%{count} machine"
other: "%{count} machines"
errors:
models:
user:
Expand Down
22 changes: 22 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ fr:
edit: Modifier
delete: Supprimer
back: Retour
close: Fermer
breadcrumb:
settings: Paramètres
rooms: Salles
pages:
params_menu:
location:
Expand Down Expand Up @@ -37,6 +39,26 @@ fr:
destroy:
flashes:
destroyed: Site a bien été supprimé.
stacks:
index:
new_stack: Ajouter un stack
title: Stacks
delete_confirmation: Ce stack ne pourra pas être supprimé tant qu'il sera associé à au moins un serveur. Voulez-vous continuer ?
show:
title: Stack
new:
title: Nouvelle stack
create:
flashes:
created: Stack was successfully created.
edit:
title: Modifier une stack
update:
flashes:
updated: Stack was successully updated.
destroy:
flashes:
destroyed: Stack a bien été supprimé.

devise:
registrations:
Expand Down

0 comments on commit d95024d

Please sign in to comment.