polish 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +14 -0
  3. data/README.md +9 -10
  4. data/Rakefile +25 -46
  5. data/VERSION +1 -0
  6. data/lib/polish.rb +5 -64
  7. data/lib/polish/locale/actionview.yml +5 -1
  8. data/lib/polish/locale/activerecord.yml +6 -1
  9. data/lib/polish/locale/datetime.rb +44 -0
  10. data/lib/polish/locale/datetime.yml +6 -15
  11. data/lib/polish/locale/pluralize.rb +16 -11
  12. data/lib/polish/proxies.rb +45 -0
  13. data/lib/proxies.rb +2 -0
  14. data/polish.gemspec +75 -0
  15. data/rails/init.rb +1 -0
  16. data/spec/fixtures/en.yml +2 -1
  17. data/spec/i18n/locale/datetime_spec.rb +30 -13
  18. data/spec/locale_spec.rb +23 -10
  19. data/spec/polish_spec.rb +11 -59
  20. data/spec/proxies_spec.rb +66 -0
  21. data/spec/spec_helper.rb +2 -0
  22. metadata +44 -79
  23. data/init.rb +0 -1
  24. data/lib/polish/backend/advanced.rb +0 -107
  25. data/lib/vendor/i18n/CHANGELOG.textile +0 -57
  26. data/lib/vendor/i18n/MIT-LICENSE +0 -20
  27. data/lib/vendor/i18n/README.textile +0 -42
  28. data/lib/vendor/i18n/Rakefile +0 -21
  29. data/lib/vendor/i18n/VERSION +0 -1
  30. data/lib/vendor/i18n/i18n.gemspec +0 -141
  31. data/lib/vendor/i18n/lib/i18n.rb +0 -270
  32. data/lib/vendor/i18n/lib/i18n/backend/base.rb +0 -251
  33. data/lib/vendor/i18n/lib/i18n/backend/cache.rb +0 -71
  34. data/lib/vendor/i18n/lib/i18n/backend/chain.rb +0 -64
  35. data/lib/vendor/i18n/lib/i18n/backend/fallbacks.rb +0 -53
  36. data/lib/vendor/i18n/lib/i18n/backend/gettext.rb +0 -65
  37. data/lib/vendor/i18n/lib/i18n/backend/pluralization.rb +0 -56
  38. data/lib/vendor/i18n/lib/i18n/backend/simple.rb +0 -23
  39. data/lib/vendor/i18n/lib/i18n/exceptions.rb +0 -61
  40. data/lib/vendor/i18n/lib/i18n/gettext.rb +0 -25
  41. data/lib/vendor/i18n/lib/i18n/helpers/gettext.rb +0 -35
  42. data/lib/vendor/i18n/lib/i18n/locale/fallbacks.rb +0 -100
  43. data/lib/vendor/i18n/lib/i18n/locale/tag.rb +0 -27
  44. data/lib/vendor/i18n/lib/i18n/locale/tag/parents.rb +0 -24
  45. data/lib/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb +0 -78
  46. data/lib/vendor/i18n/lib/i18n/locale/tag/simple.rb +0 -44
  47. data/lib/vendor/i18n/lib/i18n/string.rb +0 -95
  48. data/lib/vendor/i18n/test/all.rb +0 -5
  49. data/lib/vendor/i18n/test/api/basics.rb +0 -15
  50. data/lib/vendor/i18n/test/api/interpolation.rb +0 -85
  51. data/lib/vendor/i18n/test/api/lambda.rb +0 -52
  52. data/lib/vendor/i18n/test/api/link.rb +0 -47
  53. data/lib/vendor/i18n/test/api/localization/date.rb +0 -65
  54. data/lib/vendor/i18n/test/api/localization/date_time.rb +0 -63
  55. data/lib/vendor/i18n/test/api/localization/lambda.rb +0 -26
  56. data/lib/vendor/i18n/test/api/localization/time.rb +0 -63
  57. data/lib/vendor/i18n/test/api/pluralization.rb +0 -37
  58. data/lib/vendor/i18n/test/api/translation.rb +0 -51
  59. data/lib/vendor/i18n/test/backend/cache/cache_test.rb +0 -57
  60. data/lib/vendor/i18n/test/backend/chain/api_test.rb +0 -80
  61. data/lib/vendor/i18n/test/backend/chain/chain_test.rb +0 -64
  62. data/lib/vendor/i18n/test/backend/fallbacks/api_test.rb +0 -79
  63. data/lib/vendor/i18n/test/backend/fallbacks/fallbacks_test.rb +0 -29
  64. data/lib/vendor/i18n/test/backend/pluralization/api_test.rb +0 -81
  65. data/lib/vendor/i18n/test/backend/pluralization/pluralization_test.rb +0 -39
  66. data/lib/vendor/i18n/test/backend/simple/all.rb +0 -5
  67. data/lib/vendor/i18n/test/backend/simple/api_test.rb +0 -90
  68. data/lib/vendor/i18n/test/backend/simple/lookup_test.rb +0 -24
  69. data/lib/vendor/i18n/test/backend/simple/setup.rb +0 -147
  70. data/lib/vendor/i18n/test/backend/simple/translations_test.rb +0 -89
  71. data/lib/vendor/i18n/test/fixtures/locales/de.po +0 -61
  72. data/lib/vendor/i18n/test/fixtures/locales/en.rb +0 -3
  73. data/lib/vendor/i18n/test/fixtures/locales/en.yml +0 -3
  74. data/lib/vendor/i18n/test/fixtures/locales/plurals.rb +0 -112
  75. data/lib/vendor/i18n/test/gettext/api_test.rb +0 -78
  76. data/lib/vendor/i18n/test/gettext/backend_test.rb +0 -35
  77. data/lib/vendor/i18n/test/i18n_exceptions_test.rb +0 -97
  78. data/lib/vendor/i18n/test/i18n_load_path_test.rb +0 -23
  79. data/lib/vendor/i18n/test/i18n_test.rb +0 -163
  80. data/lib/vendor/i18n/test/locale/fallbacks_test.rb +0 -128
  81. data/lib/vendor/i18n/test/locale/tag/rfc4646_test.rb +0 -147
  82. data/lib/vendor/i18n/test/locale/tag/simple_test.rb +0 -35
  83. data/lib/vendor/i18n/test/string_test.rb +0 -94
  84. data/lib/vendor/i18n/test/test_helper.rb +0 -71
  85. data/lib/vendor/i18n/test/with_options.rb +0 -34
  86. data/lib/vendor/i18n/vendor/po_parser.rb +0 -329
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
4
- require 'i18n/backend/pluralization'
5
-
6
- module PluralizationSetup
7
- def setup
8
- super
9
- I18n.backend.meta_class.send(:include, I18n::Backend::Pluralization)
10
- I18n.load_path << locales_dir + '/plurals.rb'
11
- end
12
-
13
- def test_uses_pluralization
14
- assert I18n.backend.meta_class.included_modules.include?(I18n::Backend::Pluralization)
15
- end
16
- end
17
-
18
- class I18nPluralizationBackendApiBasicsTest < Test::Unit::TestCase
19
- include PluralizationSetup
20
- include Tests::Backend::Api::Basics
21
- end
22
-
23
- class I18nPluralizationBackendApiTranslateTest < Test::Unit::TestCase
24
- include Tests::Backend::Simple::Setup::Base
25
- include PluralizationSetup
26
- include Tests::Backend::Api::Translation
27
- end
28
-
29
- class I18nPluralizationBackendApiInterpolateTest < Test::Unit::TestCase
30
- include Tests::Backend::Simple::Setup::Base
31
- include PluralizationSetup
32
- include Tests::Backend::Api::Interpolation
33
- end
34
-
35
- class I18nPluralizationBackendApiLambdaTest < Test::Unit::TestCase
36
- include Tests::Backend::Simple::Setup::Base
37
- include PluralizationSetup
38
- include Tests::Backend::Api::Lambda
39
- end
40
-
41
- class I18nPluralizationBackendApiTranslateLinkedTest < Test::Unit::TestCase
42
- include Tests::Backend::Simple::Setup::Base
43
- include PluralizationSetup
44
- include Tests::Backend::Api::Link
45
- end
46
-
47
- class I18nPluralizationBackendApiPluralizeTest < Test::Unit::TestCase
48
- include Tests::Backend::Simple::Setup::Base
49
- include Tests::Backend::Simple::Setup::Localization
50
- include PluralizationSetup
51
- include Tests::Backend::Api::Pluralization
52
- end
53
-
54
- class I18nPluralizationBackendApiLocalizeDateTest < Test::Unit::TestCase
55
- include Tests::Backend::Simple::Setup::Base
56
- include Tests::Backend::Simple::Setup::Localization
57
- include PluralizationSetup
58
- include Tests::Backend::Api::Localization::Date
59
- end
60
-
61
- class I18nPluralizationBackendApiLocalizeDateTimeTest < Test::Unit::TestCase
62
- include Tests::Backend::Simple::Setup::Base
63
- include Tests::Backend::Simple::Setup::Localization
64
- include PluralizationSetup
65
- include Tests::Backend::Api::Localization::DateTime
66
- end
67
-
68
- class I18nPluralizationBackendApiLocalizeTimeTest < Test::Unit::TestCase
69
- include Tests::Backend::Simple::Setup::Base
70
- include Tests::Backend::Simple::Setup::Localization
71
- include PluralizationSetup
72
- include Tests::Backend::Api::Localization::Time
73
- end
74
-
75
- class I18nPluralizationBackendApiLocalizeLambdaTest < Test::Unit::TestCase
76
- include Tests::Backend::Simple::Setup::Base
77
- include Tests::Backend::Simple::Setup::Localization
78
- include PluralizationSetup
79
- include Tests::Backend::Api::Localization::Lambda
80
- end
81
-
@@ -1,39 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
4
- require 'i18n/backend/pluralization'
5
-
6
- class I18nPluralizationBackendTest < Test::Unit::TestCase
7
- def setup
8
- I18n.backend = I18n::Backend::Simple.new
9
- I18n.backend.meta_class.send(:include, I18n::Backend::Pluralization)
10
- @pluralizer = lambda { |n| n == 1 ? :one : n == 0 || (2..10).include?(n % 100) ? :few : (11..19).include?(n % 100) ? :many : :other }
11
- backend_store_translations(:foo, :i18n => { :pluralize => @pluralizer })
12
- @entry = { :zero => 'zero', :one => 'one', :few => 'few', :many => 'many', :other => 'other' }
13
- end
14
-
15
- define_method :"test: pluralization picks a pluralizer from :'i18n.pluralize'" do
16
- assert_equal @pluralizer, I18n.backend.send(:pluralizer, :foo)
17
- end
18
-
19
- define_method :"test: pluralization picks :one for 1" do
20
- assert_equal 'one', I18n.t(:count => 1, :default => @entry, :locale => :foo)
21
- end
22
-
23
- define_method :"test: pluralization picks :few for 2" do
24
- assert_equal 'few', I18n.t(:count => 2, :default => @entry, :locale => :foo)
25
- end
26
-
27
- define_method :"test: pluralization picks :many for 11" do
28
- assert_equal 'many', I18n.t(:count => 11, :default => @entry, :locale => :foo)
29
- end
30
-
31
- define_method :"test: pluralization picks zero for 0 if the key is contained in the data" do
32
- assert_equal 'zero', I18n.t(:count => 0, :default => @entry, :locale => :foo)
33
- end
34
-
35
- define_method :"test: pluralization picks few for 0 if the key is not contained in the data" do
36
- @entry.delete(:zero)
37
- assert_equal 'few', I18n.t(:count => 0, :default => @entry, :locale => :foo)
38
- end
39
- end
@@ -1,5 +0,0 @@
1
- # encoding: utf-8
2
-
3
- Dir[File.dirname(__FILE__) + '/*_test.rb'].each do |file|
4
- require file
5
- end
@@ -1,90 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
4
-
5
- class I18nSimpleBackendApiBasicsTest < Test::Unit::TestCase
6
- include Tests::Backend::Simple::Setup::Base
7
- include Tests::Backend::Api::Basics
8
-
9
- def test_uses_simple_backend
10
- assert_equal I18n::Backend::Simple, I18n.backend.class
11
- end
12
- end
13
-
14
- class I18nSimpleBackendApiTranslateTest < Test::Unit::TestCase
15
- include Tests::Backend::Simple::Setup::Base
16
- include Tests::Backend::Api::Translation
17
-
18
- # implementation specific tests
19
-
20
- def test_translate_calls_lookup_with_locale_given
21
- I18n.backend.expects(:lookup).with('de', :bar, [:foo], nil).returns 'bar'
22
- I18n.backend.translate 'de', :bar, :scope => [:foo]
23
- end
24
-
25
- def test_translate_calls_pluralize
26
- I18n.backend.expects(:pluralize).with 'en', 'bar', 1
27
- I18n.backend.translate 'en', :bar, :scope => [:foo], :count => 1
28
- end
29
-
30
- def test_translate_calls_interpolate
31
- I18n.backend.expects(:interpolate).with 'en', 'bar', {}
32
- I18n.backend.translate 'en', :bar, :scope => [:foo]
33
- end
34
-
35
- def test_translate_calls_interpolate_including_count_as_a_value
36
- I18n.backend.expects(:interpolate).with 'en', 'bar', {:count => 1}
37
- I18n.backend.translate 'en', :bar, :scope => [:foo], :count => 1
38
- end
39
- end
40
-
41
- class I18nSimpleBackendApiInterpolateTest < Test::Unit::TestCase
42
- include Tests::Backend::Simple::Setup::Base
43
- include Tests::Backend::Api::Interpolation
44
-
45
- # implementation specific tests
46
-
47
- def test_interpolate_given_nil_as_a_string_returns_nil
48
- assert_nil I18n.backend.send(:interpolate, nil, nil, :name => 'David')
49
- end
50
-
51
- def test_interpolate_given_an_non_string_as_a_string_returns_nil
52
- assert_equal [], I18n.backend.send(:interpolate, nil, [], :name => 'David')
53
- end
54
- end
55
-
56
- class I18nSimpleBackendApiLambdaTest < Test::Unit::TestCase
57
- include Tests::Backend::Simple::Setup::Base
58
- include Tests::Backend::Api::Lambda
59
- end
60
-
61
- class I18nSimpleBackendApiTranslateLinkedTest < Test::Unit::TestCase
62
- include Tests::Backend::Simple::Setup::Base
63
- include Tests::Backend::Api::Link
64
- end
65
-
66
- class I18nSimpleBackendApiPluralizationTest < Test::Unit::TestCase
67
- include Tests::Backend::Simple::Setup::Base
68
- include Tests::Backend::Api::Pluralization
69
- end
70
-
71
- class I18nSimpleBackendApiLocalizeDateTest < Test::Unit::TestCase
72
- include Tests::Backend::Simple::Setup::Localization
73
- include Tests::Backend::Api::Localization::Date
74
- end
75
-
76
- class I18nSimpleBackendApiLocalizeDateTimeTest < Test::Unit::TestCase
77
- include Tests::Backend::Simple::Setup::Localization
78
- include Tests::Backend::Api::Localization::DateTime
79
- end
80
-
81
- class I18nSimpleBackendApiLocalizeTimeTest < Test::Unit::TestCase
82
- include Tests::Backend::Simple::Setup::Localization
83
- include Tests::Backend::Api::Localization::Time
84
- end
85
-
86
- class I18nSimpleBackendApiLocalizeLambdaTest < Test::Unit::TestCase
87
- include Tests::Backend::Simple::Setup::Localization
88
- include Tests::Backend::Api::Localization::Lambda
89
- end
90
-
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
4
-
5
- class I18nSimpleBackendLookupTest < Test::Unit::TestCase
6
- include Tests::Backend::Simple::Setup::Base
7
-
8
- # useful because this way we can use the backend with no key for interpolation/pluralization
9
- def test_lookup_given_nil_as_a_key_returns_nil
10
- assert_nil I18n.backend.send(:lookup, :en, nil)
11
- end
12
-
13
- def test_lookup_given_nested_keys_looks_up_a_nested_hash_value
14
- assert_equal 'bar', I18n.backend.send(:lookup, :en, :bar, [:foo])
15
- end
16
-
17
- def test_lookup_using_a_custom_separator
18
- assert_equal 'bar', I18n.backend.send(:lookup, :en, 'foo|bar', [], '|')
19
- end
20
-
21
- def test_default_using_a_custom_separator
22
- assert_equal 'bar', I18n.backend.send(:default, :en, :'does_not_exist', :'foo|bar', :separator => '|')
23
- end
24
- end
@@ -1,147 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Tests
4
- module Backend
5
- module Simple
6
- module Setup
7
- module Base
8
- def setup
9
- super
10
- I18n.locale = nil
11
- I18n.default_locale = :en
12
- I18n.backend = I18n::Backend::Simple.new
13
- backend_store_translations :en, :foo => {:bar => 'bar', :baz => 'baz'}
14
- end
15
-
16
- def teardown
17
- super
18
- I18n.load_path = []
19
- I18n.backend = nil
20
- end
21
- end
22
-
23
- module Localization
24
- include Base
25
-
26
- def setup
27
- super
28
- setup_datetime_translations
29
- setup_datetime_lambda_translations
30
- @old_timezone, ENV['TZ'] = ENV['TZ'], 'UTC'
31
- end
32
-
33
- def teardown
34
- super
35
- @old_timezone ? ENV['TZ'] = @old_timezone : ENV.delete('TZ')
36
- end
37
-
38
- def setup_datetime_translations
39
- backend_store_translations :de, {
40
- :date => {
41
- :formats => {
42
- :default => "%d.%m.%Y",
43
- :short => "%d. %b",
44
- :long => "%d. %B %Y",
45
- :long_ordinalized => lambda { |date, options|
46
- tz = " (#{options[:timezone]})" if options[:timezone]
47
- "#{date.day}ter %B %Y#{tz}"
48
- }
49
- },
50
- :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
51
- :abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
52
- :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
53
- :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil),
54
- :order => [:day, :month, :year]
55
- },
56
- :time => {
57
- :formats => {
58
- :default => "%a, %d. %b %Y %H:%M:%S %z",
59
- :short => "%d. %b %H:%M",
60
- :long => "%d. %B %Y %H:%M",
61
- :long_ordinalized => lambda { |date, options|
62
- tz = " (#{options[:timezone]})" if options[:timezone]
63
- "#{date.day}ter %B %Y, %H:%M Uhr#{tz}"
64
- }
65
- },
66
- :am => 'am',
67
- :pm => 'pm'
68
- },
69
- :datetime => {
70
- :distance_in_words => {
71
- :half_a_minute => 'half a minute',
72
- :less_than_x_seconds => {
73
- :one => 'less than 1 second',
74
- :other => 'less than {{count}} seconds'
75
- },
76
- :x_seconds => {
77
- :one => '1 second',
78
- :other => '{{count}} seconds'
79
- },
80
- :less_than_x_minutes => {
81
- :one => 'less than a minute',
82
- :other => 'less than {{count}} minutes'
83
- },
84
- :x_minutes => {
85
- :one => '1 minute',
86
- :other => '{{count}} minutes'
87
- },
88
- :about_x_hours => {
89
- :one => 'about 1 hour',
90
- :other => 'about {{count}} hours'
91
- },
92
- :x_days => {
93
- :one => '1 day',
94
- :other => '{{count}} days'
95
- },
96
- :about_x_months => {
97
- :one => 'about 1 month',
98
- :other => 'about {{count}} months'
99
- },
100
- :x_months => {
101
- :one => '1 month',
102
- :other => '{{count}} months'
103
- },
104
- :about_x_years => {
105
- :one => 'about 1 year',
106
- :other => 'about {{count}} year'
107
- },
108
- :over_x_years => {
109
- :one => 'over 1 year',
110
- :other => 'over {{count}} years'
111
- }
112
- }
113
- }
114
- }
115
- end
116
-
117
- def setup_datetime_lambda_translations
118
- backend_store_translations 'ru', {
119
- :date => {
120
- :'day_names' => lambda { |key, options|
121
- (options[:format] =~ /^%A/) ?
122
- %w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
123
- %w(воскресенье понедельник вторник среда четверг пятница суббота)
124
- },
125
- :'abbr_day_names' => %w(Вс Пн Вт Ср Чт Пт Сб),
126
- :'month_names' => lambda { |key, options|
127
- (options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
128
- %w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
129
- %w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
130
- },
131
- :'abbr_month_names' => lambda { |key, options|
132
- (options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
133
- %w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
134
- %w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
135
- },
136
- },
137
- :time => {
138
- :am => "утра",
139
- :pm => "вечера"
140
- }
141
- }
142
- end
143
- end
144
- end
145
- end
146
- end
147
- end
@@ -1,89 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
4
-
5
- class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase
6
- include Tests::Backend::Simple::Setup::Base
7
-
8
- def test_load_translations_with_unknown_file_type_raises_exception
9
- assert_raises(I18n::UnknownFileType) { I18n.backend.load_translations "#{locales_dir}/en.xml" }
10
- end
11
-
12
- def test_load_translations_with_ruby_file_type_does_not_raise_exception
13
- assert_nothing_raised { I18n.backend.load_translations "#{locales_dir}/en.rb" }
14
- end
15
-
16
- def test_load_rb_loads_data_from_ruby_file
17
- data = I18n.backend.send :load_rb, "#{locales_dir}/en.rb"
18
- assert_equal({ :en => { :fuh => { :bah => 'bas' } } }, data)
19
- end
20
-
21
- def test_load_rb_loads_data_from_yaml_file
22
- data = I18n.backend.send :load_yml, "#{locales_dir}/en.yml"
23
- assert_equal({ 'en' => { 'foo' => { 'bar' => 'baz' } } }, data)
24
- end
25
-
26
- def test_load_translations_loads_from_different_file_formats
27
- I18n.backend = I18n::Backend::Simple.new
28
- I18n.backend.load_translations "#{locales_dir}/en.rb", "#{locales_dir}/en.yml"
29
- expected = { :en => { :fuh => { :bah => "bas" }, :foo => { :bar => "baz" } } }
30
- assert_equal expected, backend_get_translations
31
- end
32
- end
33
-
34
- class I18nSimpleBackendStoreTranslationsTest < Test::Unit::TestCase
35
- include Tests::Backend::Simple::Setup::Base
36
-
37
- def test_store_translations_adds_translations # no, really :-)
38
- I18n.backend.store_translations :'en', :foo => 'bar'
39
- assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
40
- end
41
-
42
- def test_store_translations_deep_merges_translations
43
- I18n.backend.store_translations :'en', :foo => {:bar => 'bar'}
44
- I18n.backend.store_translations :'en', :foo => {:baz => 'baz'}
45
- assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
46
- end
47
-
48
- def test_store_translations_forces_locale_to_sym
49
- I18n.backend.store_translations 'en', :foo => 'bar'
50
- assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
51
- end
52
-
53
- def test_store_translations_converts_keys_to_symbols
54
- # backend_reset_translations!
55
- I18n.backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
56
- assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
57
- end
58
-
59
- def test_deep_symbolize_keys_works
60
- result = I18n.backend.send :deep_symbolize_keys, 'foo' => {'bar' => {'baz' => 'bar'}}
61
- expected = {:foo => {:bar => {:baz => 'bar'}}}
62
- assert_equal expected, result
63
- end
64
- end
65
-
66
- class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
67
- include Tests::Backend::Simple::Setup::Base
68
-
69
- def setup
70
- I18n.backend = I18n::Backend::Simple.new
71
- I18n.load_path = [locales_dir + '/en.yml']
72
- assert_nil backend_get_translations
73
- I18n.backend.send :init_translations
74
- end
75
-
76
- def test_setup
77
- assert_not_nil backend_get_translations
78
- end
79
-
80
- def test_reload_translations_unloads_translations
81
- I18n.backend.reload!
82
- assert_nil backend_get_translations
83
- end
84
-
85
- def test_reload_translations_uninitializes_translations
86
- I18n.backend.reload!
87
- assert_equal I18n.backend.initialized?, false
88
- end
89
- end