polish 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +25 -0
  3. data/Rakefile +56 -0
  4. data/TODO +5 -0
  5. data/init.rb +1 -0
  6. data/lib/polish.rb +104 -0
  7. data/lib/polish/action_view_ext/helpers/date_helper.rb +94 -0
  8. data/lib/polish/backend/advanced.rb +105 -0
  9. data/lib/polish/locale/actionview.yml +81 -0
  10. data/lib/polish/locale/activerecord.yml +27 -0
  11. data/lib/polish/locale/activesupport.yml +11 -0
  12. data/lib/polish/locale/datetime.yml +25 -0
  13. data/lib/polish/locale/pluralize.rb +16 -0
  14. data/lib/vendor/i18n/CHANGELOG.textile +57 -0
  15. data/lib/vendor/i18n/MIT-LICENSE +20 -0
  16. data/lib/vendor/i18n/README.textile +42 -0
  17. data/lib/vendor/i18n/Rakefile +21 -0
  18. data/lib/vendor/i18n/VERSION +1 -0
  19. data/lib/vendor/i18n/i18n.gemspec +141 -0
  20. data/lib/vendor/i18n/lib/i18n.rb +270 -0
  21. data/lib/vendor/i18n/lib/i18n/backend/base.rb +251 -0
  22. data/lib/vendor/i18n/lib/i18n/backend/cache.rb +71 -0
  23. data/lib/vendor/i18n/lib/i18n/backend/chain.rb +64 -0
  24. data/lib/vendor/i18n/lib/i18n/backend/fallbacks.rb +53 -0
  25. data/lib/vendor/i18n/lib/i18n/backend/gettext.rb +65 -0
  26. data/lib/vendor/i18n/lib/i18n/backend/pluralization.rb +56 -0
  27. data/lib/vendor/i18n/lib/i18n/backend/simple.rb +23 -0
  28. data/lib/vendor/i18n/lib/i18n/exceptions.rb +61 -0
  29. data/lib/vendor/i18n/lib/i18n/gettext.rb +25 -0
  30. data/lib/vendor/i18n/lib/i18n/helpers/gettext.rb +35 -0
  31. data/lib/vendor/i18n/lib/i18n/locale/fallbacks.rb +100 -0
  32. data/lib/vendor/i18n/lib/i18n/locale/tag.rb +27 -0
  33. data/lib/vendor/i18n/lib/i18n/locale/tag/parents.rb +24 -0
  34. data/lib/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb +78 -0
  35. data/lib/vendor/i18n/lib/i18n/locale/tag/simple.rb +44 -0
  36. data/lib/vendor/i18n/lib/i18n/string.rb +95 -0
  37. data/lib/vendor/i18n/test/all.rb +5 -0
  38. data/lib/vendor/i18n/test/api/basics.rb +15 -0
  39. data/lib/vendor/i18n/test/api/interpolation.rb +85 -0
  40. data/lib/vendor/i18n/test/api/lambda.rb +52 -0
  41. data/lib/vendor/i18n/test/api/link.rb +47 -0
  42. data/lib/vendor/i18n/test/api/localization/date.rb +65 -0
  43. data/lib/vendor/i18n/test/api/localization/date_time.rb +63 -0
  44. data/lib/vendor/i18n/test/api/localization/lambda.rb +26 -0
  45. data/lib/vendor/i18n/test/api/localization/time.rb +63 -0
  46. data/lib/vendor/i18n/test/api/pluralization.rb +37 -0
  47. data/lib/vendor/i18n/test/api/translation.rb +51 -0
  48. data/lib/vendor/i18n/test/backend/cache/cache_test.rb +57 -0
  49. data/lib/vendor/i18n/test/backend/chain/api_test.rb +80 -0
  50. data/lib/vendor/i18n/test/backend/chain/chain_test.rb +64 -0
  51. data/lib/vendor/i18n/test/backend/fallbacks/api_test.rb +79 -0
  52. data/lib/vendor/i18n/test/backend/fallbacks/fallbacks_test.rb +29 -0
  53. data/lib/vendor/i18n/test/backend/pluralization/api_test.rb +81 -0
  54. data/lib/vendor/i18n/test/backend/pluralization/pluralization_test.rb +39 -0
  55. data/lib/vendor/i18n/test/backend/simple/all.rb +5 -0
  56. data/lib/vendor/i18n/test/backend/simple/api_test.rb +90 -0
  57. data/lib/vendor/i18n/test/backend/simple/lookup_test.rb +24 -0
  58. data/lib/vendor/i18n/test/backend/simple/setup.rb +147 -0
  59. data/lib/vendor/i18n/test/backend/simple/translations_test.rb +89 -0
  60. data/lib/vendor/i18n/test/fixtures/locales/de.po +61 -0
  61. data/lib/vendor/i18n/test/fixtures/locales/en.rb +3 -0
  62. data/lib/vendor/i18n/test/fixtures/locales/en.yml +3 -0
  63. data/lib/vendor/i18n/test/fixtures/locales/plurals.rb +112 -0
  64. data/lib/vendor/i18n/test/gettext/api_test.rb +78 -0
  65. data/lib/vendor/i18n/test/gettext/backend_test.rb +35 -0
  66. data/lib/vendor/i18n/test/i18n_exceptions_test.rb +97 -0
  67. data/lib/vendor/i18n/test/i18n_load_path_test.rb +23 -0
  68. data/lib/vendor/i18n/test/i18n_test.rb +163 -0
  69. data/lib/vendor/i18n/test/locale/fallbacks_test.rb +128 -0
  70. data/lib/vendor/i18n/test/locale/tag/rfc4646_test.rb +147 -0
  71. data/lib/vendor/i18n/test/locale/tag/simple_test.rb +35 -0
  72. data/lib/vendor/i18n/test/string_test.rb +94 -0
  73. data/lib/vendor/i18n/test/test_helper.rb +71 -0
  74. data/lib/vendor/i18n/test/with_options.rb +34 -0
  75. data/lib/vendor/i18n/vendor/po_parser.rb +329 -0
  76. data/spec/fixtures/en.yml +4 -0
  77. data/spec/fixtures/pl.yml +4 -0
  78. data/spec/i18n/locale/datetime_spec.rb +91 -0
  79. data/spec/i18n/locale/pluralization_spec.rb +41 -0
  80. data/spec/locale_spec.rb +124 -0
  81. data/spec/polish_spec.rb +141 -0
  82. data/spec/spec_helper.rb +4 -0
  83. metadata +138 -0
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+
3
+ =begin
4
+ heavily based on Masao Mutoh's gettext String interpolation extension
5
+ http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
6
+ Copyright (C) 2005-2009 Masao Mutoh
7
+ You may redistribute it and/or modify it under the same license terms as Ruby.
8
+ =end
9
+
10
+ if RUBY_VERSION < '1.9'
11
+
12
+ # KeyError is raised by String#% when the string contains a named placeholder
13
+ # that is not contained in the given arguments hash. Ruby 1.9 includes and
14
+ # raises this exception natively. We define it to mimic Ruby 1.9's behaviour
15
+ # in Ruby 1.8.x
16
+
17
+ class KeyError < IndexError
18
+ def initialize(message = nil)
19
+ super(message || "key not found")
20
+ end
21
+ end unless defined?(KeyError)
22
+
23
+ # Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
24
+ #
25
+ # String#% method which accept "named argument". The translator can know
26
+ # the meaning of the msgids using "named argument" instead of %s/%d style.
27
+
28
+ class String
29
+ # For older ruby versions, such as ruby-1.8.5
30
+ alias :bytesize :size unless instance_methods.find {|m| m.to_s == 'bytesize'}
31
+ alias :interpolate_without_ruby_19_syntax :% # :nodoc:
32
+
33
+ INTERPOLATION_PATTERN = Regexp.union(
34
+ /%%/,
35
+ /%\{(\w+)\}/, # matches placeholders like "%{foo}"
36
+ /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
37
+ )
38
+
39
+ # % uses self (i.e. the String) as a format specification and returns the
40
+ # result of applying it to the given arguments. In other words it interpolates
41
+ # the given arguments to the string according to the formats the string
42
+ # defines.
43
+ #
44
+ # There are three ways to use it:
45
+ #
46
+ # * Using a single argument or Array of arguments.
47
+ #
48
+ # This is the default behaviour of the String class. See Kernel#sprintf for
49
+ # more details about the format string.
50
+ #
51
+ # Example:
52
+ #
53
+ # "%d %s" % [1, "message"]
54
+ # # => "1 message"
55
+ #
56
+ # * Using a Hash as an argument and unformatted, named placeholders.
57
+ #
58
+ # When you pass a Hash as an argument and specify placeholders with %{foo}
59
+ # it will interpret the hash values as named arguments.
60
+ #
61
+ # Example:
62
+ #
63
+ # "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"}
64
+ # # => "Masao Mutoh"
65
+ #
66
+ # * Using a Hash as an argument and formatted, named placeholders.
67
+ #
68
+ # When you pass a Hash as an argument and specify placeholders with %<foo>d
69
+ # it will interpret the hash values as named arguments and format the value
70
+ # according to the formatting instruction appended to the closing >.
71
+ #
72
+ # Example:
73
+ #
74
+ # "%<integer>d, %<float>.1f" % { :integer => 10, :float => 43.4 }
75
+ # # => "10, 43.3"
76
+ def %(args)
77
+ if args.kind_of?(Hash)
78
+ dup.gsub(INTERPOLATION_PATTERN) do |match|
79
+ if match == '%%'
80
+ '%'
81
+ else
82
+ key = ($1 || $2).to_sym
83
+ raise KeyError unless args.has_key?(key)
84
+ $3 ? sprintf("%#{$3}", args[key]) : args[key]
85
+ end
86
+ end
87
+ elsif self =~ INTERPOLATION_PATTERN
88
+ raise ArgumentError.new('one hash required')
89
+ else
90
+ result = gsub(/%([{<])/, '%%\1')
91
+ result.send :'interpolate_without_ruby_19_syntax', args
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ Dir[File.dirname(__FILE__) + '/**/*_test.rb'].sort.each do |file|
4
+ require file
5
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Basics
7
+ def test_available_locales
8
+ backend_store_translations 'de', :foo => 'bar'
9
+ backend_store_translations 'en', :foo => 'foo'
10
+ assert_equal ['de', 'en'], I18n.backend.available_locales.map{|locale| locale.to_s }.sort
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Interpolation
7
+ def interpolate(options)
8
+ I18n.backend.translate('en', nil, options)
9
+ end
10
+
11
+ def test_interpolation_given_no_interpolation_values_it_does_not_alter_the_string
12
+ assert_equal 'Hi {{name}}!', interpolate(:default => 'Hi {{name}}!')
13
+ end
14
+
15
+ def test_interpolation_given_interpolation_values_it_interpolates_the_values_to_the_string
16
+ assert_equal 'Hi David!', interpolate(:default => 'Hi {{name}}!', :name => 'David')
17
+ end
18
+
19
+ def test_interpolation_given_interpolation_values_with_nil_values_it_interpolates_the_values_to_the_string
20
+ assert_equal 'Hi !', interpolate(:default => 'Hi {{name}}!', :name => nil)
21
+ end
22
+
23
+ def test_interpolation_given_a_lambda_as_a_value_it_calls_it_when_the_string_contains_the_key
24
+ assert_equal 'Hi David!', interpolate(:default => 'Hi {{name}}!', :name => lambda { 'David' })
25
+ end
26
+
27
+ def test_interpolation_given_a_lambda_as_a_value_it_does_not_call_it_when_the_string_does_not_contain_the_key
28
+ assert_nothing_raised { interpolate(:default => 'Hi!', :name => lambda { raise 'fail' }) }
29
+ end
30
+
31
+ def test_interpolation_given_interpolation_values_but_missing_a_key_it_raises_a_missing_interpolation_argument_exception
32
+ assert_raises(I18n::MissingInterpolationArgument) do
33
+ interpolate(:default => '{{foo}}', :bar => 'bar')
34
+ end
35
+ end
36
+
37
+ def test_interpolation_does_not_raise_missing_interpolation_argument_exceptions_for_escaped_variables
38
+ assert_nothing_raised(I18n::MissingInterpolationArgument) do
39
+ assert_equal 'Barr {{foo}}', interpolate(:default => '{{bar}} \{{foo}}', :bar => 'Barr')
40
+ end
41
+ end
42
+
43
+ def test_interpolate_with_ruby_1_9_syntax
44
+ assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David')
45
+ end
46
+
47
+ def test_interpolate_given_a_value_hash_interpolates_into_unicode_string
48
+ assert_equal 'Häi David!', interpolate(:default => 'Häi {{name}}!', :name => 'David')
49
+ end
50
+
51
+ def test_interpolate_given_a_unicode_value_hash_interpolates_to_the_string
52
+ assert_equal 'Hi ゆきひろ!', interpolate(:default => 'Hi {{name}}!', :name => 'ゆきひろ')
53
+ end
54
+
55
+ def test_interpolate_given_a_unicode_value_hash_interpolates_into_unicode_string
56
+ assert_equal 'こんにちは、ゆきひろさん!', interpolate(:default => 'こんにちは、{{name}}さん!', :name => 'ゆきひろ')
57
+ end
58
+
59
+ if Kernel.const_defined?(:Encoding)
60
+ def test_interpolate_given_a_non_unicode_multibyte_value_hash_interpolates_into_a_string_with_the_same_encoding
61
+ assert_equal euc_jp('Hi ゆきひろ!'), interpolate(:default => 'Hi {{name}}!', :name => euc_jp('ゆきひろ'))
62
+ end
63
+
64
+ def test_interpolate_given_a_unicode_value_hash_into_a_non_unicode_multibyte_string_raises_encoding_compatibility_error
65
+ assert_raises(Encoding::CompatibilityError) do
66
+ interpolate(:default => euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ')
67
+ end
68
+ end
69
+
70
+ def test_interpolate_given_a_non_unicode_multibyte_value_hash_into_an_unicode_string_raises_encoding_compatibility_error
71
+ assert_raises(Encoding::CompatibilityError) do
72
+ interpolate(:default => 'こんにちは、{{name}}さん!', :name => euc_jp('ゆきひろ'))
73
+ end
74
+ end
75
+ end
76
+
77
+ def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key
78
+ assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '{{default}}', :foo => :bar) }
79
+ assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '{{scope}}', :foo => :bar) }
80
+ assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '{{separator}}', :foo => :bar) }
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Lambda
7
+ def test_translate_simple_proc
8
+ setup_proc_translations
9
+ assert_equal 'bar=bar, baz=baz, foo=foo', I18n.backend.translate('en', :a_lambda, :foo => 'foo', :bar => 'bar', :baz => 'baz')
10
+ end
11
+
12
+ def test_translate_proc_in_defaults
13
+ setup_proc_translations
14
+ assert_equal 'bar=bar, baz=baz, foo=foo', I18n.backend.translate('en', :does_not_exist, :default => :a_lambda, :foo => 'foo', :bar => 'bar', :baz => 'baz')
15
+ assert_equal 'bar=bar, baz=baz, foo=foo', I18n.backend.translate('en', :does_not_exist, :default => [:does_not_exist_2, :does_not_exist_3, :a_lambda], :foo => 'foo', :bar => 'bar', :baz => 'baz')
16
+ end
17
+
18
+ def test_translate_proc_with_pluralize
19
+ setup_proc_translations
20
+ params = { :zero => 'zero', :one => 'one', :other => 'other' }
21
+ assert_equal 'zero', I18n.backend.translate('en', :lambda_for_pluralize, params.merge(:count => 0))
22
+ assert_equal 'one', I18n.backend.translate('en', :lambda_for_pluralize, params.merge(:count => 1))
23
+ assert_equal 'other', I18n.backend.translate('en', :lambda_for_pluralize, params.merge(:count => 2))
24
+ end
25
+
26
+ def test_translate_proc_with_interpolate
27
+ setup_proc_translations
28
+ assert_equal 'bar baz foo', I18n.backend.translate('en', :lambda_for_interpolate, :foo => 'foo', :bar => 'bar', :baz => 'baz')
29
+ end
30
+
31
+ def test_translate_with_proc_as_default
32
+ expected = 'result from lambda'
33
+ assert_equal expected, I18n.backend.translate(:en, :'does not exist', :default => lambda { |key, values| expected })
34
+ end
35
+
36
+ private
37
+
38
+ def setup_proc_translations
39
+ I18n.backend.store_translations 'en', {
40
+ :a_lambda => lambda { |key, values|
41
+ values.keys.sort_by(&:to_s).collect { |key| "#{key}=#{values[key]}"}.join(', ')
42
+ },
43
+ :lambda_for_pluralize => lambda { |key, values| values },
44
+ :lambda_for_interpolate => lambda { |key, values|
45
+ "{{#{values.keys.sort_by(&:to_s).join('}} {{')}}}"
46
+ }
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Link
7
+ def test_translate_calls_translate_if_resolves_to_a_symbol
8
+ setup_linked_translations
9
+ assert_equal 'foo', I18n.backend.translate('en', :link_to_foo)
10
+ end
11
+
12
+ def test_translate_calls_translate_if_resolves_to_a_symbol2
13
+ setup_linked_translations
14
+ assert_equal('baz', I18n.backend.translate('en', :link_to_baz))
15
+ end
16
+
17
+ def test_translate_calls_translate_if_resolves_to_a_symbol3
18
+ setup_linked_translations
19
+ assert I18n.backend.translate('en', :link_to_bar).key?(:baz)
20
+ end
21
+
22
+ def test_translate_calls_translate_if_resolves_to_a_symbol_with_scope_1
23
+ setup_linked_translations
24
+ assert_equal('baz', I18n.backend.translate('en', :link_to_baz, :scope => :bar))
25
+ end
26
+
27
+ def test_translate_calls_translate_if_resolves_to_a_symbol_with_scope_1
28
+ setup_linked_translations
29
+ assert_equal('buz', I18n.backend.translate('en', :'bar.link_to_buz'))
30
+ end
31
+
32
+ private
33
+
34
+ def setup_linked_translations
35
+ I18n.backend.store_translations 'en', {
36
+ :foo => 'foo',
37
+ :bar => { :baz => 'baz', :link_to_baz => :baz, :link_to_buz => :'boz.buz' },
38
+ :boz => { :buz => 'buz' },
39
+ :link_to_foo => :foo,
40
+ :link_to_bar => :bar,
41
+ :link_to_baz => :'bar.baz'
42
+ }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Localization
7
+ module Date
8
+ # TODO should be Mrz, shouldn't it?
9
+ def test_localize_given_the_short_format_it_uses_it
10
+ assert_equal '01. Mar', I18n.backend.localize('de', date, :short)
11
+ end
12
+
13
+ def test_localize_given_the_long_format_it_uses_it
14
+ assert_equal '01. März 2008', I18n.backend.localize('de', date, :long)
15
+ end
16
+
17
+ def test_localize_given_the_default_format_it_uses_it
18
+ assert_equal '01.03.2008', I18n.backend.localize('de', date, :default)
19
+ end
20
+
21
+ def test_localize_given_a_day_name_format_it_returns_a_day_name
22
+ assert_equal 'Samstag', I18n.backend.localize('de', date, '%A')
23
+ end
24
+
25
+ def test_localize_given_an_abbr_day_name_format_it_returns_an_abbrevated_day_name
26
+ assert_equal 'Sa', I18n.backend.localize('de', date, '%a')
27
+ end
28
+
29
+ def test_localize_given_a_month_name_format_it_returns_a_month_name
30
+ assert_equal 'März', I18n.backend.localize('de', date, '%B')
31
+ end
32
+
33
+ # TODO should be Mrz, shouldn't it?
34
+ def test_localize_given_an_abbr_month_name_format_it_returns_an_abbrevated_month_name
35
+ assert_equal 'Mar', I18n.backend.localize('de', date, '%b')
36
+ end
37
+
38
+ def test_localize_given_a_format_specified_as_a_proc
39
+ assert_equal '1ter März 2008', I18n.backend.localize('de', date, :long_ordinalized)
40
+ end
41
+
42
+ def test_localize_given_a_format_specified_as_a_proc_with_additional_options
43
+ assert_equal '1ter März 2008 (MEZ)', I18n.backend.localize('de', date, :long_ordinalized, :timezone => 'MEZ')
44
+ end
45
+
46
+ def test_localize_given_no_format_it_does_not_fail
47
+ assert_nothing_raised{ I18n.backend.localize 'de', date }
48
+ end
49
+
50
+ def test_localize_given_an_unknown_format_it_does_not_fail
51
+ assert_nothing_raised{ I18n.backend.localize 'de', date, '%x' }
52
+ end
53
+
54
+ def test_localize_nil_raises_argument_error
55
+ assert_raises(I18n::ArgumentError) { I18n.backend.localize 'de', nil }
56
+ end
57
+
58
+ def test_localize_object_raises_argument_error
59
+ assert_raises(I18n::ArgumentError) { I18n.backend.localize 'de', Object.new }
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Localization
7
+ module DateTime
8
+ # TODO should be Mrz, shouldn't it?
9
+ def test_localize_given_the_short_format_it_uses_it
10
+ assert_equal '01. Mar 06:00', I18n.backend.localize('de', morning_datetime, :short)
11
+ end
12
+
13
+ def test_localize_given_the_long_format_it_uses_it
14
+ assert_equal '01. März 2008 06:00', I18n.backend.localize('de', morning_datetime, :long)
15
+ end
16
+
17
+ # TODO should be Mrz, shouldn't it?
18
+ def test_localize_given_the_default_format_it_uses_it
19
+ assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.backend.localize('de', morning_datetime, :default)
20
+ end
21
+
22
+ def test_localize_given_a_day_name_format_it_returns_the_correct_day_name
23
+ assert_equal 'Samstag', I18n.backend.localize('de', morning_datetime, '%A')
24
+ end
25
+
26
+ def test_localize_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
27
+ assert_equal 'Sa', I18n.backend.localize('de', morning_datetime, '%a')
28
+ end
29
+
30
+ def test_localize_given_a_month_name_format_it_returns_the_correct_month_name
31
+ assert_equal 'März', I18n.backend.localize('de', morning_datetime, '%B')
32
+ end
33
+
34
+ # TODO should be Mrz, shouldn't it?
35
+ def test_localize_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
36
+ assert_equal 'Mar', I18n.backend.localize('de', morning_datetime, '%b')
37
+ end
38
+
39
+ def test_localize_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
40
+ assert_equal 'am', I18n.backend.localize('de', morning_datetime, '%p')
41
+ assert_equal 'pm', I18n.backend.localize('de', evening_datetime, '%p')
42
+ end
43
+
44
+ def test_localize_given_a_format_specified_as_a_proc
45
+ assert_equal '1ter März 2008, 06:00 Uhr', I18n.backend.localize('de', morning_datetime, :long_ordinalized)
46
+ end
47
+
48
+ def test_localize_given_a_format_specified_as_a_proc_with_additional_options
49
+ assert_equal '1ter März 2008, 06:00 Uhr (MEZ)', I18n.backend.localize('de', morning_datetime, :long_ordinalized, :timezone => 'MEZ')
50
+ end
51
+
52
+ def test_localize_given_no_format_it_does_not_fail
53
+ assert_nothing_raised{ I18n.backend.localize 'de', morning_datetime }
54
+ end
55
+
56
+ def test_localize_given_an_unknown_format_it_does_not_fail
57
+ assert_nothing_raised{ I18n.backend.localize 'de', morning_datetime, '%x' }
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module Tests
4
+ module Backend
5
+ module Api
6
+ module Localization
7
+ module Lambda
8
+ def test_localize_uses_lambda_day_names
9
+ assert_match /Суббота/, I18n.backend.localize('ru', time, "%A, %d %B")
10
+ assert_match /суббота/, I18n.backend.localize('ru', time, "%d %B (%A)")
11
+ end
12
+
13
+ def test_localize_uses_lambda_month_names
14
+ assert_match /марта/, I18n.backend.localize('ru', time, "%d %B %Y")
15
+ assert_match /Март/, I18n.backend.localize('ru', time, "%B %Y")
16
+ end
17
+
18
+ def test_localize_uses_lambda_abbr_day_names
19
+ assert_match /марта/, I18n.backend.localize('ru', time, "%d %b %Y")
20
+ assert_match /март/, I18n.backend.localize('ru', time, "%b %Y")
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end