Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ Style/DocumentDynamicEvalDefinition: # new in 1.1
Enabled: true
Style/EndlessMethod: # new in 1.8
Enabled: true
Style/FormatStringToken:
# Force use of the `%{variable}` style of tokens instead of `%<variable>s` because
# Translation.io has trouble with auto-translating it. It converts `%<variable>s` to
# `%<variable> s` (note the added space)
EnforcedStyle: template
Style/HashConversion: # new in 1.10
Enabled: true
Style/HashExcept: # new in 1.7
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def create_or_update
unless p.question_exists?(p_params[:question_id])
# rubocop:disable Layout/LineLength
render(status: :not_found, json: {
msg: format(_('There is no question with id %<question_id>s associated to plan id %<plan_id>s for which to create or update an answer'), question_id: p_params[:question_id], plan_id: p_params[:plan_id])
msg: format(_('There is no question with id %{question_id} associated to plan id %{plan_id} for which to create or update an answer'), question_id: p_params[:question_id], plan_id: p_params[:plan_id])
})
# rubocop:enable Layout/LineLength
return
end
rescue ActiveRecord::RecordNotFound
# rubocop:disable Layout/LineLength
render(status: :not_found, json: {
msg: format(_('There is no plan with id %<id>s for which to create or update an answer'), id: p_params[:plan_id])
msg: format(_('There is no plan with id %{id} for which to create or update an answer'), id: p_params[:plan_id])
})
# rubocop:enable Layout/LineLength
return
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def authenticate_admin!
end

def failure_message(obj, action = 'save')
format(_('Unable to %<action>s the %<object>s.%<errors>s'),
format(_('Unable to %{action} the %{object}. {errors}'),
object: obj_name_for_display(obj),
action: action || 'save', errors: errors_for_display(obj))
end

def success_message(obj, action = 'saved')
format(_('Successfully %<action>s the %<object>s.'), object: obj_name_for_display(obj), action: action || 'save')
format(_('Successfully %{action} the %{object}.'), object: obj_name_for_display(obj), action: action || 'save')
end

def errors_for_display(obj)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/paginable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def sort_link_name(sort_field)
style="float: right; font-size: 1.2em;">

<span class="screen-reader-text">
#{format(_('Sort by %<sort_field>'), sort_field: sort_field.split('.').first)}
#{format(_('Sort by %{sort_field}'), sort_field: sort_field.split('.').first)}
</span>
</i>
HTML
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/identifiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def destroy
if user.identifiers.include?(identifier)
identifier.destroy!
flash[:notice] =
format(_('Successfully unlinked your account from %<is>s.'), is: identifier.identifier_scheme&.description)
format(_('Successfully unlinked your account from %{is}.'), is: identifier.identifier_scheme&.description)
else
flash[:alert] =
format(_('Unable to unlink your account from %<is>s.'), is: identifier.identifier_scheme&.description)
format(_('Unable to unlink your account from %{is}.'), is: identifier.identifier_scheme&.description)
end

redirect_to edit_user_registration_path
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/org_admin/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def feedback_complete
if plan.complete_feedback(current_user)
# rubocop:disable Layout/LineLength
redirect_to(org_admin_plans_path,
notice: format(_('%<plan_owner>s has been notified that you have finished providing feedback'), plan_owner: plan.owner.name(false)))
notice: format(_('%{plan_owner} has been notified that you have finished providing feedback'), plan_owner: plan.owner.name(false)))
# rubocop:enable Layout/LineLength
else
redirect_to org_admin_plans_path,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/org_admin/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def organisational

@orgs = current_user.can_super_admin? ? Org.all : nil
@title = if current_user.can_super_admin?
format(_('%<org_name>s Templates'), org_name: current_user.org.name)
format(_('%{org_name} Templates'), org_name: current_user.org.name)
else
_('Own Templates')
end
Expand Down Expand Up @@ -212,7 +212,7 @@ def update
rescue ActiveSupport::JSON.parse_error
render(json: {
status: :bad_request,
msg: format(_('Error parsing links for a %<template>s'),
msg: format(_('Error parsing links for a %{template}'),
template: template_type(template))
})
nil
Expand Down Expand Up @@ -340,7 +340,7 @@ def template_export
template: 'template_exports/template_export',
margin: @formatting[:margin],
footer: {
center: format(_('Template created using the %<application_name>s service. Last modified %<date>s'), application_name: ApplicationService.application_name, date: l(@template.updated_at.to_date, formats: :short)),
center: format(_('Template created using the %{application_name} service. Last modified %{date}'), application_name: ApplicationService.application_name, date: l(@template.updated_at.to_date, formats: :short)),
font_size: 8,
spacing: (@formatting[:margin][:bottom] / 2) - 4,
right: '[page] of [topage]',
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/plan_exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def show_pdf
render pdf: file_name,
margin: @formatting[:margin],
footer: {
center: format(_('Created using %<application_name>s. Last modified %<date>s'),
center: format(_('Created using %{application_name}. Last modified %{date}'),
application_name: ApplicationService.application_name,
date: l(@plan.updated_at.to_date, format: :readable)),
font_size: 8,
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def create

@plan.title = if plan_params[:title].blank?
if current_user.firstname.blank?
format(_('My Plan (%<title>s)'), title: @plan.template.title)
format(_('My Plan (%{title})'), title: @plan.template.title)
else
format(_('%<user_name>s Plan'), user_name: "#{current_user.firstname}'s")
format(_('%{user_name} Plan'), user_name: "#{current_user.firstname}'s")
end
else
plan_params[:title]
Expand Down Expand Up @@ -422,13 +422,13 @@ def visibility
else
# rubocop:disable Layout/LineLength
render status: :forbidden, json: {
msg: format(_("Unable to change the plan's status since it is needed at least %<percentage}>s percentage responded"), percentage: Rails.configuration.x.plans.default_percentage_answered)
msg: format(_("Unable to change the plan's status since it is needed at least %{percentage} percentage responded"), percentage: Rails.configuration.x.plans.default_percentage_answered)
}
# rubocop:enable Layout/LineLength
end
else
render status: :not_found,
json: { msg: format(_('Unable to find plan id %{<plan_id>s'),
json: { msg: format(_('Unable to find plan id %{plan_id}'),
plan_id: params[:id]) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/public_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def template_export
template: 'template_exports/template_export',
margin: @formatting[:margin],
footer: {
center: format(_('Template created using the %<application_name>s service. Last modified %<date>s'),
center: format(_('Template created using the %{application_name} service. Last modified %{date}'),
application_name: ApplicationService.application_name,
date: l(@template.updated_at.to_date, formats: :short)),
font_size: 8,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def new

# Connect the new user with the identifier sent back by the OAuth provider
flash[:notice] = format(_("Please make a choice below. After linking your
details to a %<application_name>s account,
details to a %{application_name} account,
you will be able to sign in directly with your
institutional credentials."), application_name: ApplicationService.application_name)
end
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create
role_params[:user][:email].present? && plan.present?

if @role.plan.owner.present? && @role.plan.owner.email == role_params[:user][:email]
flash[:notice] = format(_('Cannot share plan with %<email>s since that email matches
flash[:notice] = format(_('Cannot share plan with %{email} since that email matches
with the owner of the plan.'),
email: role_params[:user][:email])
else
Expand All @@ -33,7 +33,7 @@ def create
.count
.positive? # role already exists

flash[:notice] = format(_('Plan is already shared with %<email>s.'),
flash[:notice] = format(_('Plan is already shared with %{email}.'),
email: role_params[:user][:email])
else
# rubocop:disable Metrics/BlockNesting
Expand All @@ -44,12 +44,12 @@ def create
surname: _('Surname'),
org: current_user.org },
current_user)
message = format(_('Invitation to %<email>s issued successfully.'),
message = format(_('Invitation to %{email} issued successfully.'),
email: role_params[:user][:email])
user = User.where_case_insensitive('email', role_params[:user][:email]).first
end

message += format(_('Plan shared with %<email>s.'), email: user.email)
message += format(_('Plan shared with %{email}.'), email: user.email)
@role.user = user

if @role.save
Expand Down Expand Up @@ -87,7 +87,7 @@ def update
end
render json: {
code: 1,
msg: format(_('Successfully changed the permissions for %<email>. They have been
msg: format(_('Successfully changed the permissions for %{email}. They have been
notified via email.'), email: @role.user.email)
}
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/super_admin/api_clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create
if @api_client.save
UserMailer.api_credentials(@api_client).deliver_now
msg = success_message(@api_client, _('created'))
msg += format(_('. The API credentials have been emailed to %<email>s'),
msg += format(_('. The API credentials have been emailed to %{email}'),
email: @api_client.contact_email)
flash.now[:notice] = msg
render :edit
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/super_admin/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def acknowledge
def set_notification
@notification = Notification.find(params[:id] || params[:notification_id])
rescue ActiveRecord::RecordNotFound
flash[:alert] = format(_('There is no notification associated with id %<id>s'),
flash[:alert] = format(_('There is no notification associated with id %{id}'),
id: params[:id])
redirect_to action: :index
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/super_admin/org_swaps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
current_user.org = lookup
if current_user.save
redirect_back(fallback_location: root_path,
notice: format(_('Your organisation affiliation has been changed. You may now edit templates for %<org_name>s.'),
notice: format(_('Your organisation affiliation has been changed. You may now edit templates for %{org_name}.'),
org_name: current_user.org.name))
else
redirect_back(fallback_location: root_path,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def handle_omniauth(scheme)
attrs: request.env['omniauth.auth'],
identifiable: current_user)
flash[:notice] =
format(_('Your account has been successfully linked to %<scheme>s.'),
format(_('Your account has been successfully linked to %{scheme}.'),
scheme: scheme.description)

else
flash[:alert] = format(_('Unable to link your account to %<scheme>s.'),
flash[:alert] = format(_('Unable to link your account to %{scheme}.'),
scheme: scheme.description)
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ def activate
user.save!
render json: {
code: 1,
msg: format(_("Successfully %<action>s %<username>s's account."),
msg: format(_("Successfully %{action} %{username}'s account."),
action: user.active ? _('activated') : _('deactivated'),
username: user.name(false))
}
rescue StandardError
render json: {
code: 0,
msg: format(_('Unable to %<action>s %<username>s'),
msg: format(_('Unable to %{action} %{username}'),
action: user.active ? _('activate') : _('deactivate'),
username: user.name(false))
}
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/conditions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ def later_question_list(question)
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

def question_title(question)
raw format('Qn. %<question_nbr>s: %<title>s',
raw format('Qn. %{question_nbr}: %{title}',
question_nbr: question.number.to_s,
title: truncate(strip_tags(question.text), length: DISPLAY_LENGTH,
separator: ' ', escape: false))
end

def section_title(section)
raw format('Sec. %<section_nbr>s: %<title>s',
raw format('Sec. %{section_nbr}: %{title}',
section_nbr: section.number.to_s,
title: truncate(strip_tags(section.title), length: DISPLAY_LENGTH,
separator: ' ', escape: false))
Expand All @@ -194,7 +194,7 @@ def condition_to_text(conditions)
return_string += opts.join(' and ')
if cond.action_type == 'add_webhook'
subject_string = text_formatted(JSON.parse(cond.webhook_data)['subject'])
return_string += format(_(' will <b>send an email</b> with subject %<subject_name>s'),
return_string += format(_(' will <b>send an email</b> with subject %{subject_name}'),
subject_name: subject_string)
else
remove_data = cond.remove_data
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/feedbacks_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# Helper methods for Feedback messages
module FeedbacksHelper
def feedback_confirmation_default_subject
_('%<application_name>s: Your plan has been submitted for feedback')
_('%{application_name}: Your plan has been submitted for feedback')
end

def feedback_confirmation_default_message
_('<p>Hello %<user_name>s.</p>'\
"<p>Your plan \"%<plan_name>s\" has been submitted for feedback from an
_('<p>Hello %{user_name}.</p>'\
"<p>Your plan \"%{plan_name}\" has been submitted for feedback from an
administrator at your organisation. "\
"If you have questions pertaining to this action, please contact us
at %<organisation_email>s.</p>")
at %{organisation_email}.</p>")
end

def feedback_constant_to_text(text, user, plan, org)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/orgs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ module OrgsHelper
# Returns String
def sample_message_for_org_feedback_form(org)
email = org.contact_email || EMAIL_PLACEHOLDER
format(_("<p>A data librarian from %<org_name>s will respond to your request within 48
format(_("<p>A data librarian from %{org_name} will respond to your request within 48
hours. If you have questions pertaining to this action please contact us
at %<organisation_email>s.</p>"), organisation_email: email, org_name: org.name)
at %{organisation_email}.</p>"), organisation_email: email, org_name: org.name)
end

# The preferred logo url for the current configuration. If DRAGONFLY_AWS is true, return
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/super_admin/orgs/merge_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def column_content(entries:, orcid:)
when 'Department'
[entry.id, entry.name].join(' - ')
when 'Guidance'
format(_('Guidance for: %<themes>s'), themes: entry.themes.collect(&:title).join(', '))
format(_('Guidance for: %{themes}'), themes: entry.themes.collect(&:title).join(', '))
when 'Identifier'
[entry.identifier_scheme&.name, entry.value].join(' - ')
when 'TokenPermissionType'
Expand All @@ -50,7 +50,7 @@ def column_content(entries:, orcid:)
def merge_column_content(entries:, orcid:, to_org_name:)
return _('Nothing to merge') unless entries.present? && entries.any?

html = format(_("<p>The following %<object_types>s will be moved over to '%<org_name>s':</p>"),
html = format(_("<p>The following %{object_types} will be moved over to '%{org_name}':</p>"),
object_types: entries.first.class.name.pluralize, org_name: to_org_name)
html + column_content(entries: entries, orcid: orcid)
end
Expand Down
Loading