Skip to content

Commit 63d4ec5

Browse files
authored
Fix hardcoded string composition with internationalizations (#5312)
* Fix hardcoded string composition with internationalizations
1 parent 54ba5da commit 63d4ec5

8 files changed

Lines changed: 25 additions & 17 deletions

File tree

apps/dashboard/app/helpers/batch_connect/sessions_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def relaunch(session)
9999

100100
user_context = session.user_context
101101
params = batch_connect_app.attributes.map{|attribute| ["batch_connect_session_context[#{attribute.id}]", user_context.fetch(attribute.id, nil)]}.to_h.compact
102-
title = "#{t('dashboard.batch_connect_sessions_relaunch_title')} #{session.title} #{t('dashboard.batch_connect_sessions_word')}"
102+
title = t('dashboard.batch_connect_sessions_relaunch_full_title', title: session.title)
103103
button_to(
104104
batch_connect_session_contexts_path(token: batch_connect_app.token),
105105
method: :post,
@@ -139,7 +139,7 @@ def cancel_or_delete(session)
139139
end
140140

141141
def delete(session)
142-
title = "#{t('dashboard.batch_connect_sessions_delete_title')} #{session.title} #{t('dashboard.batch_connect_sessions_word')}"
142+
title = t('dashboard.batch_connect_sessions_delete_full_title', title: session.title)
143143
button_to(
144144
batch_connect_session_path(session.id),
145145
method: :delete,
@@ -153,7 +153,7 @@ def delete(session)
153153
end
154154

155155
def cancel(session)
156-
title = "#{t('dashboard.batch_connect_sessions_cancel_title')} #{session.title} #{t('dashboard.batch_connect_sessions_word')}"
156+
title = t('dashboard.batch_connect_sessions_cancel_full_title', title: session.title)
157157
button_to(
158158
batch_connect_cancel_session_path(session.id),
159159
method: :post,

apps/dashboard/app/helpers/files_helper.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
module FilesHelper
66
include ApplicationHelper
7-
8-
def files_browse_page_title(path)
9-
prefix = "#{t('dashboard.files_title')} - #{@user_configuration.dashboard_title}"
10-
return prefix if path.blank?
117

12-
dir_segment = (path.to_s == '/') ? 'Root' : path.basename.to_s
13-
"#{prefix} - #{dir_segment}"
8+
def files_browse_page_title(path)
9+
site = @user_configuration.dashboard_title
10+
page = t('dashboard.files_title')
11+
return t('dashboard.page_title', page: page, site: site) unless path.present?
12+
dir_segment = path.to_s == '/' ? t('dashboard.root') : path.basename.to_s
13+
t('dashboard.page_title_with_dir', page: page, site: site, dir: dir_segment)
1414
end
1515

1616
def path_segment_with_slash(filesystem, segment, counter, total)

apps/dashboard/app/views/batch_connect/sessions/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% content_for :title, "#{t('dashboard.breadcrumbs_my_sessions')} - #{@user_configuration.dashboard_title}" %>
1+
<% content_for :title, t('dashboard.page_title', page: t('dashboard.breadcrumbs_my_sessions'), site: @user_configuration.dashboard_title) %>
22
<%-
33
any_apps = (@sys_app_groups + @usr_app_groups + @dev_app_groups).any?
44
-%>

apps/dashboard/app/views/module_browser/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% content_for :title, "#{t('dashboard.module_browser_title')} - #{@user_configuration.dashboard_title}" %>
1+
<% content_for :title, t('dashboard.page_title', page: t('dashboard.module_browser_title'), site: @user_configuration.dashboard_title) %>
22

33
<h1 class="mb-4 d-flex justify-content-between">
44
<%= t('dashboard.module_browser_title') %>

apps/dashboard/app/views/projects/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
</div>
7878
<div class="col-12 col-lg-7 jobs-files-item">
7979
<div id="directory_browser" class="border border-2 px-1 py-3 mt-3 mb-5 bg-white rounded">
80-
<h2 class="lead fw-bolder d-flex justify-content-center"><%= "#{t('dashboard.project')} #{t('dashboard.directory')}" %>: &nbsp<i><%= @project.id %></i></h2>
80+
<h2 class="lead fw-bolder d-flex justify-content-center"><%= t('dashboard.project_directory') %>: &nbsp<i><%= @project.id %></i></h2>
8181
<hr>
8282
<%= turbo_frame_tag 'project_directory',
8383
src: directory_frame_path(

apps/dashboard/app/views/shared/_insufficient_quota_resource.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
<ul class="list-unstyled mb-2">
1010
<li>
11-
<%= quota.to_s %><%= ". #{t('dashboard.quota_additional_message')}" %>
11+
<%= t('dashboard.quota_message', quota: quota.to_s, additional_message: t('dashboard.quota_additional_message')) %>
1212
</li>
1313
<li>
1414
<%=

apps/dashboard/config/locales/en.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ en:
6969
batch_connect_no_sessions: You have no active sessions.
7070
batch_connect_sandbox: " [Sandbox]"
7171
batch_connect_sessions_cancel_confirm: Are you sure?
72+
batch_connect_sessions_cancel_full_title: "Cancel %{title} Session"
7273
batch_connect_sessions_cancel_title: Cancel
7374
batch_connect_sessions_data_html: |
7475
The %{title} session data for this session can be accessed
7576
under the %{data_link_tag}.
7677
batch_connect_sessions_delete_confirm: Are you sure?
78+
batch_connect_sessions_delete_full_title: "Delete %{title} Session"
7779
batch_connect_sessions_delete_hover: Delete Session
7880
batch_connect_sessions_delete_title: Delete
7981
batch_connect_sessions_edit_title: Edit new %{title} with this session parameters
@@ -86,6 +88,7 @@ en:
8688
batch_connect_sessions_novnc_launch: Launch %{app_title}
8789
batch_connect_sessions_novnc_view_only: View Only (Share-able Link)
8890
batch_connect_sessions_path_selector_forbidden_error: You do not have permission to select that directory or file.
91+
batch_connect_sessions_relaunch_full_title: "Relaunch %{title} Session"
8992
batch_connect_sessions_relaunch_title: Relaunch
9093
batch_connect_sessions_staged_root: staged root directory
9194
batch_connect_sessions_stats_created_at: 'Created at:'
@@ -161,6 +164,7 @@ en:
161164
files_send_to_target_title_default: Send selected files metadata to the external application
162165
files_shell: Open in Terminal
163166
files_shell_dropdown: Select Cluster to Open in Terminal
167+
files_title: File browsing
164168
files_doesnt_exist: "%{path} does not exist."
165169
files_not_readable: "You do not have sufficient permissions to read '%{path}'."
166170
home_directory: Home Directory
@@ -252,7 +256,6 @@ en:
252256
mode: Mode
253257
module_browser_last_updated: 'Last updated: %{last_updated}'
254258
module_browser_title: Module Browser
255-
files_title: File browsing
256259
motd_erb_render_error: 'MOTD was not parsed or rendered correctly: %{error_message}'
257260
motd_title: Message of the Day
258261
name: Name
@@ -277,6 +280,8 @@ en:
277280
nsf_access_events: NSF ACCESS Events
278281
ok: OK
279282
owner: Owner
283+
page_title: "%{page} - %{site}"
284+
page_title_with_dir: "%{page} - %{site} - %{dir}"
280285
path_selector_default_popup_title: Select Your Working Directory
281286
path_selector_home: home
282287
path_selector_parent_directory: parent directory
@@ -286,13 +291,15 @@ en:
286291
products_manifest_save_error: Cannot save app manifest to %{path}
287292
project: Project
288293
project_balances: Project Balances
294+
project_directory: Project Directory
289295
project_zip_error_message: 'Error creating ZIP file: %{error}'
290296
project_zip_success_message: 'Success: project.zip has been created in your project directory.'
291297
quota_additional_message: Consider deleting or archiving files to free up disk space.
292298
quota_block: Using %{used} of quota %{available}
293299
quota_block_shared: "(%{used_exclusive} are yours)"
294300
quota_file: Using %{used} files of quota %{available} files
295301
quota_file_shared: "(%{used_exclusive} files are yours)"
302+
quota_message: "%{quota}. %{additional_message}"
296303
quota_reload_message: Reload page to see updated quota. Quotas are updated every 5 minutes.
297304
quota_warning_prefix_html: Quota limit warning for
298305
recently_used_apps_title: Recently Used Apps
@@ -302,6 +309,7 @@ en:
302309
restart_msg_html: |
303310
Your group membership has changed, which affects your access to apps. Your dashboard should restart automatically.
304311
If it doesn't please, click: <a href="%{restart_url}">restart web server</a>.
312+
root: Root
305313
save: Save
306314
saved_settings_title: Saved Settings
307315
select_path: Select Path

apps/dashboard/test/helpers/batch_connect/sessions_helper_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class BatchConnect::SessionsHelperTest < ActionView::TestCase
6262
assert_equal true, form['class'].include?('relaunch')
6363

6464
button = html.at_css('button')
65-
assert_equal 'Relaunch AppName Session', button['title']
65+
assert_equal I18n.t('dashboard.batch_connect_sessions_relaunch_full_title', title: 'AppName'), button['title']
6666
assert_equal true, button['class'].include?('relaunch')
6767
end
6868

@@ -80,10 +80,10 @@ def create_session(state = :running, valid: true)
8080
end
8181

8282
def cancel_session_title
83-
"#{I18n.t('dashboard.batch_connect_sessions_cancel_title')} AppName #{I18n.t('dashboard.batch_connect_sessions_word')}"
83+
I18n.t('dashboard.batch_connect_sessions_cancel_full_title', title: 'AppName')
8484
end
8585

8686
def delete_session_title
87-
"#{I18n.t('dashboard.batch_connect_sessions_delete_title')} AppName #{I18n.t('dashboard.batch_connect_sessions_word')}"
87+
I18n.t('dashboard.batch_connect_sessions_delete_full_title', title: 'AppName')
8888
end
8989
end

0 commit comments

Comments
 (0)