Use lazy translation lookups for redactions

Requires renaming the translation keys
This commit is contained in:
Andy Allan 2018-04-25 14:39:37 +08:00
parent 4a9846b078
commit 2c7bc36493
6 changed files with 25 additions and 28 deletions

View file

@ -25,7 +25,7 @@ class RedactionsController < ApplicationController
# note that the description format will default to 'markdown'
if @redaction.save
flash[:notice] = t("redaction.create.flash")
flash[:notice] = t(".flash")
redirect_to @redaction
else
render :action => "new"
@ -42,7 +42,7 @@ class RedactionsController < ApplicationController
@redaction.description = params[:redaction][:description]
if @redaction.save
flash[:notice] = t("redaction.update.flash")
flash[:notice] = t(".flash")
redirect_to @redaction
else
render :action => "edit"
@ -54,14 +54,14 @@ class RedactionsController < ApplicationController
@redaction.old_ways.empty? &&
@redaction.old_relations.empty?
if @redaction.destroy
flash[:notice] = t("redaction.destroy.flash")
flash[:notice] = t(".flash")
redirect_to :redactions
else
flash[:error] = t("redaction.destroy.error")
flash[:error] = t(".error")
redirect_to @redaction
end
else
flash[:error] = t("redaction.destroy.not_empty")
flash[:error] = t(".not_empty")
redirect_to @redaction
end
end

View file

@ -1,22 +1,21 @@
<% @title = t 'redaction.edit.title' %>
<% @title = t '.title' %>
<% content_for :heading do %>
<h1><%= t 'redaction.edit.heading' %></h1>
<h1><%= t '.heading' %></h1>
<% end %>
<%= form_for(@redaction) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :title, t('redaction.edit.title') %><br />
<%= f.label :title, t('.title') %><br />
<%= f.text_field :title %>
</p>
<p>
<%= f.label :description, t('redaction.edit.description') %><br />
<%= f.label :description, t('.description') %><br />
<%= richtext_area :redaction, :description, :cols => 80, :rows => 20, :format => @redaction.description_format %>
</p>
<p>
<%= f.submit t('redaction.edit.submit') %>
<%= f.submit t('.submit') %>
</p>
<% end %>

View file

@ -1,10 +1,10 @@
<% @title = t('redaction.index.title') %>
<% @title = t('.title') %>
<% content_for :heading do %>
<h1><%= t('redaction.index.heading') %></h1>
<h1><%= t('.heading') %></h1>
<% end %>
<% unless @redactions.empty? %>
<%= render :partial => 'redactions' %>
<% else %>
<p><%= t 'redaction.index.empty' %></p>
<p><%= t '.empty' %></p>
<% end %>

View file

@ -1,22 +1,20 @@
<% @title = t 'redaction.new.title' %>
<% @title = t '.title' %>
<% content_for :heading do %>
<h1><%= t 'redaction.new.heading' %></h1>
<h1><%= t '.heading' %></h1>
<% end %>
<%= form_for(@redaction) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :title, t('redaction.new.title') %><br />
<%= f.label :title, t('.title') %><br />
<%= f.text_field :title %>
</p>
<p>
<%= f.label :description, t('redaction.new.description') %><br />
<%= f.label :description, t('.description') %><br />
<%= richtext_area :redaction, :description, :cols => 80, :rows => 20, :format => @redaction.description_format %>
</p>
<p>
<%= f.submit t('redaction.new.submit') %>
<%= f.submit t('.submit') %>
</p>
<% end %>

View file

@ -1,20 +1,20 @@
<% @title = t('redaction.show.title') %>
<% @title = t('.title') %>
<% content_for :heading do %>
<h1><%= t('redaction.show.heading', :title => @redaction.title) %></h1>
<h1><%= t('.heading', :title => @redaction.title) %></h1>
<% end %>
<p>
<b><%= t 'redaction.show.user' %></b>
<b><%= t '.user' %></b>
<%= link_to(@redaction.user.display_name, user_path(@redaction.user)) %>
</p>
<p class="richtext">
<b><%= t 'redaction.show.description' %></b>
<b><%= t '.description' %></b>
<%= @redaction.description.to_html %>
</p>
<% if current_user and current_user.moderator? %>
<div class="buttons">
<%= button_to t('redaction.show.edit'), edit_redaction_path(@redaction), :method => :get %></td>
<%= button_to t('redaction.show.destroy'), @redaction, :method => "delete", :remote => true, :data => { :confirm => t('redaction.show.confirm') } %>
<%= button_to t('.edit'), edit_redaction_path(@redaction), :method => :get %></td>
<%= button_to t('.destroy'), @redaction, :method => "delete", :remote => true, :data => { :confirm => t('.confirm') } %>
</div>
<% end %>

View file

@ -2401,7 +2401,7 @@ en:
show_address: Show address
query_features: Query features
centre_map: Centre map here
redaction:
redactions:
edit:
description: "Description"
heading: "Edit redaction"