i18n 0.3.6 → 0.3.7

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 (62) hide show
  1. data/lib/i18n.rb +29 -4
  2. data/lib/i18n/backend/active_record/translation.rb +6 -4
  3. data/lib/i18n/backend/base.rb +1 -1
  4. data/lib/i18n/locale/fallbacks.rb +4 -4
  5. data/lib/i18n/version.rb +1 -1
  6. metadata +16 -116
  7. data/CHANGELOG.textile +0 -76
  8. data/MIT-LICENSE +0 -20
  9. data/README.textile +0 -104
  10. data/Rakefile +0 -29
  11. data/test/all.rb +0 -8
  12. data/test/api.rb +0 -18
  13. data/test/api/active_record_test.rb +0 -30
  14. data/test/api/all_features_test.rb +0 -59
  15. data/test/api/cascade_test.rb +0 -32
  16. data/test/api/chain_test.rb +0 -27
  17. data/test/api/fallbacks_test.rb +0 -34
  18. data/test/api/fast_test.rb +0 -32
  19. data/test/api/pluralization_test.rb +0 -34
  20. data/test/api/simple_test.rb +0 -23
  21. data/test/api/tests/basics.rb +0 -15
  22. data/test/api/tests/defaults.rb +0 -40
  23. data/test/api/tests/interpolation.rb +0 -92
  24. data/test/api/tests/link.rb +0 -56
  25. data/test/api/tests/localization/date.rb +0 -96
  26. data/test/api/tests/localization/date_time.rb +0 -93
  27. data/test/api/tests/localization/procs.rb +0 -60
  28. data/test/api/tests/localization/time.rb +0 -88
  29. data/test/api/tests/lookup.rb +0 -62
  30. data/test/api/tests/pluralization.rb +0 -35
  31. data/test/api/tests/procs.rb +0 -55
  32. data/test/backend/active_record/missing_test.rb +0 -51
  33. data/test/backend/active_record_test.rb +0 -57
  34. data/test/backend/cache_test.rb +0 -71
  35. data/test/backend/cascade_test.rb +0 -73
  36. data/test/backend/chain_test.rb +0 -63
  37. data/test/backend/cldr_test.rb +0 -151
  38. data/test/backend/exceptions_test.rb +0 -25
  39. data/test/backend/fallbacks_test.rb +0 -107
  40. data/test/backend/fast_test.rb +0 -50
  41. data/test/backend/helpers_test.rb +0 -27
  42. data/test/backend/interpolation_compiler_test.rb +0 -108
  43. data/test/backend/metadata_test.rb +0 -66
  44. data/test/backend/pluralization_test.rb +0 -47
  45. data/test/backend/simple_test.rb +0 -77
  46. data/test/core_ext/string/interpolate_test.rb +0 -99
  47. data/test/gettext/api_test.rb +0 -207
  48. data/test/gettext/backend_test.rb +0 -91
  49. data/test/i18n_exceptions_test.rb +0 -97
  50. data/test/i18n_load_path_test.rb +0 -23
  51. data/test/i18n_test.rb +0 -207
  52. data/test/locale/fallbacks_test.rb +0 -126
  53. data/test/locale/tag/rfc4646_test.rb +0 -143
  54. data/test/locale/tag/simple_test.rb +0 -33
  55. data/test/test_data/locales/cldr/de/calendars.yml +0 -152
  56. data/test/test_data/locales/cldr/de/currencies.yml +0 -8
  57. data/test/test_data/locales/cldr/de/numbers.yml +0 -31
  58. data/test/test_data/locales/de.po +0 -72
  59. data/test/test_data/locales/en.rb +0 -3
  60. data/test/test_data/locales/en.yml +0 -3
  61. data/test/test_data/locales/plurals.rb +0 -113
  62. data/test/test_helper.rb +0 -116
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Tests
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
9
-
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
13
-
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
17
-
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
21
-
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
25
-
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
29
-
30
- define_method "test pluralization: given incomplete pluralization data it raises I18n::InvalidPluralizationData" do
31
- assert_raise(I18n::InvalidPluralizationData) { I18n.t(:default => { :one => 'bar' }, :count => 2) }
32
- end
33
- end
34
- end
35
- end
@@ -1,55 +0,0 @@
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
- if can_store_procs?
8
- store_translations(:a_lambda => lambda { |*args| args.inspect })
9
- assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo')
10
- end
11
- end
12
-
13
- define_method "test defaults: given a default is a Proc it calls it with the key and interpolation values" do
14
- proc = lambda { |*args| args.inspect }
15
- assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
16
- end
17
-
18
- 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
19
- if can_store_procs?
20
- store_translations(:a_lambda => lambda { |*args| args.inspect })
21
- assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo')
22
- assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo')
23
- end
24
- end
25
-
26
- define_method "test interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do
27
- proc = lambda { |*args| args.inspect }
28
- assert_match %r(\[\{:foo=>#<Proc.*>\}\]), I18n.t(nil, :default => '{{foo}}', :foo => proc)
29
- end
30
-
31
- define_method "test interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do
32
- proc = lambda { |*args| "{{foo}}: " + args.inspect }
33
- assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
34
- end
35
-
36
- define_method "test pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do
37
- proc = lambda { |*args| { :zero => 'zero', :one => 'one', :other => 'other' } }
38
- assert_equal 'zero', I18n.t(:default => proc, :count => 0)
39
- assert_equal 'one', I18n.t(:default => proc, :count => 1)
40
- assert_equal 'other', I18n.t(:default => proc, :count => 2)
41
- end
42
-
43
- define_method "test lookup: given the option :resolve => false was passed it does not resolve proc translations" do
44
- if can_store_procs?
45
- store_translations(:a_lambda => lambda { |*args| args.inspect })
46
- assert_equal Proc, I18n.t(:a_lambda, :resolve => false).class
47
- end
48
- end
49
-
50
- define_method "test lookup: given the option :resolve => false was passed it does not resolve proc default" do
51
- assert_equal Proc, I18n.t(nil, :default => lambda { |*args| args.inspect }, :resolve => false).class
52
- end
53
- end
54
- end
55
- end
@@ -1,51 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- require_active_record!
6
-
7
- class I18nActiveRecordMissingTest < Test::Unit::TestCase
8
- def setup
9
- store_translations(:en, :i18n => { :plural => { :keys => [:zero, :one, :other] } })
10
-
11
- I18n.backend = I18n::Backend::Chain.new(I18n.backend)
12
- I18n.backend.meta_class.send(:include, I18n::Backend::ActiveRecord::Missing)
13
-
14
- I18n::Backend::ActiveRecord::Translation.delete_all
15
- end
16
-
17
- test "can persist interpolations" do
18
- translation = I18n::Backend::ActiveRecord::Translation.new(:key => 'foo', :value => 'bar', :locale => :en)
19
- translation.interpolations = %w(count name)
20
- translation.save
21
- assert translation.valid?
22
- end
23
-
24
- test "lookup persists the key" do
25
- I18n.t('foo.bar.baz')
26
- assert_equal 1, I18n::Backend::ActiveRecord::Translation.count
27
- end
28
-
29
- test "lookup does not persist the key twice" do
30
- 2.times { I18n.t('foo.bar.baz') }
31
- assert_equal 1, I18n::Backend::ActiveRecord::Translation.count
32
- end
33
-
34
- test "lookup persists interpolation keys when looked up directly" do
35
- I18n.t('foo.bar.baz', :cow => "lucy" ) # creates stub translation.
36
- translation_stub = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo.bar.baz').first
37
- assert translation_stub.interpolates?(:cow)
38
- end
39
-
40
- test "creates one stub per pluralization" do
41
- I18n.t('foo', :count => 999)
42
- translations = I18n::Backend::ActiveRecord::Translation.locale(:en).find_all_by_key %w{ foo.zero foo.one foo.other }
43
- assert_equal 3, translations.length
44
- end
45
-
46
- test "creates no stub for base key in pluralization" do
47
- I18n.t('foo', :count => 999)
48
- translations = I18n::Backend::ActiveRecord::Translation.locale(:en).find_by_key %w{ foo.zero foo.one foo.other }
49
- assert !I18n::Backend::ActiveRecord::Translation.locale(:en).find_by_key("foo")
50
- end
51
- end if defined?(ActiveRecord)
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- require_active_record!
6
-
7
- class I18nBackendActiveRecordTest < Test::Unit::TestCase
8
- def setup
9
- I18n.backend = I18n::Backend::ActiveRecord.new
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
17
-
18
- test "store_translations does not allow ambiguous keys (1)" do
19
- I18n::Backend::ActiveRecord::Translation.delete_all
20
- I18n.backend.store_translations(:en, :foo => 'foo')
21
- I18n.backend.store_translations(:en, :foo => { :bar => 'bar' })
22
- I18n.backend.store_translations(:en, :foo => { :baz => 'baz' })
23
-
24
- translations = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo', '.').all
25
- assert_equal %w(bar baz), translations.map(&:value)
26
-
27
- assert_equal({ :bar => 'bar', :baz => 'baz' }, I18n.t(:foo))
28
- end
29
-
30
- test "store_translations does not allow ambiguous keys (2)" do
31
- I18n::Backend::ActiveRecord::Translation.delete_all
32
- I18n.backend.store_translations(:en, :foo => { :bar => 'bar' })
33
- I18n.backend.store_translations(:en, :foo => { :baz => 'baz' })
34
- I18n.backend.store_translations(:en, :foo => 'foo')
35
-
36
- translations = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo', '.').all
37
- assert_equal %w(foo), translations.map(&:value)
38
-
39
- assert_equal 'foo', I18n.t(:foo)
40
- end
41
-
42
- test "can store translations with keys that are translations containing special chars" do
43
- I18n.backend.store_translations(:es, :"Pagina's" => "Pagina's" )
44
- assert_equal "Pagina's", I18n.t(:"Pagina's", :locale => :es)
45
- end
46
-
47
- with_mocha do
48
- test "missing translations table does not cause an error in #available_locales" do
49
- I18n::Backend::ActiveRecord::Translation.expects(:available_locales).raises(::ActiveRecord::StatementInvalid)
50
- assert_equal [], I18n.backend.available_locales
51
- end
52
- end
53
-
54
- def test_expand_keys
55
- assert_equal %w(foo foo.bar foo.bar.baz), I18n.backend.send(:expand_keys, :'foo.bar.baz')
56
- end
57
- end if defined?(ActiveRecord)
@@ -1,71 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- begin
6
- require 'active_support'
7
- rescue LoadError
8
- $stderr.puts "Skipping cache tests using ActiveSupport"
9
- else
10
-
11
- class I18nBackendCacheTest < Test::Unit::TestCase
12
- class Backend
13
- include I18n::Backend::Base
14
- include I18n::Backend::Cache
15
- end
16
-
17
- def setup
18
- I18n.backend = Backend.new
19
- super
20
- I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store)
21
- end
22
-
23
- def teardown
24
- I18n.cache_store = nil
25
- end
26
-
27
- test "it uses the cache" do
28
- assert I18n.cache_store.is_a?(ActiveSupport::Cache::MemoryStore)
29
- end
30
-
31
- with_mocha do
32
- test "translate hits the backend and caches the response" do
33
- I18n.backend.expects(:lookup).returns('Foo')
34
- assert_equal 'Foo', I18n.t(:foo)
35
-
36
- I18n.backend.expects(:lookup).never
37
- assert_equal 'Foo', I18n.t(:foo)
38
-
39
- I18n.backend.expects(:lookup).returns('Bar')
40
- assert_equal 'Bar', I18n.t(:bar)
41
- end
42
-
43
- test "still raises MissingTranslationData but also caches it" do
44
- I18n.backend.expects(:lookup).returns(nil)
45
- assert_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
46
-
47
- I18n.backend.expects(:lookup).never
48
- assert_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
49
- end
50
- end
51
-
52
- test "uses 'i18n' as a cache key namespace by default" do
53
- assert_equal 0, I18n.backend.send(:cache_key, :foo).index('i18n')
54
- end
55
-
56
- test "adds a custom cache key namespace" do
57
- with_cache_namespace('bar') do
58
- assert_equal 0, I18n.backend.send(:cache_key, :foo).index('i18n-bar')
59
- end
60
- end
61
-
62
- protected
63
-
64
- def with_cache_namespace(namespace)
65
- I18n.cache_namespace = namespace
66
- yield
67
- I18n.cache_namespace = nil
68
- end
69
- end
70
-
71
- end # AS cache check
@@ -1,73 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- class I18nBackendCascadeTest < Test::Unit::TestCase
6
- class Backend
7
- include I18n::Backend::Base
8
- include I18n::Backend::Cascade
9
- end
10
-
11
- def setup
12
- I18n.backend = Backend.new
13
- store_translations(:en,
14
- :foo => 'foo',
15
- :bar => { :baz => 'baz' }
16
- )
17
- end
18
-
19
- def lookup(key, options = {})
20
- I18n.t(key, options.merge(:cascade => { :step => 1, :offset => 1, :skip_root => false }))
21
- end
22
-
23
- test "still returns an existing translation as usual" do
24
- assert_equal 'foo', lookup(:foo)
25
- assert_equal 'baz', lookup(:'bar.baz')
26
- end
27
-
28
- test "falls back by cutting keys off the end of the scope" do
29
- assert_equal 'foo', lookup(:foo, :scope => :'missing')
30
- assert_equal 'foo', lookup(:foo, :scope => :'missing.missing')
31
- assert_equal 'baz', lookup(:baz, :scope => :'bar.missing')
32
- assert_equal 'baz', lookup(:baz, :scope => :'bar.missing.missing')
33
- end
34
-
35
- test "raises I18n::MissingTranslationData exception when no translation was found" do
36
- assert_raise(I18n::MissingTranslationData) { lookup(:'foo.missing', :raise => true) }
37
- assert_raise(I18n::MissingTranslationData) { lookup(:'bar.baz.missing', :raise => true) }
38
- assert_raise(I18n::MissingTranslationData) { lookup(:'missing.bar.baz', :raise => true) }
39
- end
40
-
41
- test "cascades before evaluating the default" do
42
- assert_equal 'foo', lookup(:foo, :scope => :missing, :default => 'default')
43
- end
44
-
45
- test "cascades defaults, too" do
46
- assert_equal 'foo', lookup(nil, :default => [:'missing.missing', :'missing.foo'])
47
- end
48
-
49
- test "let's us assemble required fallbacks for ActiveRecord validation messages" do
50
- store_translations(:en,
51
- :errors => {
52
- :reply => {
53
- :title => {
54
- :blank => 'blank on reply title'
55
- },
56
- :taken => 'taken on reply'
57
- },
58
- :topic => {
59
- :title => {
60
- :format => 'format on topic title'
61
- },
62
- :length => 'length on topic'
63
- },
64
- :odd => 'odd on errors'
65
- }
66
- )
67
- assert_equal 'blank on reply title', lookup(:'errors.reply.title.blank', :default => :'errors.topic.title.blank')
68
- assert_equal 'taken on reply', lookup(:'errors.reply.title.taken', :default => :'errors.topic.title.taken')
69
- assert_equal 'format on topic title', lookup(:'errors.reply.title.format', :default => :'errors.topic.title.format')
70
- assert_equal 'length on topic', lookup(:'errors.reply.title.length', :default => :'errors.topic.title.length')
71
- assert_equal 'odd on errors', lookup(:'errors.reply.title.odd', :default => :'errors.topic.title.odd')
72
- end
73
- end
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- class I18nBackendChainTest < Test::Unit::TestCase
6
- def setup
7
- @first = backend(:en => {
8
- :foo => 'Foo', :formats => { :short => 'short' }, :plural_1 => { :one => '{{count}}' }
9
- })
10
- @second = backend(:en => {
11
- :bar => 'Bar', :formats => { :long => 'long' }, :plural_2 => { :one => 'one' }
12
- })
13
- @chain = I18n.backend = I18n::Backend::Chain.new(@first, @second)
14
- end
15
-
16
- test "looks up translations from the first chained backend" do
17
- assert_equal 'Foo', @first.send(:translations)[:en][:foo]
18
- assert_equal 'Foo', I18n.t(:foo)
19
- end
20
-
21
- test "looks up translations from the second chained backend" do
22
- assert_equal 'Bar', @second.send(:translations)[:en][:bar]
23
- assert_equal 'Bar', I18n.t(:bar)
24
- end
25
-
26
- test "defaults only apply to lookups on the last backend in the chain" do
27
- assert_equal 'Foo', I18n.t(:foo, :default => 'Bah')
28
- assert_equal 'Bar', I18n.t(:bar, :default => 'Bah')
29
- assert_equal 'Bah', I18n.t(:bah, :default => 'Bah') # default kicks in only here
30
- end
31
-
32
- test "default" do
33
- assert_equal 'Fuh', I18n.t(:default => 'Fuh')
34
- assert_equal 'Zero', I18n.t(:default => { :zero => 'Zero' }, :count => 0)
35
- assert_equal({ :zero => 'Zero' }, I18n.t(:default => { :zero => 'Zero' }))
36
- assert_equal 'Foo', I18n.t(:default => :foo)
37
- end
38
-
39
- test "namespace lookup collects results from all backends" do
40
- assert_equal({ :short => 'short', :long => 'long' }, I18n.t(:formats))
41
- end
42
-
43
- test "namespace lookup with only the first backend returning a result" do
44
- assert_equal({ :one => '{{count}}' }, I18n.t(:plural_1))
45
- end
46
-
47
- test "pluralization still works" do
48
- assert_equal '1', I18n.t(:plural_1, :count => 1)
49
- assert_equal 'one', I18n.t(:plural_2, :count => 1)
50
- end
51
-
52
- test "bulk lookup collects results from all backends" do
53
- assert_equal ['Foo', 'Bar'], I18n.t([:foo, :bar])
54
- end
55
-
56
- protected
57
-
58
- def backend(translations)
59
- backend = I18n::Backend::Simple.new
60
- translations.each { |locale, translations| backend.store_translations(locale, translations) }
61
- backend
62
- end
63
- end
@@ -1,151 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- require 'cldr'
5
- rescue LoadError
6
- puts "Skipping tests for I18n::Backend::Cldr because the ruby-cldr gem is not installed."
7
- end
8
-
9
- if defined?(Cldr)
10
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
11
- require 'test_helper'
12
- require 'i18n/backend/cldr'
13
- require 'date'
14
-
15
- class I18nBackendCldrTest < Test::Unit::TestCase
16
- class Backend
17
- include I18n::Backend::Base
18
- include I18n::Backend::Cldr
19
- end
20
-
21
- def setup
22
- I18n.backend = Backend.new
23
- I18n.locale = :de
24
- I18n.load_path += Dir[locales_dir + '/cldr/**/*.{yml,rb}']
25
- super
26
- end
27
-
28
- # NUMBER
29
-
30
- test "format_number" do
31
- assert_equal '123.456,78', I18n.l(123456.78)
32
- end
33
-
34
- # CURRENCY
35
-
36
- test "format_currency" do
37
- assert_equal '123.456,78 EUR', I18n.l(123456.78, :currency => 'EUR')
38
- end
39
-
40
- # hu? does this actually make any sense?
41
- test "format_currency translating currency names" do
42
- assert_equal '1,00 Irisches Pfund', I18n.l(1, :currency => :IEP)
43
- assert_equal '2,00 Irische Pfund', I18n.l(2, :currency => :IEP)
44
- end
45
-
46
- # PERCENT
47
-
48
- # this is odd but the cldr percent format does not include a fraction
49
- test "format_percent" do
50
- assert_equal '123.457 %', I18n.l(123456.78, :as => :percent)
51
- end
52
-
53
- # so we can pass a precision manually
54
- test "format_percent w/ precision" do
55
- assert_equal '123.456,70 %', I18n.l(123456.7, :as => :percent, :precision => 2)
56
- end
57
-
58
- # DATE
59
-
60
- def date
61
- Date.new(2010, 1, 1)
62
- end
63
-
64
- test "format_date :full" do
65
- assert_equal 'Freitag, 1. Januar 2010', I18n.l(date, :format => :full)
66
- end
67
-
68
- test "format_date :long" do
69
- assert_equal '1. Januar 2010', I18n.l(date, :format => :long)
70
- end
71
-
72
- test "format_date :medium" do
73
- assert_equal '01.01.2010', I18n.l(date)
74
- end
75
-
76
- test "format_date :short" do
77
- assert_equal '01.01.10', I18n.l(date, :format => :short)
78
- end
79
-
80
- # TIME
81
-
82
- def time
83
- Time.utc(2010, 1, 1, 13, 15, 17)
84
- end
85
-
86
- # TODO cldr export lacks localized timezone data
87
- # test "format_time :full" do
88
- # assert_equal 'Freitag, 1. Januar 2010', I18n.l(time, :format => :full)
89
- # end
90
-
91
- test "format_time :long" do
92
- assert_equal '13:15:17 UTC', I18n.l(time, :format => :long)
93
- end
94
-
95
- test "format_time :medium" do
96
- assert_equal '13:15:17', I18n.l(time)
97
- end
98
-
99
- test "format_time :short" do
100
- assert_equal '13:15', I18n.l(time, :format => :short)
101
- end
102
-
103
- # DATETIME
104
-
105
- def datetime
106
- DateTime.new(2010, 11, 12, 13, 14, 15)
107
- end
108
-
109
- # TODO cldr export lacks localized timezone data
110
- # test "format_datetime :full" do
111
- # assert_equal 'Thursday, 12. November 2010 13:14:15', I18n.l(datetime, :format => :full)
112
- # end
113
-
114
- test "format_datetime :long" do
115
- assert_equal '12. November 2010 13:14:15 +00:00', I18n.l(datetime, :format => :long)
116
- end
117
-
118
- test "format_datetime :medium" do
119
- assert_equal '12.11.2010 13:14:15', I18n.l(datetime)
120
- end
121
-
122
- test "format_datetime :short" do
123
- assert_equal '12.11.10 13:14', I18n.l(datetime, :format => :short)
124
- end
125
-
126
- test "format_datetime mixed :long + :short" do
127
- assert_equal '12. November 2010 13:14', I18n.l(datetime, :date_format => :long, :time_format => :short)
128
- end
129
-
130
- test "format_datetime mixed :short + :long" do
131
- assert_equal '12.11.10 13:14:15 +00:00', I18n.l(datetime, :date_format => :short, :time_format => :long)
132
- end
133
-
134
- # CUSTOM FORMATS
135
-
136
- test "can deal with customized formats data" do
137
- store_translations :de, :numbers => {
138
- :formats => {
139
- :decimal => {
140
- :patterns => {
141
- :default => "#,##0.###",
142
- :stupid => "#"
143
- }
144
- }
145
- }
146
- }
147
- assert_equal '123.456,78', I18n.l(123456.78)
148
- assert_equal '123457', I18n.l(123456.78, :format => :stupid)
149
- end
150
- end
151
- end