Skip to content

Commit 577f78e

Browse files
committed
i18nliner bump, fix pagination link issue
refs CNVS-11947 the scoping tweak ensures that translate call with an explicit :scope (ohai will_paginate) do not have their keys incorrectly scoped to the current file version bump also fixes issue w/ 5 built-in ActiveRecord translations not resolving (e.g. "1 error prohibited this %{model} from being saved"), due to the unfortunately named `i18n_scope` stomping an existing method with a slightly different purpose. it doesn't appear that a user would ever actually see any of these 5 strings in canvas, but ¯\_(ツ)_/¯ test plan: 0. create a bunch of page errors if necessary 1. go to /error_reports 2. confirm the pagination links say stuff like "Next →" instead of "Next Label" Change-Id: I9ff182863691fbceda44b105ab9bb94d9321b177 Reviewed-on: https://gerrit.instructure.com/43640 Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Jennifer Stern <jstern@instructure.com> Reviewed-by: Jennifer Stern <jstern@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
1 parent 628df26 commit 577f78e

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

Gemfile.d/other_stuff.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
gem 'i18n', '0.6.9'
4848
gem 'i18nema', '0.0.8', :platforms => [:mri_20, :mri_21]
4949
gem 'i18nema19', '0.0.8', :platform => :mri_19
50-
gem 'i18nliner', '0.0.8'
50+
gem 'i18nliner', '0.0.9'
5151
gem 'icalendar', '1.5.4'
5252
gem 'ims-lti', '2.0.0.beta.10'
5353
gem 'jammit', :github => 'documentcloud/jammit', :ref => '98b50a67029c2860717485a72a2ff0ae8ec37840'

config/initializers/i18n.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,38 +129,38 @@ def qualified_locale
129129
require "i18n_extraction/i18nliner_scope_extensions"
130130

131131
ActionView::Template.class_eval do
132-
def render_with_i18n_scope(view, *args, &block)
133-
old_i18n_scope = view.i18n_scope
132+
def render_with_i18nliner_scope(view, *args, &block)
133+
old_i18nliner_scope = view.i18nliner_scope
134134
if @virtual_path
135-
view.i18n_scope = I18nliner::Scope.new(@virtual_path.gsub(/\/_?/, '.'))
135+
view.i18nliner_scope = I18nliner::Scope.new(@virtual_path.gsub(/\/_?/, '.'))
136136
end
137-
render_without_i18n_scope(view, *args, &block)
137+
render_without_i18nliner_scope(view, *args, &block)
138138
ensure
139-
view.i18n_scope = old_i18n_scope
139+
view.i18nliner_scope = old_i18nliner_scope
140140
end
141-
alias_method_chain :render, :i18n_scope
141+
alias_method_chain :render, :i18nliner_scope
142142
end
143143

144144
ActionView::Base.class_eval do
145-
attr_accessor :i18n_scope
145+
attr_accessor :i18nliner_scope
146146
end
147147

148148
ActionController::Base.class_eval do
149-
def i18n_scope
150-
@i18n_scope ||= I18nliner::Scope.new(controller_path.tr('/', '.'))
149+
def i18nliner_scope
150+
@i18nliner_scope ||= I18nliner::Scope.new(controller_path.tr('/', '.'))
151151
end
152152
end
153153

154154
ActiveRecord::Base.class_eval do
155155
include I18nUtilities
156156
extend I18nUtilities
157157

158-
def i18n_scope
159-
self.class.i18n_scope
158+
def i18nliner_scope
159+
self.class.i18nliner_scope
160160
end
161161

162-
def self.i18n_scope
163-
@i18n_scope ||= I18nliner::Scope.new(self.class.name.underscore)
162+
def self.i18nliner_scope
163+
@i18nliner_scope ||= I18nliner::Scope.new(self.class.name.underscore)
164164
end
165165

166166
class << self
@@ -188,14 +188,14 @@ def validates_locale(*args)
188188
end
189189

190190
ActionMailer::Base.class_eval do
191-
def i18n_scope
192-
@i18n_scope ||= I18nliner::Scope.new("#{mailer_name}.#{action_name}")
191+
def i18nliner_scope
192+
@i18nliner_scope ||= I18nliner::Scope.new("#{mailer_name}.#{action_name}")
193193
end
194194

195195
def translate(key, default, options = {})
196196
key, options = I18nliner::CallHelpers.infer_arguments(args)
197197
options = inferpolate(options) if I18nliner.infer_interpolation_values
198-
options[:i18n_scope] = i18n_scope
198+
options[:i18nliner_scope] = i18nliner_scope
199199
I18n.translate(key, options)
200200
end
201201
alias :t :translate

gems/i18n_extraction/i18n_extraction.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
1717
spec.add_dependency "sexp_processor", "~> 4.2"
1818
spec.add_dependency "ruby_parser", "~> 3.6"
1919
spec.add_dependency "activesupport", ">= 3.2", "< 4.2"
20-
spec.add_dependency "i18nliner", "0.0.8"
20+
spec.add_dependency "i18nliner", "0.0.9"
2121

2222
spec.add_development_dependency "bundler", "~> 1.5"
2323
spec.add_development_dependency "rake"

gems/i18n_extraction/lib/i18n_extraction/i18nliner_scope_extensions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
class I18nliner::Scope
44
ABSOLUTE_KEY = /\A#/
55

6-
def normalize_key(key, inferred_key)
6+
def normalize_key(key, inferred_key, explicit_scope_option)
77
key = key.to_s
8-
return key if key.sub!(ABSOLUTE_KEY, '') || !scope || inferred_key
8+
return key if key.sub!(ABSOLUTE_KEY, '') || !scope || inferred_key || explicit_scope_option
99
scope + key
1010
end
1111
end

0 commit comments

Comments
 (0)