From b6b0ce0f76b2fda6a634644c04e7f7faa57764ff Mon Sep 17 00:00:00 2001 From: Aaron Ogata Date: Mon, 7 Mar 2022 06:27:39 -0800 Subject: [PATCH] use I18n.t() instead of t() helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs FOO-2746 With Rails 6.1, using the t() helper has new default key behaviour that screws with i18nliner’s ability to derive the correct key from the text string. Since we don’t need the actionview translation helper functionality here, just use the I18n.t call instead when there is no default explicitly defined in the call. Change-Id: I4868409cd02df2bfe36e482c23d357234cea7465 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/286460 Tested-by: Service Cloud Jenkins Reviewed-by: Jacob Burroughs QA-Review: Aaron Ogata Product-Review: Aaron Ogata --- app/helpers/application_helper.rb | 6 +++--- app/helpers/attachment_helper.rb | 2 +- app/helpers/courses_helper.rb | 4 ++-- app/helpers/eportfolios_helper.rb | 2 +- app/helpers/gradebooks_helper.rb | 8 ++++---- app/helpers/submission_comments_helper.rb | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2c9b249e235..f9443d450d3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -980,7 +980,7 @@ module ApplicationHelper def agree_to_terms # may be overridden by a plugin @agree_to_terms || - t( + I18n.t( "I agree to the *terms of use*.", wrapper: { "*" => link_to('\1', "#", class: "terms_of_service_link") @@ -1174,12 +1174,12 @@ module ApplicationHelper def link_to_parent_signup(auth_type) data = reg_link_data(auth_type) link_to( - t("Parents sign up here"), + I18n.t("Parents sign up here"), "#", id: "signup_parent", class: "signup_link", data: data, - title: t("Parent Signup") + title: I18n.t("Parent Signup") ) end diff --git a/app/helpers/attachment_helper.rb b/app/helpers/attachment_helper.rb index 43f9d600a01..2575be8c2c9 100644 --- a/app/helpers/attachment_helper.rb +++ b/app/helpers/attachment_helper.rb @@ -99,7 +99,7 @@ module AttachmentHelper send_file_headers!(length: body.length, filename: attachment.filename, disposition: "inline", type: attachment.content_type_with_encoding) render body: body elsif must_proxy - render 400, text: t("It's not allowed to redirect to HTML files that can't be proxied while Content-Security-Policy is being enforced") + render 400, text: I18n.t("It's not allowed to redirect to HTML files that can't be proxied while Content-Security-Policy is being enforced") elsif inline redirect_to authenticated_inline_url(attachment) else diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 34e1a969aa6..9753f9fcb6a 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -143,9 +143,9 @@ module CoursesHelper return nil if MasterCourses::MasterTemplate.is_master_course?(course) if MasterCourses::ChildSubscription.is_child_course?(course) - t("Course is already associated with a blueprint") + I18n.t("Course is already associated with a blueprint") elsif course.student_enrollments.not_fake.exists? - t("Cannot have a blueprint course with students") + I18n.t("Cannot have a blueprint course with students") else nil end diff --git a/app/helpers/eportfolios_helper.rb b/app/helpers/eportfolios_helper.rb index 156bbb84199..47234468f01 100644 --- a/app/helpers/eportfolios_helper.rb +++ b/app/helpers/eportfolios_helper.rb @@ -29,7 +29,7 @@ module EportfoliosHelper def delete_icon(png = false) if png - image_tag("delete.png", alt: t("Delete")) + image_tag("delete.png", alt: I18n.t("Delete")) else raw("×") end diff --git a/app/helpers/gradebooks_helper.rb b/app/helpers/gradebooks_helper.rb index 085ecc2bcf0..14f952d9920 100644 --- a/app/helpers/gradebooks_helper.rb +++ b/app/helpers/gradebooks_helper.rb @@ -169,12 +169,12 @@ module GradebooksHelper end def translated_due_date_for_speedgrader(assignment) - return t("Due: Multiple Due Dates") if assignment.multiple_due_dates_apply_to?(@current_user) + return I18n.t("Due: Multiple Due Dates") if assignment.multiple_due_dates_apply_to?(@current_user) assignment = assignment.overridden_for(@current_user) if assignment.due_at - return t("Due: %{assignment_due_date_time}", assignment_due_date_time: datetime_string(force_zone(assignment.due_at))) + return I18n.t("Due: %{assignment_due_date_time}", assignment_due_date_time: datetime_string(force_zone(assignment.due_at))) end override_dates = if assignment.only_visible_to_overrides? @@ -184,9 +184,9 @@ module GradebooksHelper end if override_dates.count == 1 - t("Due: %{assignment_due_date_time}", assignment_due_date_time: datetime_string(force_zone(override_dates.first))) + I18n.t("Due: %{assignment_due_date_time}", assignment_due_date_time: datetime_string(force_zone(override_dates.first))) else - t("Due: No Due Date") + I18n.t("Due: No Due Date") end end diff --git a/app/helpers/submission_comments_helper.rb b/app/helpers/submission_comments_helper.rb index 684f4c86e91..a691ad73f25 100644 --- a/app/helpers/submission_comments_helper.rb +++ b/app/helpers/submission_comments_helper.rb @@ -22,7 +22,7 @@ module SubmissionCommentsHelper if can_do(comment, @current_user, :read_author) comment.author_name else - t("Anonymous User") + I18n.t("Anonymous User") end end end