Skip to content

Commit

Permalink
Added translations for cluster 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 79147be
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/controllers/clusters_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 @cluster.save
format.html { redirect_to @cluster, notice: 'Cluster was successfully created.' }
format.html { redirect_to @cluster, notice: t(".flashes.created") }
format.json { render :show, status: :created, location: @cluster }
else
format.html { render :new }
Expand All @@ -42,7 +42,7 @@ def create
def update
respond_to do |format|
if @cluster.update(cluster_params)
format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }
format.html { redirect_to @cluster, notice: t(".flashes.updated") }
format.json { render :show, status: :ok, location: @cluster }
else
format.html { render :edit }
Expand All @@ -56,7 +56,7 @@ def update
def destroy
if @cluster.destroy
respond_to do |format|
format.html { redirect_to clusters_url, notice: 'Cluster a bien été supprimé.' }
format.html { redirect_to clusters_url, notice: t(".flashes.destroyed") }
format.json { head :no_content }
end
else
Expand Down
12 changes: 8 additions & 4 deletions app/views/clusters/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<%= form_for(@cluster, html: { class: "form-horizontal", role: "form" }) do |f| %>
<% if @cluster.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(@cluster.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("breadcrumb.close") %>
</span></button>
<h4>
<%= t("form.errors.title", count: @cluster.errors.count) %>
</h4>

<ul>
<% @cluster.errors.full_messages.each do |msg| %>
Expand All @@ -13,14 +17,14 @@
<% 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">
<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 %>
8 changes: 5 additions & 3 deletions app/views/clusters/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<div class="page-header">
<%= link_to clusters_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to @cluster, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-info-sign"></span>
Voir
<%= t("breadcrumb.show") %>
<% end %>
<h1>Modifier le cluster</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
Expand Down
23 changes: 15 additions & 8 deletions app/views/clusters/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, 'Clusters' => '' } %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("breadcrumb.settings") => modeles_url,
t("breadcrumb.clusters") => "" }
%>

<div class="container-fluid">

Expand All @@ -13,16 +16,20 @@
<div class="page-header">
<%= link_to new_cluster_path, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
New Cluster
<%= t(".new_cluster") %>
<% end %>
<h1>Listing clusters</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>
<%= Cluster.human_attribute_name(:name) %>
</th>
<th></th>
<th></th>
<th></th>
Expand All @@ -34,13 +41,13 @@
<%= content_tag_for(:tr, @clusters) do |cluster| %>
<td><%= cluster %></td>
<td><%= cluster.servers.count %> serveurs</td>
<td><%= link_to 'Voir', cluster_path(cluster), class: 'btn btn-primary' %></td>
<td><%= link_to 'Modifier', edit_cluster_path(cluster), class: 'btn btn-primary' %></td>
<td><%= link_to t("action.show"), cluster_path(cluster), class: 'btn btn-primary' %></td>
<td><%= link_to t("action.edit"), edit_cluster_path(cluster), class: 'btn btn-primary' %></td>
<td>
<%= link_to 'Supprimer',
<%= link_to t("action.delete"),
cluster,
method: :delete,
data: { confirm: 'Ce cluster 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/clusters/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="page-header">
<%= link_to clusters_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<h1>New cluster</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
8 changes: 5 additions & 3 deletions app/views/clusters/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<div class="page-header">
<%= link_to clusters_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to edit_cluster_path(@cluster), class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-pencil"></span>
Modifier
<%= t("action.edit") %>
<% end %>
<h1>Cluster <%= @cluster %></h1>
<h1>
<%= t(".title", cluster: @cluster) %>
</h1>
</div>

<ul>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/activerecord.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ fr:
errors_count:
one: 1 erreur
other: "%{count} erreurs"
cluster:
name: Nom
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 @@ -9,6 +9,9 @@ fr:
back: Retour
breadcrumb:
settings: Paramètres
clusters: Clusters
show: Voir
close: Fermer
pages:
params_menu:
location:
Expand Down Expand Up @@ -37,6 +40,26 @@ fr:
destroy:
flashes:
destroyed: Site a bien été supprimé.
clusters:
index:
new_cluster: Nouveau cluster
title: Listing clusters
delete_confirmation: Ce cluster ne pourra pas être supprimé tant qu'il sera associé à au moins un serveur. Voulez-vous continuer ?
show:
title: Cluster %{cluster}
new:
title: Nouveau cluster
create:
flashes:
created: Cluster was successfully created.
edit:
title: Modifier le cluster
update:
flashes:
updated: Cluster was successfully updated.
destroy:
flashes:
destroyed: Cluster a bien été supprimé.

devise:
registrations:
Expand Down

0 comments on commit 79147be

Please sign in to comment.