i18n 0.3.0 → 0.3.1
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/CHANGELOG.textile +19 -0
- data/README.textile +41 -15
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/i18n.rb +1 -1
- data/lib/i18n/backend/active_record.rb +6 -5
- data/lib/i18n/backend/active_record/missing.rb +64 -0
- data/lib/i18n/backend/active_record/translation.rb +2 -2
- data/lib/i18n/backend/base.rb +2 -2
- data/lib/i18n/backend/chain.rb +3 -3
- data/lib/i18n/helpers/gettext.rb +1 -1
- data/test/all.rb +4 -4
- data/test/api/basics.rb +8 -8
- data/test/api/defaults.rb +40 -0
- data/test/api/interpolation.rb +65 -67
- data/test/api/link.rb +31 -38
- data/test/api/localization/date.rb +69 -50
- data/test/api/localization/date_time.rb +66 -42
- data/test/api/localization/procs.rb +54 -0
- data/test/api/localization/time.rb +71 -52
- data/test/api/lookup.rb +38 -0
- data/test/api/pluralization.rb +22 -24
- data/test/api/procs.rb +40 -0
- data/test/cases/api/active_record_test.rb +28 -0
- data/test/cases/api/all_features_test.rb +37 -0
- data/test/cases/api/chain_test.rb +26 -0
- data/test/cases/api/fallbacks_test.rb +33 -0
- data/test/cases/api/pluralization_test.rb +33 -0
- data/test/cases/api/simple_test.rb +21 -0
- data/test/{backend/active_record_missing/active_record_missing_test.rb → cases/backend/active_record/missing_test.rb} +5 -8
- data/test/{backend/active_record → cases/backend}/active_record_test.rb +13 -3
- data/test/{backend/cache → cases/backend}/cache_test.rb +7 -7
- data/test/{backend/chain → cases/backend}/chain_test.rb +1 -1
- data/test/{backend/fallbacks → cases/backend}/fallbacks_test.rb +5 -5
- data/test/{backend/simple → cases/backend}/helpers_test.rb +1 -1
- data/test/{backend/metadata → cases/backend}/metadata_test.rb +12 -10
- data/test/{backend/pluralization → cases/backend}/pluralization_test.rb +10 -10
- data/test/cases/backend/simple_test.rb +77 -0
- data/test/{core_ext → cases/core_ext}/string/interpolate_test.rb +15 -15
- data/test/{gettext → cases/gettext}/api_test.rb +1 -4
- data/test/{gettext → cases/gettext}/backend_test.rb +9 -2
- data/test/{i18n_exceptions_test.rb → cases/i18n_exceptions_test.rb} +1 -1
- data/test/{i18n_load_path_test.rb → cases/i18n_load_path_test.rb} +2 -2
- data/test/{i18n_test.rb → cases/i18n_test.rb} +1 -1
- data/test/{locale → cases/locale}/fallbacks_test.rb +1 -3
- data/test/{locale → cases/locale}/tag/rfc4646_test.rb +1 -3
- data/test/{locale → cases/locale}/tag/simple_test.rb +1 -3
- data/test/fixtures/locales/de.po +5 -0
- data/test/test_helper.rb +45 -30
- data/vendor/po_parser.rb +329 -0
- metadata +60 -69
- data/lib/i18n/backend/active_record_missing.rb +0 -55
- data/test/api/lambda.rb +0 -52
- data/test/api/localization/lambda.rb +0 -26
- data/test/api/translation.rb +0 -51
- data/test/backend/active_record/all.rb +0 -3
- data/test/backend/active_record/api_test.rb +0 -54
- data/test/backend/active_record/setup.rb +0 -166
- data/test/backend/all/api_test.rb +0 -88
- data/test/backend/chain/api_test.rb +0 -80
- data/test/backend/fallbacks/api_test.rb +0 -84
- data/test/backend/pluralization/api_test.rb +0 -86
- data/test/backend/simple/all.rb +0 -5
- data/test/backend/simple/api_test.rb +0 -92
- data/test/backend/simple/lookup_test.rb +0 -24
- data/test/backend/simple/setup.rb +0 -147
- data/test/backend/simple/translations_test.rb +0 -83
- data/test/with_options.rb +0 -34
data/test/api/lookup.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Tests
|
4
|
+
module Api
|
5
|
+
module Lookup
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
store_translations(:foo => { :bar => 'bar', :baz => 'baz' })
|
9
|
+
end
|
10
|
+
|
11
|
+
define_method "test lookup: given a nested key it looks up the nested hash value" do
|
12
|
+
assert_equal 'bar', I18n.t(:'foo.bar')
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method "test lookup: given a missing key, no default and no raise option it returns an error message" do
|
16
|
+
assert_equal "translation missing: en, missing", I18n.t(:missing)
|
17
|
+
end
|
18
|
+
|
19
|
+
define_method "test lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do
|
20
|
+
assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
21
|
+
end
|
22
|
+
|
23
|
+
define_method "test lookup: given an array of keys it translates all of them" do
|
24
|
+
assert_equal %w(bar baz), I18n.t([:bar, :baz], :scope => [:foo])
|
25
|
+
end
|
26
|
+
|
27
|
+
define_method "test lookup: using a custom scope separator" do
|
28
|
+
# data must have been stored using the custom separator when using the ActiveRecord backend
|
29
|
+
I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' })
|
30
|
+
assert_equal 'bar', I18n.t('foo|bar', :separator => '|')
|
31
|
+
end
|
32
|
+
|
33
|
+
define_method "test lookup: given nil as a locale it raises InvalidLocale" do
|
34
|
+
assert_raises(I18n::InvalidLocale) { I18n.t(:bar, :locale => nil) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/test/api/pluralization.rb
CHANGED
@@ -1,36 +1,34 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Tests
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
4
|
+
module Api
|
5
|
+
module Pluralization
|
6
|
+
define_method "test pluralization: given 0 it returns the :zero translation if it is defined" do
|
7
|
+
assert_equal 'zero', I18n.t(:default => { :zero => 'zero' }, :count => 0)
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
define_method "test pluralization: given 0 it returns the :other translation if :zero is not defined" do
|
11
|
+
assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 0)
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
define_method "test pluralization: given 1 it returns the singular translation" do
|
15
|
+
assert_equal 'bar', I18n.t(:default => { :one => 'bar' }, :count => 1)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
define_method "test pluralization: given 2 it returns the :other translation" do
|
19
|
+
assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 2)
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
define_method "test pluralization: given 3 it returns the :other translation" do
|
23
|
+
assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 3)
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
define_method "test pluralization: given nil it returns the whole entry" do
|
27
|
+
assert_equal({ :one => 'bar' }, I18n.t(:default => { :one => 'bar' }, :count => nil))
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
define_method "test pluralization: given incomplete pluralization data it raises I18n::InvalidPluralizationData" do
|
31
|
+
assert_raises(I18n::InvalidPluralizationData) { I18n.t(:default => { :one => 'bar' }, :count => 2) }
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
data/test/api/procs.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Tests
|
4
|
+
module Api
|
5
|
+
module Procs
|
6
|
+
define_method "test lookup: given a translation is a proc it calls the proc with the key and interpolation values" do
|
7
|
+
store_translations(:a_lambda => lambda { |*args| args.inspect })
|
8
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo')
|
9
|
+
end
|
10
|
+
|
11
|
+
define_method "test defaults: given a default is a Proc it calls it with the key and interpolation values" do
|
12
|
+
proc = lambda { |*args| args.inspect }
|
13
|
+
assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
14
|
+
end
|
15
|
+
|
16
|
+
define_method "test defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do
|
17
|
+
store_translations(:a_lambda => lambda { |*args| args.inspect })
|
18
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo')
|
19
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo')
|
20
|
+
end
|
21
|
+
|
22
|
+
define_method "test interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do
|
23
|
+
proc = lambda { |*args| args.inspect }
|
24
|
+
assert_match %r(\[\{:foo=>#<Proc.*>\}\]), I18n.t(nil, :default => '{{foo}}', :foo => proc)
|
25
|
+
end
|
26
|
+
|
27
|
+
define_method "test interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do
|
28
|
+
proc = lambda { |*args| "{{foo}}: " + args.inspect }
|
29
|
+
assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
30
|
+
end
|
31
|
+
|
32
|
+
define_method "test pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do
|
33
|
+
proc = lambda { |*args| { :zero => 'zero', :one => 'one', :other => 'other' } }
|
34
|
+
assert_equal 'zero', I18n.t(:default => proc, :count => 0)
|
35
|
+
assert_equal 'one', I18n.t(:default => proc, :count => 1)
|
36
|
+
assert_equal 'other', I18n.t(:default => proc, :count => 2)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
3
|
+
|
4
|
+
setup_active_record
|
5
|
+
|
6
|
+
class I18nActiveRecordApiTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
I18n.backend = I18n::Backend::ActiveRecord.new
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
include Tests::Api::Basics
|
13
|
+
include Tests::Api::Defaults
|
14
|
+
include Tests::Api::Interpolation
|
15
|
+
include Tests::Api::Link
|
16
|
+
include Tests::Api::Lookup
|
17
|
+
include Tests::Api::Pluralization
|
18
|
+
include Tests::Api::Procs
|
19
|
+
include Tests::Api::Localization::Date
|
20
|
+
include Tests::Api::Localization::DateTime
|
21
|
+
include Tests::Api::Localization::Time
|
22
|
+
include Tests::Api::Localization::Procs
|
23
|
+
|
24
|
+
define_method "test: make sure we use an ActiveRecord backend" do
|
25
|
+
assert_equal I18n::Backend::ActiveRecord, I18n.backend.class
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
+
|
5
|
+
class I18nAllFeaturesApiTest < Test::Unit::TestCase
|
6
|
+
class Backend
|
7
|
+
include I18n::Backend::Base
|
8
|
+
include I18n::Backend::Cache
|
9
|
+
include I18n::Backend::Metadata
|
10
|
+
include I18n::Backend::Fallbacks
|
11
|
+
include I18n::Backend::Pluralization
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
I18n.backend = I18n::Backend::Chain.new(Backend.new, I18n::Backend::Simple.new)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
include Tests::Api::Basics
|
20
|
+
include Tests::Api::Defaults
|
21
|
+
include Tests::Api::Interpolation
|
22
|
+
include Tests::Api::Link
|
23
|
+
include Tests::Api::Lookup
|
24
|
+
include Tests::Api::Pluralization
|
25
|
+
include Tests::Api::Procs
|
26
|
+
include Tests::Api::Localization::Date
|
27
|
+
include Tests::Api::Localization::DateTime
|
28
|
+
include Tests::Api::Localization::Time
|
29
|
+
include Tests::Api::Localization::Procs
|
30
|
+
|
31
|
+
define_method "test: make sure we use a Chain backend with an all features backend" do
|
32
|
+
assert_equal I18n::Backend::Chain, I18n.backend.class
|
33
|
+
assert_equal Backend, I18n.backend.backends.first.class
|
34
|
+
end
|
35
|
+
|
36
|
+
# links: test that keys stored on one backend can link to keys stored on another backend
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
+
|
5
|
+
class I18nApiChainTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
|
9
|
+
end
|
10
|
+
|
11
|
+
include Tests::Api::Basics
|
12
|
+
include Tests::Api::Defaults
|
13
|
+
include Tests::Api::Interpolation
|
14
|
+
include Tests::Api::Link
|
15
|
+
include Tests::Api::Lookup
|
16
|
+
include Tests::Api::Pluralization
|
17
|
+
include Tests::Api::Procs
|
18
|
+
include Tests::Api::Localization::Date
|
19
|
+
include Tests::Api::Localization::DateTime
|
20
|
+
include Tests::Api::Localization::Time
|
21
|
+
include Tests::Api::Localization::Procs
|
22
|
+
|
23
|
+
define_method "test: make sure we use the Chain backend" do
|
24
|
+
assert_equal I18n::Backend::Chain, I18n.backend.class
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
+
|
5
|
+
class I18nFallbacksApiTest < Test::Unit::TestCase
|
6
|
+
class Backend
|
7
|
+
include I18n::Backend::Base
|
8
|
+
include I18n::Backend::Fallbacks
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup
|
12
|
+
I18n.backend = Backend.new
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
include Tests::Api::Basics
|
17
|
+
include Tests::Api::Defaults
|
18
|
+
include Tests::Api::Interpolation
|
19
|
+
include Tests::Api::Link
|
20
|
+
include Tests::Api::Lookup
|
21
|
+
include Tests::Api::Pluralization
|
22
|
+
include Tests::Api::Procs
|
23
|
+
include Tests::Api::Localization::Date
|
24
|
+
include Tests::Api::Localization::DateTime
|
25
|
+
include Tests::Api::Localization::Time
|
26
|
+
include Tests::Api::Localization::Procs
|
27
|
+
|
28
|
+
define_method "test: make sure we use a backend with Fallbacks included" do
|
29
|
+
assert_equal Backend, I18n.backend.class
|
30
|
+
end
|
31
|
+
|
32
|
+
# links: test that keys stored on one backend can link to keys stored on another backend
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
+
|
5
|
+
class I18nPluralizationApiTest < Test::Unit::TestCase
|
6
|
+
class Backend
|
7
|
+
include I18n::Backend::Base
|
8
|
+
include I18n::Backend::Pluralization
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup
|
12
|
+
I18n.backend = Backend.new
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
include Tests::Api::Basics
|
17
|
+
include Tests::Api::Defaults
|
18
|
+
include Tests::Api::Interpolation
|
19
|
+
include Tests::Api::Link
|
20
|
+
include Tests::Api::Lookup
|
21
|
+
include Tests::Api::Pluralization
|
22
|
+
include Tests::Api::Procs
|
23
|
+
include Tests::Api::Localization::Date
|
24
|
+
include Tests::Api::Localization::DateTime
|
25
|
+
include Tests::Api::Localization::Time
|
26
|
+
include Tests::Api::Localization::Procs
|
27
|
+
|
28
|
+
define_method "test: make sure we use a backend with Pluralization included" do
|
29
|
+
assert_equal Backend, I18n.backend.class
|
30
|
+
end
|
31
|
+
|
32
|
+
# links: test that keys stored on one backend can link to keys stored on another backend
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
+
|
5
|
+
class I18nSimpleBackendApiTest < Test::Unit::TestCase
|
6
|
+
include Tests::Api::Basics
|
7
|
+
include Tests::Api::Defaults
|
8
|
+
include Tests::Api::Interpolation
|
9
|
+
include Tests::Api::Link
|
10
|
+
include Tests::Api::Lookup
|
11
|
+
include Tests::Api::Pluralization
|
12
|
+
include Tests::Api::Procs
|
13
|
+
include Tests::Api::Localization::Date
|
14
|
+
include Tests::Api::Localization::DateTime
|
15
|
+
include Tests::Api::Localization::Time
|
16
|
+
include Tests::Api::Localization::Procs
|
17
|
+
|
18
|
+
define_method "test: make sure we use the Simple backend" do
|
19
|
+
assert_equal I18n::Backend::Simple, I18n.backend.class
|
20
|
+
end
|
21
|
+
end
|
@@ -1,17 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
3
|
-
|
4
|
-
|
5
|
-
require 'i18n/backend/active_record_missing'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
3
|
+
|
4
|
+
setup_active_record
|
6
5
|
|
7
6
|
class I18nActiveRecordMissingTest < Test::Unit::TestCase
|
8
|
-
include Tests::Backend::ActiveRecord::Setup::Base
|
9
|
-
|
10
7
|
def setup
|
11
|
-
|
8
|
+
store_translations(:en, :i18n => { :plural_keys => [:zero, :one, :other] })
|
12
9
|
|
13
10
|
I18n.backend = I18n::Backend::Chain.new(I18n.backend)
|
14
|
-
I18n.backend.meta_class.send(:include, I18n::Backend::
|
11
|
+
I18n.backend.meta_class.send(:include, I18n::Backend::ActiveRecord::Missing)
|
15
12
|
|
16
13
|
I18n::Backend::ActiveRecord::Translation.delete_all
|
17
14
|
end
|
@@ -1,9 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
3
|
-
require 'i18n/backend/active_record'
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
setup_active_record
|
5
|
+
|
6
|
+
class I18nBackendActiveRecordTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
I18n.backend = I18n::Backend::ActiveRecord.new
|
9
|
+
I18n::Backend::ActiveRecord::Translation.send(:include, I18n::Backend::ActiveRecord::StoreProcs)
|
10
|
+
store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' })
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
I18n::Backend::ActiveRecord::Translation.destroy_all
|
15
|
+
super
|
16
|
+
end
|
7
17
|
|
8
18
|
def test_store_translations_does_not_allow_ambigous_keys_1
|
9
19
|
I18n::Backend::ActiveRecord::Translation.delete_all
|
@@ -4,12 +4,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
|
4
4
|
require 'i18n/backend/cache'
|
5
5
|
|
6
6
|
begin
|
7
|
-
require 'active_support
|
7
|
+
require 'active_support'
|
8
8
|
rescue LoadError
|
9
|
-
$stderr.puts "Skipping cache tests using ActiveSupport
|
9
|
+
$stderr.puts "Skipping cache tests using ActiveSupport"
|
10
10
|
else
|
11
11
|
|
12
|
-
class
|
12
|
+
class I18nBackendCacheTest < Test::Unit::TestCase
|
13
13
|
class Backend
|
14
14
|
include I18n::Backend::Base
|
15
15
|
include I18n::Backend::Cache
|
@@ -29,7 +29,7 @@ class I18nCacheBackendTest < Test::Unit::TestCase
|
|
29
29
|
assert I18n.cache_store.is_a?(ActiveSupport::Cache::MemoryStore)
|
30
30
|
end
|
31
31
|
|
32
|
-
define_method
|
32
|
+
define_method "test translate hits the backend and caches the response" do
|
33
33
|
I18n.backend.expects(:lookup).returns('Foo')
|
34
34
|
assert_equal 'Foo', I18n.t(:foo)
|
35
35
|
|
@@ -40,18 +40,18 @@ class I18nCacheBackendTest < Test::Unit::TestCase
|
|
40
40
|
assert_equal 'Bar', I18n.t(:bar)
|
41
41
|
end
|
42
42
|
|
43
|
-
define_method
|
43
|
+
define_method "test still raises MissingTranslationData but also caches it" do
|
44
44
|
I18n.backend.expects(:lookup).returns(nil)
|
45
45
|
assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
46
46
|
I18n.backend.expects(:lookup).never
|
47
47
|
assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
48
48
|
end
|
49
49
|
|
50
|
-
define_method
|
50
|
+
define_method "test uses 'i18n' as a cache key namespace by default" do
|
51
51
|
assert_equal 0, I18n.backend.send(:cache_key, :foo).index('i18n')
|
52
52
|
end
|
53
53
|
|
54
|
-
define_method
|
54
|
+
define_method "test adds a custom cache key namespace" do
|
55
55
|
with_cache_namespace('bar') do
|
56
56
|
assert_equal 0, I18n.backend.send(:cache_key, :foo).index('i18n-bar')
|
57
57
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
4
|
require 'i18n/backend/chain'
|
5
5
|
|
6
|
-
class
|
6
|
+
class I18nBackendChainTest < Test::Unit::TestCase
|
7
7
|
def setup
|
8
8
|
@first = backend(:en => {
|
9
9
|
:foo => 'Foo', :formats => { :short => 'short' }, :plural_1 => { :one => '{{count}}' }
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
4
|
|
5
|
-
class
|
5
|
+
class I18nBackendFallbacksTest < Test::Unit::TestCase
|
6
6
|
class Backend
|
7
7
|
include I18n::Backend::Base
|
8
8
|
include I18n::Backend::Fallbacks
|
@@ -10,9 +10,9 @@ class I18nFallbacksBackendTest < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def setup
|
12
12
|
I18n.backend = Backend.new
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
store_translations(:en, :foo => 'Foo in :en', :bar => 'Bar in :en', :buz => 'Buz in :en')
|
14
|
+
store_translations(:de, :bar => 'Bar in :de', :baz => 'Baz in :de')
|
15
|
+
store_translations(:'de-DE', :baz => 'Baz in :de-DE')
|
16
16
|
end
|
17
17
|
|
18
18
|
define_method "test: still returns an existing translation as usual" do
|
@@ -39,7 +39,7 @@ class I18nFallbacksBackendTest < Test::Unit::TestCase
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
class
|
42
|
+
class I18nBackendFallbacksWithChainTest < Test::Unit::TestCase
|
43
43
|
class Backend
|
44
44
|
include I18n::Backend::Base
|
45
45
|
include I18n::Backend::Fallbacks
|