i18n 0.6.9 → 0.6.11
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.
- data/{README.textile → README.md} +27 -27
- data/{ci → gemfiles}/Gemfile.rails-2.3.x +4 -2
- data/gemfiles/Gemfile.rails-2.3.x.lock +30 -0
- data/{ci/Gemfile.rails-3.x → gemfiles/Gemfile.rails-3.0.x} +4 -2
- data/gemfiles/Gemfile.rails-3.0.x.lock +30 -0
- data/gemfiles/Gemfile.rails-3.1.x +10 -0
- data/gemfiles/Gemfile.rails-3.1.x.lock +30 -0
- data/gemfiles/Gemfile.rails-3.2.x +10 -0
- data/gemfiles/Gemfile.rails-3.2.x.lock +31 -0
- data/gemfiles/Gemfile.rails-4.0.x +10 -0
- data/gemfiles/Gemfile.rails-4.0.x.lock +37 -0
- data/gemfiles/Gemfile.rails-4.1.x +10 -0
- data/gemfiles/Gemfile.rails-4.1.x.lock +38 -0
- data/lib/i18n.rb +6 -9
- data/lib/i18n/backend/base.rb +1 -1
- data/lib/i18n/backend/fallbacks.rb +7 -3
- data/lib/i18n/config.rb +9 -0
- data/lib/i18n/core_ext/kernel/suppress_warnings.rb +8 -0
- data/lib/i18n/exceptions.rb +1 -1
- data/lib/i18n/version.rb +1 -1
- data/test/api/all_features_test.rb +1 -1
- data/test/api/cascade_test.rb +1 -1
- data/test/api/chain_test.rb +1 -1
- data/test/api/fallbacks_test.rb +1 -1
- data/test/api/key_value_test.rb +2 -2
- data/test/api/memoize_test.rb +3 -3
- data/test/api/override_test.rb +1 -6
- data/test/api/pluralization_test.rb +1 -1
- data/test/api/simple_test.rb +1 -1
- data/test/backend/cache_test.rb +1 -1
- data/test/backend/cascade_test.rb +1 -1
- data/test/backend/chain_test.rb +1 -1
- data/test/backend/exceptions_test.rb +1 -1
- data/test/backend/fallbacks_test.rb +24 -3
- data/test/backend/interpolation_compiler_test.rb +4 -5
- data/test/backend/key_value_test.rb +2 -2
- data/test/backend/metadata_test.rb +1 -1
- data/test/backend/pluralization_test.rb +1 -1
- data/test/backend/simple_test.rb +6 -6
- data/test/backend/transliterator_test.rb +1 -1
- data/test/core_ext/hash_test.rb +1 -1
- data/test/core_ext/string/interpolate_test.rb +1 -1
- data/test/gettext/api_test.rb +1 -1
- data/test/gettext/backend_test.rb +1 -1
- data/test/i18n/exceptions_test.rb +6 -6
- data/test/i18n/interpolate_test.rb +2 -2
- data/test/i18n/load_path_test.rb +1 -1
- data/test/i18n_test.rb +21 -4
- data/test/locale/fallbacks_test.rb +2 -2
- data/test/locale/tag/rfc4646_test.rb +3 -3
- data/test/locale/tag/simple_test.rb +1 -1
- data/test/run_all.rb +12 -13
- data/test/test_helper.rb +40 -20
- metadata +34 -106
- data/ci/Gemfile.no-rails +0 -5
- data/ci/Gemfile.no-rails.lock +0 -14
- data/ci/Gemfile.rails-2.3.x.lock +0 -23
- data/ci/Gemfile.rails-3.x.lock +0 -23
- data/lib/i18n/core_ext/kernel/surpress_warnings.rb +0 -9
data/lib/i18n/exceptions.rb
CHANGED
@@ -13,7 +13,7 @@ module I18n
|
|
13
13
|
# TODO: this block is to be replaced by `exception.message` when
|
14
14
|
# rescue_format is removed
|
15
15
|
if options[:rescue_format] == :html
|
16
|
-
if @rescue_format_deprecation
|
16
|
+
if !defined?(@rescue_format_deprecation)
|
17
17
|
$stderr.puts "[DEPRECATED] I18n's :recue_format option will be removed from a future release. All exception messages will be plain text. If you need the exception handler to return an html format please set or pass a custom exception handler."
|
18
18
|
@rescue_format_deprecation = true
|
19
19
|
end
|
data/lib/i18n/version.rb
CHANGED
@@ -7,7 +7,7 @@ rescue LoadError
|
|
7
7
|
puts "not testing with Cache enabled because active_support can not be found"
|
8
8
|
end
|
9
9
|
|
10
|
-
class I18nAllFeaturesApiTest <
|
10
|
+
class I18nAllFeaturesApiTest < I18n::TestCase
|
11
11
|
class Backend < I18n::Backend::Simple
|
12
12
|
include I18n::Backend::Metadata
|
13
13
|
include I18n::Backend::Cache
|
data/test/api/cascade_test.rb
CHANGED
data/test/api/chain_test.rb
CHANGED
data/test/api/fallbacks_test.rb
CHANGED
data/test/api/key_value_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
I18n::
|
3
|
+
I18n::TestCase.setup_rufus_tokyo
|
4
4
|
|
5
|
-
class I18nKeyValueApiTest <
|
5
|
+
class I18nKeyValueApiTest < I18n::TestCase
|
6
6
|
include I18n::Tests::Basics
|
7
7
|
include I18n::Tests::Defaults
|
8
8
|
include I18n::Tests::Interpolation
|
data/test/api/memoize_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class I18nMemoizeBackendWithSimpleApiTest <
|
3
|
+
class I18nMemoizeBackendWithSimpleApiTest < I18n::TestCase
|
4
4
|
include I18n::Tests::Basics
|
5
5
|
include I18n::Tests::Defaults
|
6
6
|
include I18n::Tests::Interpolation
|
@@ -27,9 +27,9 @@ class I18nMemoizeBackendWithSimpleApiTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
I18n::
|
30
|
+
I18n::TestCase.setup_rufus_tokyo
|
31
31
|
|
32
|
-
class I18nMemoizeBackendWithKeyValueApiTest <
|
32
|
+
class I18nMemoizeBackendWithKeyValueApiTest < I18n::TestCase
|
33
33
|
include I18n::Tests::Basics
|
34
34
|
include I18n::Tests::Defaults
|
35
35
|
include I18n::Tests::Interpolation
|
data/test/api/override_test.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class I18nOverrideTest <
|
3
|
+
class I18nOverrideTest < I18n::TestCase
|
4
4
|
module OverrideInverse
|
5
|
-
|
6
5
|
def translate(*args)
|
7
6
|
super(*args).reverse
|
8
7
|
end
|
9
8
|
alias :t :translate
|
10
|
-
|
11
9
|
end
|
12
10
|
|
13
11
|
module OverrideSignature
|
14
|
-
|
15
12
|
def translate(*args)
|
16
13
|
args.first + args[1]
|
17
14
|
end
|
18
15
|
alias :t :translate
|
19
|
-
|
20
16
|
end
|
21
17
|
|
22
18
|
def setup
|
@@ -44,5 +40,4 @@ class I18nOverrideTest < Test::Unit::TestCase
|
|
44
40
|
@I18n.extend OverrideSignature
|
45
41
|
assert_equal 'HelloWelcome message on home page', @I18n.translate('Hello', 'Welcome message on home page', :tokenize => true) # tr8n example
|
46
42
|
end
|
47
|
-
|
48
43
|
end
|
data/test/api/simple_test.rb
CHANGED
data/test/backend/cache_test.rb
CHANGED
data/test/backend/chain_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class I18nBackendChainTest <
|
3
|
+
class I18nBackendChainTest < I18n::TestCase
|
4
4
|
def setup
|
5
5
|
@first = backend(:en => {
|
6
6
|
:foo => 'Foo', :formats => { :short => 'short' }, :plural_1 => { :one => '%{count}' }, :dates => {:a => "A"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class I18nBackendFallbacksTranslateTest <
|
3
|
+
class I18nBackendFallbacksTranslateTest < I18n::TestCase
|
4
4
|
class Backend < I18n::Backend::Simple
|
5
5
|
include I18n::Backend::Fallbacks
|
6
6
|
end
|
@@ -10,6 +10,7 @@ class I18nBackendFallbacksTranslateTest < Test::Unit::TestCase
|
|
10
10
|
store_translations(:en, :foo => 'Foo in :en', :bar => 'Bar in :en', :buz => 'Buz in :en')
|
11
11
|
store_translations(:de, :bar => 'Bar in :de', :baz => 'Baz in :de')
|
12
12
|
store_translations(:'de-DE', :baz => 'Baz in :de-DE')
|
13
|
+
store_translations(:'pt-BR', :baz => 'Baz in :pt-BR')
|
13
14
|
end
|
14
15
|
|
15
16
|
test "still returns an existing translation as usual" do
|
@@ -74,9 +75,18 @@ class I18nBackendFallbacksTranslateTest < Test::Unit::TestCase
|
|
74
75
|
test "should ensure that default is not splitted on new line char" do
|
75
76
|
assert_equal "Default \n Bar", I18n.t(:missing_bar, :default => "Default \n Bar")
|
76
77
|
end
|
78
|
+
|
79
|
+
test "should not raise error when enforce_available_locales is true, :'pt' is missing and default is a Symbol" do
|
80
|
+
I18n.enforce_available_locales = true
|
81
|
+
begin
|
82
|
+
assert_equal 'Foo', I18n.t(:'model.attrs.foo', :locale => :'pt-BR', :default => [:'attrs.foo', "Foo"])
|
83
|
+
ensure
|
84
|
+
I18n.enforce_available_locales = false
|
85
|
+
end
|
86
|
+
end
|
77
87
|
end
|
78
88
|
|
79
|
-
class I18nBackendFallbacksLocalizeTest <
|
89
|
+
class I18nBackendFallbacksLocalizeTest < I18n::TestCase
|
80
90
|
class Backend < I18n::Backend::Simple
|
81
91
|
include I18n::Backend::Fallbacks
|
82
92
|
end
|
@@ -108,7 +118,7 @@ class I18nBackendFallbacksLocalizeTest < Test::Unit::TestCase
|
|
108
118
|
end
|
109
119
|
end
|
110
120
|
|
111
|
-
class I18nBackendFallbacksWithChainTest <
|
121
|
+
class I18nBackendFallbacksWithChainTest < I18n::TestCase
|
112
122
|
class Backend < I18n::Backend::Simple
|
113
123
|
include I18n::Backend::Fallbacks
|
114
124
|
end
|
@@ -116,10 +126,21 @@ class I18nBackendFallbacksWithChainTest < Test::Unit::TestCase
|
|
116
126
|
def setup
|
117
127
|
backend = Backend.new
|
118
128
|
backend.store_translations(:de, :foo => 'FOO')
|
129
|
+
backend.store_translations(:'pt-BR', :foo => 'Baz in :pt-BR')
|
119
130
|
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, backend)
|
131
|
+
I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
|
120
132
|
end
|
121
133
|
|
122
134
|
test "falls back from de-DE to de when there is no translation for de-DE available" do
|
123
135
|
assert_equal 'FOO', I18n.t(:foo, :locale => :'de-DE')
|
124
136
|
end
|
137
|
+
|
138
|
+
test "should not raise error when enforce_available_locales is true, :'pt' is missing and default is a Symbol" do
|
139
|
+
I18n.enforce_available_locales = true
|
140
|
+
begin
|
141
|
+
assert_equal 'Foo', I18n.t(:'model.attrs.foo', :locale => :'pt-BR', :default => [:'attrs.foo', "Foo"])
|
142
|
+
ensure
|
143
|
+
I18n.enforce_available_locales = false
|
144
|
+
end
|
145
|
+
end
|
125
146
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class InterpolationCompilerTest <
|
3
|
+
class InterpolationCompilerTest < I18n::TestCase
|
4
4
|
Compiler = I18n::Backend::InterpolationCompiler::Compiler
|
5
5
|
|
6
6
|
def compile_and_interpolate(str, values = {})
|
@@ -95,18 +95,18 @@ class InterpolationCompilerTest < Test::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
class I18nBackendInterpolationCompilerTest <
|
98
|
+
class I18nBackendInterpolationCompilerTest < I18n::TestCase
|
99
99
|
class Backend < I18n::Backend::Simple
|
100
100
|
include I18n::Backend::InterpolationCompiler
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
include I18n::Tests::Interpolation
|
104
104
|
|
105
105
|
def setup
|
106
106
|
I18n.backend = Backend.new
|
107
107
|
super
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
# pre-compile default strings to make sure we are testing I18n::Backend::InterpolationCompiler
|
111
111
|
def interpolate(*args)
|
112
112
|
options = args.last.kind_of?(Hash) ? args.last : {}
|
@@ -115,5 +115,4 @@ class I18nBackendInterpolationCompilerTest < Test::Unit::TestCase
|
|
115
115
|
end
|
116
116
|
super
|
117
117
|
end
|
118
|
-
|
119
118
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
I18n::
|
3
|
+
I18n::TestCase.setup_rufus_tokyo
|
4
4
|
|
5
|
-
class I18nBackendKeyValueTest <
|
5
|
+
class I18nBackendKeyValueTest < I18n::TestCase
|
6
6
|
def setup_backend!(subtree=true)
|
7
7
|
I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*'), subtree)
|
8
8
|
store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' })
|
data/test/backend/simple_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class I18nBackendSimpleTest <
|
3
|
+
class I18nBackendSimpleTest < I18n::TestCase
|
4
4
|
def setup
|
5
5
|
I18n.backend = I18n::Backend::Simple.new
|
6
6
|
I18n.load_path = [locales_dir + '/en.yml']
|
@@ -49,23 +49,23 @@ class I18nBackendSimpleTest < Test::Unit::TestCase
|
|
49
49
|
# storing translations
|
50
50
|
|
51
51
|
test "simple store_translations: stores translations, ... no, really :-)" do
|
52
|
-
|
52
|
+
store_translations :'en', :foo => 'bar'
|
53
53
|
assert_equal Hash[:'en', {:foo => 'bar'}], translations
|
54
54
|
end
|
55
55
|
|
56
56
|
test "simple store_translations: deep_merges with existing translations" do
|
57
|
-
|
58
|
-
|
57
|
+
store_translations :'en', :foo => {:bar => 'bar'}
|
58
|
+
store_translations :'en', :foo => {:baz => 'baz'}
|
59
59
|
assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], translations
|
60
60
|
end
|
61
61
|
|
62
62
|
test "simple store_translations: converts the given locale to a Symbol" do
|
63
|
-
|
63
|
+
store_translations 'en', :foo => 'bar'
|
64
64
|
assert_equal Hash[:'en', {:foo => 'bar'}], translations
|
65
65
|
end
|
66
66
|
|
67
67
|
test "simple store_translations: converts keys to Symbols" do
|
68
|
-
|
68
|
+
store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
|
69
69
|
assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], translations
|
70
70
|
end
|
71
71
|
|
data/test/core_ext/hash_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'i18n/core_ext/hash'
|
3
3
|
|
4
|
-
class I18nCoreExtHashInterpolationTest <
|
4
|
+
class I18nCoreExtHashInterpolationTest < I18n::TestCase
|
5
5
|
test "#deep_symbolize_keys" do
|
6
6
|
hash = { 'foo' => { 'bar' => { 'baz' => 'bar' } } }
|
7
7
|
expected = { :foo => { :bar => { :baz => 'bar' } } }
|
@@ -5,7 +5,7 @@ require 'test_helper'
|
|
5
5
|
# some tests taken from Masao's tests
|
6
6
|
# http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb
|
7
7
|
|
8
|
-
class I18nCoreExtStringInterpolationTest <
|
8
|
+
class I18nCoreExtStringInterpolationTest < I18n::TestCase
|
9
9
|
test "String interpolates a single argument" do
|
10
10
|
assert_equal "Masao", "%s" % "Masao"
|
11
11
|
end
|
data/test/gettext/api_test.rb
CHANGED
@@ -5,7 +5,7 @@ require 'test_helper'
|
|
5
5
|
# apparently Ruby 1.9.1p129 has encoding problems with the gettext po parser
|
6
6
|
unless RUBY_VERSION == '1.9.1' && RUBY_PATCHLEVEL <= 129
|
7
7
|
|
8
|
-
class I18nGettextBackendTest <
|
8
|
+
class I18nGettextBackendTest < I18n::TestCase
|
9
9
|
include I18n::Gettext::Helpers
|
10
10
|
|
11
11
|
class Backend < I18n::Backend::Simple
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class I18nExceptionsTest <
|
3
|
+
class I18nExceptionsTest < I18n::TestCase
|
4
4
|
def test_invalid_locale_stores_locale
|
5
5
|
force_invalid_locale
|
6
|
-
rescue I18n::ArgumentError =>
|
6
|
+
rescue I18n::ArgumentError => exception
|
7
7
|
assert_nil exception.locale
|
8
8
|
end
|
9
9
|
|
@@ -91,28 +91,28 @@ class I18nExceptionsTest < Test::Unit::TestCase
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def force_missing_translation_data(options = {})
|
94
|
-
|
94
|
+
store_translations('de', :bar => nil)
|
95
95
|
I18n.translate(:foo, options.merge(:scope => :bar, :locale => :de))
|
96
96
|
rescue I18n::ArgumentError => e
|
97
97
|
block_given? ? yield(e) : raise(e)
|
98
98
|
end
|
99
99
|
|
100
100
|
def force_invalid_pluralization_data
|
101
|
-
|
101
|
+
store_translations('de', :foo => [:bar])
|
102
102
|
I18n.translate(:foo, :count => 1, :locale => :de)
|
103
103
|
rescue I18n::ArgumentError => e
|
104
104
|
block_given? ? yield(e) : raise(e)
|
105
105
|
end
|
106
106
|
|
107
107
|
def force_missing_interpolation_argument
|
108
|
-
|
108
|
+
store_translations('de', :foo => "%{bar}")
|
109
109
|
I18n.translate(:foo, :baz => 'baz', :locale => :de)
|
110
110
|
rescue I18n::ArgumentError => e
|
111
111
|
block_given? ? yield(e) : raise(e)
|
112
112
|
end
|
113
113
|
|
114
114
|
def force_reserved_interpolation_key
|
115
|
-
|
115
|
+
store_translations('de', :foo => "%{scope}")
|
116
116
|
I18n.translate(:foo, :baz => 'baz', :locale => :de)
|
117
117
|
rescue I18n::ArgumentError => e
|
118
118
|
block_given? ? yield(e) : raise(e)
|
@@ -4,7 +4,7 @@ require 'i18n/core_ext/string/interpolate'
|
|
4
4
|
# thanks to Masao's String extensions, some tests taken from Masao's tests
|
5
5
|
# http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb
|
6
6
|
|
7
|
-
class I18nInterpolateTest <
|
7
|
+
class I18nInterpolateTest < I18n::TestCase
|
8
8
|
test "String interpolates a hash argument w/ named placeholders" do
|
9
9
|
assert_equal "Masao Mutoh", I18n.interpolate("%{first} %{last}", :first => 'Masao', :last => 'Mutoh' )
|
10
10
|
end
|
@@ -60,7 +60,7 @@ class I18nInterpolateTest < Test::Unit::TestCase
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
class I18nMissingInterpolationCustomHandlerTest <
|
63
|
+
class I18nMissingInterpolationCustomHandlerTest < I18n::TestCase
|
64
64
|
def setup
|
65
65
|
@old_handler = I18n.config.missing_interpolation_argument_handler
|
66
66
|
I18n.config.missing_interpolation_argument_handler = lambda do |key, values, string|
|