string extraction for most i18n oddities

Change-Id: Ibdf9315b6165269af2ee0c99a27093d5abc75641
Reviewed-on: https://gerrit.instructure.com/4509
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Jon Jensen 2011-06-30 14:36:59 -06:00
parent 5febff3c62
commit fba0c94e4a
17 changed files with 135 additions and 12 deletions

View File

@ -230,6 +230,7 @@ class AccountsController < ApplicationController
end
end
cancel_cache_buster
# TODO i18n
send_data(
res,
:type => "text/csv",

View File

@ -42,7 +42,7 @@ class FacebookController < ApplicationController
@policies.each{|p| p.save!}
end
end
# TODO: i18n
# TODO: i18n... see notification.rb
@notification_categories = Notification.dashboard_categories.reject{|c| c.category == "Summaries"}
@policies = @user.notification_policies.for_channel(@cc)
redirect_to facebook_settings_url

View File

@ -547,6 +547,8 @@ class Account < ActiveRecord::Base
def default_enrollment_term
return @default_enrollment_term if @default_enrollment_term
unless self.root_account_id
# TODO i18n
t '#account.default_term_name', "Default Term"
@default_enrollment_term = self.enrollment_terms.active.find_or_create_by_name("Default Term")
end
end
@ -645,10 +647,14 @@ class Account < ActiveRecord::Base
end
def self.site_admin
# TODO i18n
t '#account.default_site_administrator_account_name', 'Site Admin'
get_special_account('site_admin', 'Site Admin')
end
def self.default
# TODO i18n
t '#account.default_account_name', 'Default Account'
get_special_account('default', 'Default Account')
end

View File

@ -101,6 +101,7 @@ class Attachment < ActiveRecord::Base
def self.process_migration(data, migration)
attachments = data['file_map'] ? data['file_map']: {}
# TODO i18n
to_import = migration.to_import 'files'
attachments.values.each do |att|
if !att['is_folder'] && att['migration_id'] && (!to_import || to_import[att['migration_id']])
@ -114,6 +115,7 @@ class Attachment < ActiveRecord::Base
if data[:locked_folders]
data[:locked_folders].each do |path|
# TODO i18n
if f = migration.context.active_folders.find_by_full_name("course files/#{path}")
f.locked = true
f.save
@ -122,6 +124,7 @@ class Attachment < ActiveRecord::Base
end
if data[:hidden_folders]
data[:hidden_folders].each do |path|
# TODO i18n
if f = migration.context.active_folders.find_by_full_name("course files/#{path}")
f.workflow_state = 'hidden'
f.save

View File

@ -244,27 +244,27 @@ class CalendarEvent < ActiveRecord::Base
description = ImportedHtmlConverter.convert(hash[:description] || "", context)
if hash[:attachment_type] == 'external_url'
url = hash[:attachment_value]
description += "<p><a href='#{url}'>See Related Link</a></p>" if url
description += "<p><a href='#{url}'>" + ERB::Util.h(t(:see_related_link, "See Related Link")) + "</a></p>" if url
elsif hash[:attachment_type] == 'assignment'
assignment = context.assignments.find_by_migration_id(hash[:attachment_value]) rescue nil
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/assignments/#{assignment.id}'>See #{assignment.title}</a></p>" if assignment
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/assignments/#{assignment.id}'>" + ERB::Util.h(t(:see_assignment, "See %{assignment_name}", :assignment_name => assignment.title)) + "</a></p>" if assignment
elsif hash[:attachment_type] == 'assessment'
quiz = context.quizzes.find_by_migration_id(hash[:attachment_value]) rescue nil
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/quizzes/#{quiz.id}'>See #{quiz.title}</a></p>" if quiz
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/quizzes/#{quiz.id}'>" + ERB::Util.h(t(:see_quiz, "See %{quiz_name}", :quiz_name => quiz.title)) + "</a></p>" if quiz
elsif hash[:attachment_type] == 'file'
file = context.attachments.find_by_migration_id(hash[:attachment_value]) rescue nil
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/files/#{file.id}/download'>See #{file.display_name}</a></p>" if file
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/files/#{file.id}/download'>" + ERB::Util.h(t(:see_file, "See %{file_name}", :file_name => file.display_name)) + "</a></p>" if file
elsif hash[:attachment_type] == 'area'
# ignored, no idea what this is
elsif hash[:attachment_type] == 'web_link'
link = context.external_url_hash[hash[:attachment_value]] rescue nil
link ||= context.full_migration_hash['web_link_categories'].map{|c| c['links'] }.flatten.select{|l| l['link_id'] == hash[:attachment_value] } rescue nil
description += "<p><a href='#{link['url']}'>#{link['name'] || 'See Related Link'}</a></p>" if link
description += "<p><a href='#{link['url']}'>#{link['name'] || ERB::Util.h(t(:see_related_link, "See Related Link"))}</a></p>" if link
elsif hash[:attachment_type] == 'media_collection'
# ignored, no idea what this is
elsif hash[:attachment_type] == 'topic'
topic = context.discussion_topic.find_by_migration_id(hash[:attachment_value]) rescue nil
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/discussion_topics/#{topic.id}'>See #{topic.title}</a></p>" if topic
description += "<p><a href='/#{context.class.to_s.downcase.pluralize}/#{context.id}/discussion_topics/#{topic.id}'>" + ERB::Util.h(t(:see_discussion_topic, "See %{discussion_topic_name}", :discussion_topic_name => topic.title)) + "</a></p>" if topic
end
item.description = description

View File

@ -398,6 +398,7 @@ class Course < ActiveRecord::Base
end
def self.default_name
# TODO i18n
t('default_name', "My Course")
end
@ -1019,6 +1020,14 @@ class Course < ActiveRecord::Base
h[[sub.user_id, sub.assignment_id]] = sub; h
}
read_only = t('csv.read_only_field', '(read only)')
t 'csv.student', 'Student'
t 'csv.id', 'ID'
t 'csv.section', 'Section'
t 'csv.comments', 'Comments'
t 'csv.current_score', 'Current Score'
t 'csv.final_score', 'Final Score'
t 'csv.final_grade', 'Final Grade'
t 'csv.points_possible', 'Points Possible'
res = FasterCSV.generate do |csv|
#First row
row = ["Student", "ID", "Section"]

View File

@ -97,6 +97,8 @@ class Folder < ActiveRecord::Base
protected :infer_hidden_state
def infer_full_name
# TODO i18n
t :default_folder_name, 'folder'
self.name ||= "folder"
self.name = self.name.gsub(/\//, "_")
folder = self
@ -220,11 +222,13 @@ class Folder < ActiveRecord::Base
end
elsif context.is_a? User
# TODO i18n
t :my_files_folder_name, 'my files'
if root_folders.select{|f| f.name == "my files" }.empty?
root_folders << context.folders.create(:name => "my files", :full_name => "my files", :workflow_state => "visible")
end
else
# TODO i18n
# TODO i18n
t :files_folder_name, 'files'
if root_folders.select{|f| f.name == "files" }.empty?
root_folders << context.folders.create(:name => "files", :full_name => "files", :workflow_state => "visible")
end
@ -278,6 +282,7 @@ class Folder < ActiveRecord::Base
else
# TODO i18n
if context.is_a? Course
t :course_content_folder_name, 'course content'
current_folder = context.folders.active.find_by_full_name("course content")
elsif @context.is_a? User
current_folder = context.folders.active.find_by_full_name("my files")

View File

@ -359,6 +359,7 @@ class Group < ActiveRecord::Base
item.migration_id = hash[:migration_id]
item.name = hash[:title]
# TODO i18n
t '#group.default_category', 'Imported Groups'
item.category = hash[:group_category] || 'Imported Groups'
item.save!

View File

@ -100,7 +100,7 @@ class LearningOutcome < ActiveRecord::Base
self.data[:rubric_criterion] = nil
return
end
criterion[:description] = hash[:description] || "No Description"
criterion[:description] = hash[:description] || t(:no_description, "No Description")
criterion[:ratings] = []
(hash[:ratings] || []).each do |key, rating|
criterion[:ratings] << {

View File

@ -422,6 +422,95 @@ class Notification < ActiveRecord::Base
end
end
# TODO i18n: show the localized notification name in the dashboard (or
# wherever), even if we continue to store the english string in the db
# (it's actually just the titleized message template filename)
def names
t 'names.account_user_notification', 'Account User Notification'
t 'names.account_user_registration', 'Account User Registration'
t 'names.assignment_changed', 'Assignment Changed'
t 'names.assignment_created', 'Assignment Created'
t 'names.assignment_due_date_changed', 'Assignment Due Date Changed'
t 'names.assignment_due_date_reminder', 'Assignment Due Date Reminder'
t 'names.assignment_graded', 'Assignment Graded'
t 'names.assignment_grading_reminder', 'Assignment Grading Reminder'
t 'names.assignment_publishing_reminder', 'Assignment Publishing Reminder'
t 'names.assignment_resubmitted', 'Assignment Resubmitted'
t 'names.assignment_submitted', 'Assignment Submitted'
t 'names.assignment_submitted_late', 'Assignment Submitted Late'
t 'names.collaboration_invitation', 'Collaboration Invitation'
t 'names.confirm_email_communication_channel', 'Confirm Email Communication Channel'
t 'names.confirm_registration', 'Confirm Registration'
t 'names.confirm_sms_communication_channel', 'Confirm Sms Communication Channel'
t 'names.content_export_failed', 'Content Export Failed'
t 'names.content_export_finished', 'Content Export Finished'
t 'names.enrollment_accepted', 'Enrollment Accepted'
t 'names.enrollment_invitation', 'Enrollment Invitation'
t 'names.enrollment_notification', 'Enrollment Notification'
t 'names.enrollment_registration', 'Enrollment Registration'
t 'names.event_date_changed', 'Event Date Changed'
t 'names.forgot_password', 'Forgot Password'
t 'names.grade_weight_changed', 'Grade Weight Changed'
t 'names.group_assignment_submitted_late', 'Group Assignment Submitted Late'
t 'names.group_membership_accepted', 'Group Membership Accepted'
t 'names.group_membership_rejected', 'Group Membership Rejected'
t 'names.merge_email_communication_channel', 'Merge Email Communication Channel'
t 'names.migration_export_ready', 'Migration Export Ready'
t 'names.migration_import_failed', 'Migration Import Failed'
t 'names.migration_import_finished', 'Migration Import Finished'
t 'names.new_account_user', 'New Account User'
t 'names.new_announcement', 'New Announcement'
t 'names.new_context_group_membership', 'New Context Group Membership'
t 'names.new_context_group_membership_invitation', 'New Context Group Membership Invitation'
t 'names.new_course', 'New Course'
t 'names.new_discussion_entry', 'New Discussion Entry'
t 'names.new_discussion_topic', 'New Discussion Topic'
t 'names.new_event_created', 'New Event Created'
t 'names.new_file_added', 'New File Added'
t 'names.new_student_organized_group', 'New Student Organized Group'
t 'names.new_teacher_registration', 'New Teacher Registration'
t 'names.new_user', 'New User'
t 'names.new_wiki_page', 'New Wiki Page'
t 'names.pseudonym_registration', 'Pseudonym Registration'
t 'names.report_generated', 'Report Generated'
t 'names.report_generation_failed', 'Report Generation Failed'
t 'names.rubric_assessment_invitation', 'Rubric Assessment Invitation'
t 'names.rubric_assessment_submission_reminder', 'Rubric Assessment Submission Reminder'
t 'names.rubric_association_created', 'Rubric Association Created'
t 'names.student_context_message', 'Student Context Message'
t 'names.submission_comment', 'Submission Comment'
t 'names.submission_comment_for_teacher', 'Submission Comment For Teacher'
t 'names.submission_grade_changed', 'Submission Grade Changed'
t 'names.submission_graded', 'Submission Graded'
t 'names.summaries', 'Summaries'
t 'names.teacher_context_message', 'Teacher Context Message'
t 'names.updated_wiki_page', 'Updated Wiki Page'
t 'names.web_conference_invitation', 'Web Conference Invitation'
end
# TODO: i18n ... show these anywhere we show the category today
def category_names
t 'categories.all_submissions', 'All Submissions'
t 'categories.announcement', 'Announcement'
t 'categories.calendar', 'Calendar'
t 'categories.course_content', 'Course Content'
t 'categories.discussion', 'Discussion'
t 'categories.discussion_entry', 'DiscussionEntry'
t 'categories.due_date', 'Due Date'
t 'categories.files', 'Files'
t 'categories.grading', 'Grading'
t 'categories.grading_policies', 'Grading Policies'
t 'categories.invitiation', 'Invitation'
t 'categories.late_grading', 'Late Grading'
t 'categories.membership_update', 'Membership Update'
t 'categories.message', 'Message'
t 'categories.other', 'Other'
t 'categories.registration', 'Registration'
t 'categories.reminder', 'Reminder'
t 'categories.student_message', 'Student Message'
t 'categories.submission_comment', 'Submission Comment'
end
def category_description
case category
when 'Announcement'

View File

@ -283,6 +283,7 @@ class RubricAssociation < ActiveRecord::Base
self.summary_data[:saved_comments] ||= {}
self.summary_data[:saved_comments][criterion.id.to_s] ||= []
self.summary_data[:saved_comments][criterion.id.to_s] << rating[:comments]
# TODO i18n
self.summary_data[:saved_comments][criterion.id.to_s] = self.summary_data[:saved_comments][criterion.id.to_s].select{|desc| desc && !desc.empty? && desc != "No Details"}.uniq.sort
self.save
end

View File

@ -168,7 +168,7 @@ class SubmissionComment < ActiveRecord::Base
end
def infer_details
self.author_name ||= self.author.short_name rescue "Someone"
self.author_name ||= self.author.short_name rescue t(:unknown_author, "Someone")
self.cached_attachments = self.attachments.map{|a| OpenObject.build('attachment', a.attributes) }
self.context = self.read_attribute(:context) || self.submission.assignment.context rescue nil
end

View File

@ -404,7 +404,7 @@ class User < ActiveRecord::Base
def infer_defaults
self.name = nil if self.name == "User"
self.name ||= self.email || "User"
self.name ||= self.email || t(:default_user_name, "User")
self.short_name = nil if self.short_name == ""
self.short_name ||= self.name
self.sortable_name = self.last_name_first.downcase

View File

@ -58,6 +58,8 @@ class Wiki < ActiveRecord::Base
end
def wiki_page
# TODO i18n
t :front_page_name, "Front Page"
self.wiki_pages.find_by_url("front-page") || self.wiki_pages.build(:title => "Front Page", :url => 'front-page')
end

View File

@ -68,6 +68,9 @@ class WikiNamespace < ActiveRecord::Base
wiki_namespace = context.wiki_namespaces.find_by_namespace(name)
wiki_namespace ||= context.wiki_namespaces.build(:namespace => name)
if !wiki_namespace.wiki
# TODO i18n
t :default_course_wiki_name, "%{course_name} Wiki", :course_name => nil
t :default_group_wiki_name, "%{group_name} Wiki", :group_name => nil
wiki_namespace.wiki = Wiki.create(:title => "#{context.name} Wiki")
wiki_namespace.save!
end

View File

@ -40,6 +40,7 @@ class WikiPage < ActiveRecord::Base
return if deleted?
self.title ||= (self.url || "page").to_cased_title
return unless self.wiki
# TODO i18n (see wiki.rb)
if self.title == "Front Page" && self.new_record?
baddies = self.wiki.wiki_pages.not_deleted.find_all_by_title("Front Page").select{|p| p.url != "front-page" }
baddies.each{|p| p.title = p.url.to_cased_title; p.save_without_broadcasting! }
@ -328,7 +329,7 @@ class WikiPage < ActiveRecord::Base
namespace = self.wiki.wiki_namespaces.find_by_context_id(context && context.id) || self.wiki.wiki_namespaces.find(:first)
prefix = namespace.context_prefix || ""
Atom::Entry.new do |entry|
entry.title = "Wiki Page#{", " + namespace.context.name}: #{self.title}" # TODO: i18n
entry.title = t(:atom_entry_title, "Wiki Page, %{course_or_group_name}: %{page_title}", :course_or_group_name => namespace.context.name, :page_title => self.title)
entry.updated = self.updated_at
entry.published = self.created_at
entry.id = "tag:#{HostUrl.default_host},#{self.created_at.strftime("%Y-%m-%d")}:/wiki_pages/#{self.feed_code}_#{self.updated_at.strftime("%Y-%m-%d")}"

View File

@ -91,6 +91,8 @@ $(document).ready(function() {
}
}
// TODO i18n
I18n.t('percent_of_final_grade', '%{percent} of final grade', {percent: 0});
$("#groups_for_student .assignment_group") //.find(".more_info_link").show().end()
.find(".more_info").hide().end()
.find(".more_info_brief").showIf($("#group_weighting_scheme").text() == "percent").append(" of final grade");