i18n 0.6.11 → 0.7.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of i18n might be problematic. Click here for more details.

Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +3 -26
  3. data/gemfiles/Gemfile.rails-3.2.x +0 -2
  4. data/gemfiles/Gemfile.rails-3.2.x.lock +5 -9
  5. data/gemfiles/Gemfile.rails-4.0.x +0 -2
  6. data/gemfiles/Gemfile.rails-4.0.x.lock +7 -11
  7. data/gemfiles/Gemfile.rails-4.1.x +0 -2
  8. data/gemfiles/Gemfile.rails-4.1.x.lock +7 -11
  9. data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-master} +1 -3
  10. data/gemfiles/Gemfile.rails-master.lock +40 -0
  11. data/lib/i18n.rb +7 -30
  12. data/lib/i18n/backend/base.rb +0 -1
  13. data/lib/i18n/backend/interpolation_compiler.rb +1 -1
  14. data/lib/i18n/backend/key_value.rb +0 -1
  15. data/lib/i18n/config.rb +16 -6
  16. data/lib/i18n/exceptions.rb +4 -28
  17. data/lib/i18n/version.rb +1 -1
  18. data/test/api/key_value_test.rb +2 -6
  19. data/test/api/memoize_test.rb +2 -6
  20. data/test/api/override_test.rb +2 -3
  21. data/test/backend/cache_test.rb +1 -0
  22. data/test/backend/cascade_test.rb +1 -0
  23. data/test/backend/chain_test.rb +1 -0
  24. data/test/backend/exceptions_test.rb +1 -0
  25. data/test/backend/fallbacks_test.rb +8 -2
  26. data/test/backend/key_value_test.rb +2 -5
  27. data/test/backend/memoize_test.rb +2 -2
  28. data/test/backend/metadata_test.rb +1 -0
  29. data/test/backend/pluralization_test.rb +1 -0
  30. data/test/backend/simple_test.rb +2 -1
  31. data/test/backend/transliterator_test.rb +4 -5
  32. data/test/gettext/api_test.rb +1 -0
  33. data/test/gettext/backend_test.rb +73 -82
  34. data/test/i18n/exceptions_test.rb +0 -15
  35. data/test/i18n/interpolate_test.rb +2 -1
  36. data/test/i18n/load_path_test.rb +1 -0
  37. data/test/i18n_test.rb +35 -0
  38. data/test/locale/fallbacks_test.rb +1 -4
  39. data/test/locale/tag/rfc4646_test.rb +1 -0
  40. data/test/run_all.rb +1 -1
  41. data/test/test_helper.rb +20 -41
  42. metadata +19 -28
  43. data/gemfiles/Gemfile.rails-2.3.x +0 -11
  44. data/gemfiles/Gemfile.rails-2.3.x.lock +0 -30
  45. data/gemfiles/Gemfile.rails-3.0.x +0 -11
  46. data/gemfiles/Gemfile.rails-3.0.x.lock +0 -30
  47. data/gemfiles/Gemfile.rails-3.1.x.lock +0 -30
  48. data/lib/i18n/core_ext/string/interpolate.rb +0 -105
  49. data/test/all.rb +0 -8
  50. data/test/core_ext/string/interpolate_test.rb +0 -99
@@ -1,8 +0,0 @@
1
- # encoding: utf-8
2
-
3
- dir = File.dirname(__FILE__)
4
- $LOAD_PATH.unshift(dir)
5
-
6
- Dir["#{dir}/**/*_test.rb"].sort.each do |file|
7
- require file.sub(/^#{dir}\/(.*)\.rb$/, '\1')
8
- end
@@ -1,99 +0,0 @@
1
- require 'test_helper'
2
-
3
- # thanks to Masao's String extensions these should work the same in
4
- # Ruby 1.8 (patched) and Ruby 1.9 (native)
5
- # some tests taken from Masao's tests
6
- # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb
7
-
8
- class I18nCoreExtStringInterpolationTest < I18n::TestCase
9
- test "String interpolates a single argument" do
10
- assert_equal "Masao", "%s" % "Masao"
11
- end
12
-
13
- test "String interpolates an array argument" do
14
- assert_equal "1 message", "%d %s" % [1, 'message']
15
- end
16
-
17
- test "String interpolates a hash argument w/ named placeholders" do
18
- assert_equal "Masao Mutoh", "%{first} %{last}" % { :first => 'Masao', :last => 'Mutoh' }
19
- end
20
-
21
- test "String interpolates a hash argument w/ named placeholders (reverse order)" do
22
- assert_equal "Mutoh, Masao", "%{last}, %{first}" % { :first => 'Masao', :last => 'Mutoh' }
23
- end
24
-
25
- test "String interpolates named placeholders with sprintf syntax" do
26
- assert_equal "10, 43.4", "%<integer>d, %<float>.1f" % {:integer => 10, :float => 43.4}
27
- end
28
-
29
- test "String interpolates named placeholders with sprintf syntax, does not recurse" do
30
- assert_equal "%<not_translated>s", "%{msg}" % { :msg => '%<not_translated>s', :not_translated => 'should not happen' }
31
- end
32
-
33
- test "String interpolation does not replace anything when no placeholders are given" do
34
- assert_equal("aaa", "aaa" % {:num => 1})
35
- assert_equal("bbb", "bbb" % [1])
36
- end
37
-
38
- test "String interpolation sprintf behaviour equals Ruby 1.9 behaviour" do
39
- assert_equal("1", "%<num>d" % {:num => 1})
40
- assert_equal("0b1", "%<num>#b" % {:num => 1})
41
- assert_equal("foo", "%<msg>s" % {:msg => "foo"})
42
- assert_equal("1.000000", "%<num>f" % {:num => 1.0})
43
- assert_equal(" 1", "%<num>3.0f" % {:num => 1.0})
44
- assert_equal("100.00", "%<num>2.2f" % {:num => 100.0})
45
- assert_equal("0x64", "%<num>#x" % {:num => 100.0})
46
- assert_raise(ArgumentError) { "%<num>,d" % {:num => 100} }
47
- assert_raise(ArgumentError) { "%<num>/d" % {:num => 100} }
48
- end
49
-
50
- test "String interpolation old-style sprintf still works" do
51
- assert_equal("foo 1.000000", "%s %f" % ["foo", 1.0])
52
- end
53
-
54
- test "String interpolation raises an ArgumentError when the string has extra placeholders (Array)" do
55
- assert_raise(ArgumentError) do # Ruby 1.9 msg: "too few arguments"
56
- "%s %s" % %w(Masao)
57
- end
58
- end
59
-
60
- test "String interpolation raises a KeyError when the string has extra placeholders (Hash)" do
61
- assert_raise(KeyError) do # Ruby 1.9 msg: "key not found"
62
- "%{first} %{last}" % { :first => 'Masao' }
63
- end
64
- end
65
-
66
- test "String interpolation does not raise when passed extra values (Array)" do
67
- assert_nothing_raised do
68
- assert_equal "Masao", "%s" % %w(Masao Mutoh)
69
- end
70
- end
71
-
72
- test "String interpolation does not raise when passed extra values (Hash)" do
73
- assert_nothing_raised do
74
- assert_equal "Masao Mutoh", "%{first} %{last}" % { :first => 'Masao', :last => 'Mutoh', :salutation => 'Mr.' }
75
- end
76
- end
77
-
78
- test "% acts as escape character in String interpolation" do
79
- assert_equal "%{first}", "%%{first}" % { :first => 'Masao' }
80
- assert_equal("% 1", "%% %<num>d" % {:num => 1.0})
81
- assert_equal("%{num} %<num>d", "%%{num} %%<num>d" % {:num => 1})
82
- end
83
-
84
- test "% can be used in Ruby's own sprintf behavior" do
85
- assert_equal "70%", "%d%%" % 70
86
- assert_equal "70-100%", "%d-%d%%" % [70, 100]
87
- assert_equal "+2.30%", "%+.2f%%" % 2.3
88
- end
89
-
90
- def test_sprintf_mix_unformatted_and_formatted_named_placeholders
91
- assert_equal("foo 1.000000", "%{name} %<num>f" % {:name => "foo", :num => 1.0})
92
- end
93
-
94
- def test_string_interpolation_raises_an_argument_error_when_mixing_named_and_unnamed_placeholders
95
- assert_raise(ArgumentError) { "%{name} %f" % [1.0] }
96
- assert_raise(ArgumentError) { "%{name} %f" % [1.0, 2.0] }
97
- end
98
- end
99
-