Skip to content

Commit 6eedf2e

Browse files
author
Jose Lloret
committed
Export plans according to gettext. #98
1 parent 06c7a37 commit 6eedf2e

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

app/controllers/plans_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class PlansController < ApplicationController
22
require 'pp'
3+
helper SettingsTemplateHelper
34
#Uncomment the line below in order to add authentication to this page - users without permission will not be able to add new plans
45
#load_and_authorize_resource
56
#
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module SettingsTemplateHelper
2+
# Retrieves an msgstr for a given admin_field
3+
def admin_field_t(admin_field)
4+
if Settings::Template::VALID_ADMIN_FIELDS.include?(admin_field)
5+
if admin_field == 'project_name'
6+
return _('Plan Name')
7+
elsif admin_field == 'project_identifier'
8+
return _('Plan ID')
9+
elsif admin_field == 'grant_title'
10+
return _('Grant number')
11+
elsif admin_field == 'principal_investigator'
12+
return _('Principal Investigator / Researcher')
13+
elsif admin_field == 'project_data_contact'
14+
return _('Plan Data Contact')
15+
elsif admin_field == 'project_description'
16+
return _('Plan Description')
17+
elsif admin_field == 'funder'
18+
return _('Funder')
19+
elsif admin_field == 'institution'
20+
return _('Institution')
21+
elsif admin_field == 'orcid'
22+
return _('Your ORCID')
23+
end
24+
end
25+
return _('Unknown column name.')
26+
end
27+
end

app/views/plans/export.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
if value.present?
2323
%>
2424
<tr>
25-
<th class="dmp_th_border"><p>- <%= t("helpers.plan.export.#{field}") -%></p></th>
25+
<th class="dmp_th_border"><p>- <%= admin_field_t(field) -%></p></th>
2626
<td class="dmp_td_border"><%= value -%></td>
2727
</tr>
2828
<% end %>
2929
<% end %>
3030
</tbody>
3131
</table>
32-
<% end %>
32+
<% end %>
3333
<% @exported_plan.sections.each do |section| %>
3434
<h3><%= section.title %></h3>
3535
<table class="dmp_table">
@@ -49,7 +49,7 @@
4949
<td class="dmp_td_border" >
5050
<% answer = @plan.answer(question.id, false) %>
5151
<% if answer.nil? then %>
52-
<p>Question not answered.</p>
52+
<p><%= _('Question not answered') %></p>
5353
<% else %>
5454
<% q_format = question.question_format %>
5555
<% if q_format.title == _('Check box') || q_format.title == _('Multi select box') ||

app/views/plans/export.pdf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
value = @exported_plan.send(field)
2828
if value.present?
2929
%>
30-
<p><strong><%= t("helpers.plan.export.#{field}") -%></strong> <%= value -%></p>
30+
<p><strong><%= admin_field_t(field) -%></strong> <%= value -%></p>
3131
<% end %>
3232
<% end %>
3333

app/views/plans/export.xml.builder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ xml.plan("id" => @plan.id) do
88
xml.details do
99
details.each do |field|
1010
value = @exported_plan.send(field)
11-
xml.detail(value, title: t("helpers.plan.export.#{field}")) if value.present?
11+
xml.detail(value, title: admin_field_t(field)) if value.present?
1212
end
1313
end
1414
end

0 commit comments

Comments
 (0)