Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
fail-fast: false
matrix:
ruby_version: [head, 3.4, 3.3, 3.2, 3.1, '3.0', jruby]
rubyopt: [""]
gemfile:
- Gemfile
- gemfiles/Gemfile.rails-6.0.x
Expand Down Expand Up @@ -48,6 +49,10 @@ jobs:
gemfile: gemfiles/Gemfile.rails-8.0.x
- ruby_version: jruby
gemfile: gemfiles/Gemfile.rails-main
include:
- ruby_version: 3.4
gemfile: Gemfile
rubyopt: "--enable-frozen-string-literal --debug-frozen-string-literal"

runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions lib/i18n/backend/interpolation_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Compiler

def compile_if_an_interpolation(string)
if interpolated_str?(string)
string = +string
string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__
def i18n_interpolate(v = {})
"#{compiled_interpolation_body(string)}"
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/tests/interpolation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ module Interpolation
end

test "interpolation: ASCII strings in the backend should be encoded to UTF8 if interpolation options are in UTF8" do
I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.force_encoding("ASCII"))
I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.dup.force_encoding(Encoding::US_ASCII))
result = I18n.t 'encoding', :who => "måmmå miå"
assert_equal Encoding::UTF_8, result.encoding
end

test "interpolation: UTF8 strings in the backend are still returned as UTF8 with ASCII interpolation" do
I18n.backend.store_translations 'en', 'encoding' => 'måmmå miå %{what}'
result = I18n.t 'encoding', :what => 'let me go'.force_encoding("ASCII")
result = I18n.t 'encoding', :what => 'let me go'.dup.force_encoding(Encoding::US_ASCII)
assert_equal Encoding::UTF_8, result.encoding
end

Expand Down Expand Up @@ -172,7 +172,7 @@ def capture(stream)
end

def euc_jp(string)
string.encode!(Encoding::EUC_JP)
string.encode(Encoding::EUC_JP)
end

def interpolate(*args)
Expand Down
2 changes: 1 addition & 1 deletion test/backend/metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setup
end

test "pluralization adds the count to metadata on Strings" do
assert_equal(1, I18n.t(:missing, :count => 1, :default => { :one => 'foo' }).translation_metadata[:count])
assert_equal(1, I18n.t(:missing, :count => 1, :default => { :one => +'foo' }).translation_metadata[:count])
end

test "metadata works with frozen values" do
Expand Down