Skip to content

Commit af5ef06

Browse files
committed
Use translation keys for Pages
1 parent d285fda commit af5ef06

File tree

8 files changed

+75
-18
lines changed

8 files changed

+75
-18
lines changed

app/controllers/better_together/pages_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create
3737
authorize @page
3838

3939
if @page.save
40-
redirect_to edit_page_path(@page), notice: 'Page was successfully created.'
40+
redirect_to edit_page_path(@page), notice: t('pages.created')
4141
else
4242
render :new
4343
end
@@ -53,11 +53,11 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
5353
respond_to do |format|
5454
if @page.update(page_params)
5555
format.html do
56-
flash[:notice] = 'Page was successfully updated.'
57-
redirect_to edit_page_path(@page), notice: 'Page was successfully updated.'
56+
flash[:notice] = t('pages.updated')
57+
redirect_to edit_page_path(@page), notice: t('pages.updated')
5858
end
5959
format.turbo_stream do
60-
flash.now[:notice] = 'Page was successfully updated.'
60+
flash.now[:notice] = t('pages.updated')
6161
render turbo_stream: [
6262
turbo_stream.replace(helpers.dom_id(@page, 'form'), partial: 'form',
6363
locals: { page: @page }),
@@ -77,7 +77,7 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
7777
def destroy
7878
authorize @page
7979
@page.destroy
80-
redirect_to pages_url, notice: 'Page was successfully destroyed.'
80+
redirect_to pages_url, notice: t('pages.destroyed')
8181
end
8282

8383
protected

app/views/better_together/pages/_form.html.erb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</div>
1010
<% if page.persisted? %>
1111
<div class="btn-group" role="group" aria-label="Third group">
12-
<%= link_to 'View Page', render_page_path(page), class: 'btn btn-info', target: "_#{dom_id(page, 'view')}" %>
12+
<%= link_to t('.view_page'), render_page_path(page), class: 'btn btn-info', target: "_#{dom_id(page, 'view')}" %>
1313
</div>
1414
<% end %>
1515
</div>
@@ -19,7 +19,7 @@
1919

2020
<% if page.errors.any? %>
2121
<div class="alert alert-danger">
22-
<h4>Please correct the following errors:</h4>
22+
<h4><%= t('.validation_errors_heading') %></h4>
2323
<ul>
2424
<% page.errors.full_messages.each do |msg| %>
2525
<li><%= msg %></li>
@@ -31,9 +31,9 @@
3131
<% if page.protected %>
3232
<div class="row">
3333
<div class="col mb-3">
34-
<span class="badge bg-danger"><strong>Protected</strong></span>
34+
<span class="badge bg-danger"><strong><%= t('.protected') %></strong></span>
3535
<div class="text-danger mt-1">
36-
This record is protected and cannot be deleted.
36+
<%= t('.protected_message') %>
3737
</div>
3838
</div>
3939
</div>
@@ -42,7 +42,7 @@
4242
<div class="row mb-3 row-cols-1 row-cols-sm-2">
4343
<div class="col mb-3 pb-3 border-bottom align-self-top">
4444
<%= render partial: 'better_together/shared/translated_string_field', locals: { model: page, form: form, attribute: 'title' } %>
45-
<small class="form-text text-muted mt-2">Enter the page title.</small> <!-- Help text added here -->
45+
<small class="form-text text-muted mt-2"><%= t('.enter_page_title_help') %></small> <!-- Help text added here -->
4646
</div>
4747

4848
<div class="col mb-3 pb-3 border-bottom align-self-top">
@@ -111,7 +111,7 @@
111111
</div>
112112

113113
<div class="col mb-3 pb-3 border-bottom">
114-
<%= form.label :sidebar_nav_id, 'Sidebar Navigation' %>
114+
<%= form.label :sidebar_nav_id, t('.sidebar_navigation') %>
115115
<%= form.collection_select :sidebar_nav_id, BetterTogether::NavigationArea.all, :id, :name, { include_blank: true }, { class: ('form-select' + (page.errors[:sidebar_nav_id].any? ? ' is-invalid' : '')), data: { controller: "better_together--slim-select" } } %>
116116
<% if page.errors[:sidebar_nav_id].any? %>
117117
<div class="invalid-feedback">
@@ -128,7 +128,7 @@
128128
<div class="row my-3">
129129
<div class="col">
130130
<div class="row">
131-
<h2>Page Blocks</h2>
131+
<h2><%= t('.page_blocks') %></h2>
132132

133133
<div id="blocks-list" data-controller="better_together--page-blocks" data-page-blocks-target="blocks">
134134
<!-- Render existing PageBlocks -->
@@ -140,7 +140,7 @@
140140
<div class="accordion-item">
141141
<h2 class="accordion-header" id="add-block-heading">
142142
<button class="accordion-button collapsed bg-secondary btn btn-success" type="button" data-bs-toggle="collapse" data-bs-target="#available-block-types" aria-expanded="false" aria-controls="available-block-types">
143-
Add Block
143+
<%= t('.add_block') %>
144144
</button>
145145
</h2>
146146
<div id="available-block-types" class="accordion-collapse collapse" aria-labelledby="add-block-heading" data-bs-parent="#new-page-block-choices">

app/views/better_together/pages/_page_row.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
<td><%= page.published? ? t('globals.published') : t('globals.draft') %></td>
66
<td class="text-end">
77
<% if policy(page).show? %>
8-
<%= link_to render_page_path(page), class: 'btn btn-outline-info btn-sm me-1', 'aria-label' => 'Show Page' do %>
8+
<%= link_to render_page_path(page), class: 'btn btn-outline-info btn-sm me-1', 'aria-label' => t('.show_page') do %>
99
<i class="fas fa-eye"></i> <%= t('globals.show') %>
1010
<% end %>
1111
<% end %>
1212
<% if policy(page).update? %>
13-
<%= link_to edit_page_path(page), class: 'btn btn-outline-secondary btn-sm me-1', 'aria-label' => 'Edit Page' do %>
13+
<%= link_to edit_page_path(page), class: 'btn btn-outline-secondary btn-sm me-1', 'aria-label' => t('.edit_page') do %>
1414
<i class="fas fa-edit"></i> <%= t('globals.edit') %>
1515
<% end %>
1616
<% end %>
1717
<% if policy(page).destroy? %>
18-
<%= link_to page_path(page), method: :delete, data: { 'turbo-method': 'delete', turbo_confirm: t('pages.confirm_destroy') }, class: 'btn btn-outline-danger btn-sm', 'aria-label' => 'Destroy Page' do %>
18+
<%= link_to page_path(page), method: :delete, data: { 'turbo-method': 'delete', turbo_confirm: t('pages.confirm_destroy') }, class: 'btn btn-outline-danger btn-sm', 'aria-label' => t('.destroy_page') do %>
1919
<i class="fas fa-trash-alt"></i> <%= t('globals.destroy') %>
2020
<% end %>
2121
<% end %>

app/views/better_together/pages/edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="container-fluid my-3">
2626
<div class="row">
2727
<div class="col">
28-
<h1>Edit Page</h1>
28+
<h1><%= t('.title') %></h1>
2929
<%= render 'form', page: @page %>
3030
</div>
3131
</div>

app/views/better_together/pages/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="container my-3">
77
<div class="row">
88
<div class="col">
9-
<h1>New Page</h1>
9+
<h1><%= t('.title') %></h1>
1010
<%= render 'form', page: @page %>
1111
</div>
1212
</div>

config/locales/en.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,10 +821,26 @@ en:
821821
title: "%{sender}: %{conversation}"
822822
time_ago: "%{time} ago"
823823
pages:
824+
new:
825+
title: New Page
826+
edit:
827+
title: Edit Page
824828
form:
825829
create_page_before_adding_content: Create page before adding content
830+
validation_errors_heading: Please correct the following errors:
831+
view_page: View Page
832+
protected: Protected
833+
protected_message: This record is protected and cannot be deleted.
834+
enter_page_title_help: Enter the page title.
835+
sidebar_navigation: Sidebar Navigation
836+
page_blocks: Page Blocks
837+
add_block: Add Block
826838
index:
827839
new_page: New page
840+
page_row:
841+
show_page: Show Page
842+
edit_page: Edit Page
843+
destroy_page: Destroy Page
828844
people:
829845
device_permissions:
830846
camera: Camera
@@ -1433,6 +1449,9 @@ en:
14331449
format:
14341450
delimiter: ''
14351451
pages:
1452+
created: Page was successfully created.
1453+
updated: Page was successfully updated.
1454+
destroyed: Page was successfully destroyed.
14361455
confirm_destroy: Confirm destroy
14371456
partners:
14381457
confirm_delete: Confirm delete

config/locales/es.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,10 +824,26 @@ es:
824824
title: "%{sender}: %{conversation}"
825825
time_ago: hace %{time}
826826
pages:
827+
new:
828+
title: Nueva página
829+
edit:
830+
title: Editar página
827831
form:
828832
create_page_before_adding_content: Crear página antes de agregar contenido
833+
validation_errors_heading: Corrige los siguientes errores:
834+
view_page: Ver página
835+
protected: Protegido
836+
protected_message: Este registro está protegido y no se puede eliminar.
837+
enter_page_title_help: Ingresa el título de la página.
838+
sidebar_navigation: Navegación lateral
839+
page_blocks: Bloques de página
840+
add_block: Agregar bloque
829841
index:
830842
new_page: Nueva página
843+
page_row:
844+
show_page: Mostrar página
845+
edit_page: Editar página
846+
destroy_page: Eliminar página
831847
people:
832848
device_permissions:
833849
camera: Camera
@@ -1425,6 +1441,9 @@ es:
14251441
format:
14261442
delimiter: ''
14271443
pages:
1444+
created: La página se creó correctamente.
1445+
updated: La página se actualizó correctamente.
1446+
destroyed: La página se eliminó correctamente.
14281447
confirm_destroy: Confirmar destrucción
14291448
partners:
14301449
confirm_delete: Confirmar eliminación

config/locales/fr.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,10 +827,26 @@ fr:
827827
title: "%{sender}: %{conversation}"
828828
time_ago: il y a %{time}
829829
pages:
830+
new:
831+
title: Nouvelle page
832+
edit:
833+
title: Modifier la page
830834
form:
831835
create_page_before_adding_content: Créez une page avant d'ajouter du contenu
836+
validation_errors_heading: Veuillez corriger les erreurs suivantes :
837+
view_page: Voir la page
838+
protected: Protégé
839+
protected_message: Cet enregistrement est protégé et ne peut pas être supprimé.
840+
enter_page_title_help: Entrez le titre de la page.
841+
sidebar_navigation: Navigation latérale
842+
page_blocks: Blocs de page
843+
add_block: Ajouter un bloc
832844
index:
833845
new_page: Nouvelle page
846+
page_row:
847+
show_page: Afficher la page
848+
edit_page: Modifier la page
849+
destroy_page: Supprimer la page
834850
people:
835851
device_permissions:
836852
camera: Camera
@@ -1447,6 +1463,9 @@ fr:
14471463
format:
14481464
delimiter: ''
14491465
pages:
1466+
created: La page a été créée avec succès.
1467+
updated: La page a été mise à jour avec succès.
1468+
destroyed: La page a été supprimée avec succès.
14501469
confirm_destroy: Confirmer la destruction
14511470
partners:
14521471
confirm_delete: Confirmer la suppression

0 commit comments

Comments
 (0)