russian 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe I18n, "Russian Date/Time localization" do
4
+ before(:each) do
5
+ @date = Date.parse("1985-12-01")
6
+ @time = Time.local(1985, 12, 01, 16, 05)
7
+ end
8
+
9
+ describe "with date formats" do
10
+ it "should use default format" do
11
+ l(@date).should == "01.12.1985"
12
+ end
13
+
14
+ it "should use short format" do
15
+ l(@date, :format => :short).should == "01 дек."
16
+ end
17
+
18
+ it "should use long format" do
19
+ l(@date, :format => :long).should == "01 декабря 1985"
20
+ end
21
+ end
22
+
23
+ describe "with date day names" do
24
+ it "should use day names" do
25
+ l(@date, :format => "%d %B (%A)").should == "01 декабря (воскресенье)"
26
+ l(@date, :format => "%d %B %Y года было %A").should == "01 декабря 1985 года было воскресенье"
27
+ end
28
+
29
+ it "should use standalone day names" do
30
+ l(@date, :format => "%A").should == "Воскресенье"
31
+ l(@date, :format => "%A, %d %B").should == "Воскресенье, 01 декабря"
32
+ end
33
+
34
+ it "should use abbreviated day names" do
35
+ l(@date, :format => "%a").should == "Вс"
36
+ l(@date, :format => "%a, %d %b %Y").should == "Вс, 01 дек. 1985"
37
+ end
38
+ end
39
+
40
+ describe "with month names" do
41
+ it "should use month names" do
42
+ l(@date, :format => "%d %B").should == "01 декабря"
43
+ l(@date, :format => "%e %B %Y").should == " 1 декабря 1985"
44
+ end
45
+
46
+ it "should use standalone month names" do
47
+ l(@date, :format => "%B").should == "Декабрь"
48
+ l(@date, :format => "%B %Y").should == "Декабрь 1985"
49
+ end
50
+
51
+ it "should use abbreviated month names" do
52
+ @date = Date.parse("1985-03-01")
53
+ l(@date, :format => "%d %b").should == "01 марта"
54
+ l(@date, :format => "%e %b %Y").should == " 1 марта 1985"
55
+ end
56
+
57
+ it "should use standalone abbreviated month names" do
58
+ @date = Date.parse("1985-03-01")
59
+ l(@date, :format => "%b").should == "март"
60
+ l(@date, :format => "%b %Y").should == "март 1985"
61
+ end
62
+ end
63
+
64
+ it "should define default date components order: day, month, year" do
65
+ I18n.backend.translate(Russian.locale, :"date.order").should == [:day, :month, :year]
66
+ end
67
+
68
+ describe "with time formats" do
69
+ it "should use default format" do
70
+ l(@time).should =~ /^Вс, 01 дек. 1985, 16:05:00/
71
+ end
72
+
73
+ it "should use short format" do
74
+ l(@time, :format => :short).should == "01 дек., 16:05"
75
+ end
76
+
77
+ it "should use long format" do
78
+ l(@time, :format => :long).should == "01 декабря 1985, 16:05"
79
+ end
80
+
81
+ it "should define am and pm" do
82
+ I18n.backend.translate(Russian.locale, :"time.am").should_not be_nil
83
+ I18n.backend.translate(Russian.locale, :"time.pm").should_not be_nil
84
+ end
85
+ end
86
+
87
+ protected
88
+ def l(object, options = {})
89
+ I18n.l(object, options.merge( { :locale => Russian.locale }))
90
+ end
91
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe I18n, "Russian pluralization" do
4
+ before(:each) do
5
+ @hash = {:one => 'вещь', :few => 'вещи', :many => 'вещей', :other => 'вещи'}
6
+ @backend = I18n.backend
7
+ end
8
+
9
+ it "should pluralize correctly" do
10
+ @backend.send(:pluralize, :'ru-RU', @hash, 1).should == 'вещь'
11
+ @backend.send(:pluralize, :'ru-RU', @hash, 2).should == 'вещи'
12
+ @backend.send(:pluralize, :'ru-RU', @hash, 3).should == 'вещи'
13
+ @backend.send(:pluralize, :'ru-RU', @hash, 5).should == 'вещей'
14
+ @backend.send(:pluralize, :'ru-RU', @hash, 10).should == 'вещей'
15
+ @backend.send(:pluralize, :'ru-RU', @hash, 21).should == 'вещь'
16
+ @backend.send(:pluralize, :'ru-RU', @hash, 29).should == 'вещей'
17
+ @backend.send(:pluralize, :'ru-RU', @hash, 129).should == 'вещей'
18
+ @backend.send(:pluralize, :'ru-RU', @hash, 131).should == 'вещь'
19
+ end
20
+ end
@@ -0,0 +1,141 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Russian, "VERSION" do
4
+ it "should be defined" do
5
+ %w(MAJOR MINOR TINY STRING).each do |v|
6
+ Russian::VERSION.const_defined?(v).should == true
7
+ end
8
+ end
9
+ end
10
+
11
+ describe Russian do
12
+ describe "with locale" do
13
+ it "should define :'ru-RU' LOCALE" do
14
+ Russian::LOCALE.should == :'ru-RU'
15
+ end
16
+
17
+ it "should provide ::locale proxy" do
18
+ Russian.locale.should == Russian::LOCALE
19
+ end
20
+ end
21
+
22
+ describe "with custom backend class" do
23
+ it "should define i18n_backend_class" do
24
+ Russian.i18n_backend_class.should == I18n::Backend::Advanced
25
+ end
26
+ end
27
+
28
+ describe "during i18n initialization" do
29
+ it "should set I18n backend to an instance of a custom backend" do
30
+ Russian.init_i18n
31
+ I18n.backend.class.should == Russian.i18n_backend_class
32
+ end
33
+
34
+ it "should set default locale to Russian locale" do
35
+ Russian.init_i18n
36
+ I18n.default_locale.should == Russian.locale
37
+ end
38
+
39
+ describe "loading locales" do
40
+ before(:all) do
41
+ Russian.init_i18n
42
+ end
43
+
44
+ it "should load datetime translations" do
45
+ lookup(:"date.formats.default").should_not be_nil
46
+ lookup(:"time.formats.default").should_not be_nil
47
+ end
48
+
49
+ it "should load pluralization rules" do
50
+ lookup(:"pluralize").should_not be_nil
51
+ lookup(:"pluralize").is_a?(Proc).should be_true
52
+ end
53
+
54
+ it "should load actionview translations" do
55
+ lookup(:"number.currency.format.format").should_not be_nil
56
+ lookup(:"datetime.distance_in_words.half_a_minute").should_not be_nil
57
+ lookup(:"activerecord.errors.template.header").should_not be_nil
58
+ end
59
+
60
+ it "should load activerecord translations" do
61
+ lookup(:"activerecord.errors.messages.invalid").should_not be_nil
62
+ lookup(:"activerecord.errors.messages.greater_than_or_equal_to").should_not be_nil
63
+ end
64
+
65
+ it "should load activesupport translations" do
66
+ lookup(:"support.array.sentence_connector").should_not be_nil
67
+ end
68
+
69
+ def lookup(*args)
70
+ I18n.backend.send(:lookup, Russian.locale, *args)
71
+ end
72
+ end
73
+ end
74
+
75
+ describe "with localize proxy" do
76
+ before(:all) do
77
+ @time = mock(:time)
78
+ @options = { :format => "%d %B %Y" }
79
+ end
80
+
81
+ %w(l localize).each do |method|
82
+ it "#{method} should call I18n backend localize" do
83
+ I18n.should_receive(:localize).with(@time, @options.merge({ :locale => Russian.locale }))
84
+ Russian.send(method, @time, @options)
85
+ end
86
+ end
87
+ end
88
+
89
+ describe "with translate proxy" do
90
+ before(:all) do
91
+ @object = :bar
92
+ @options = { :scope => :foo }
93
+ end
94
+
95
+ %w(t translate).each do |method|
96
+ it "#{method} should call I18n backend translate" do
97
+ I18n.should_receive(:translate).with(@object, @options.merge({ :locale => Russian.locale }))
98
+ Russian.send(method, @object, @options)
99
+ end
100
+ end
101
+ end
102
+
103
+ describe "strftime" do
104
+ before(:all) do
105
+ @time = mock(:time)
106
+ end
107
+
108
+ it "should call localize with object and format" do
109
+ format = "%d %B %Y"
110
+ Russian.should_receive(:localize).with(@time, { :format => format })
111
+ Russian.strftime(@time, format)
112
+ end
113
+
114
+ it "should call localize with object and default format when format is not specified" do
115
+ Russian.should_receive(:localize).with(@time, { :format => :default })
116
+ Russian.strftime(@time)
117
+ end
118
+ end
119
+
120
+ describe "pluralize" do
121
+ it "should pluralize with variants given" do
122
+ variants = %w(вещь вещи вещей)
123
+
124
+ Russian.pluralize(1, *variants).should == "вещь"
125
+ Russian.pluralize(2, *variants).should == 'вещи'
126
+ Russian.pluralize(3, *variants).should == 'вещи'
127
+ Russian.pluralize(5, *variants).should == 'вещей'
128
+ Russian.pluralize(10, *variants).should == 'вещей'
129
+ Russian.pluralize(21, *variants).should == 'вещь'
130
+ Russian.pluralize(29, *variants).should == 'вещей'
131
+ Russian.pluralize(129, *variants).should == 'вещей'
132
+ Russian.pluralize(131, *variants).should == 'вещь'
133
+ end
134
+
135
+ it "should raise an exception when there are not enough variants" do
136
+ lambda { Russian.pluralize(1) }.should raise_error(ArgumentError)
137
+ lambda { Russian.pluralize(1, "вещь") }.should raise_error(ArgumentError)
138
+ lambda { Russian.pluralize(1, "вещь", "вещи") }.should raise_error(ArgumentError)
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,5 @@
1
+ $TESTING=true
2
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require 'russian'
5
+
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: russian
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Markin
8
+ autorequire: russian
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-01 00:00:00 +04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Russian language support for Ruby and Rails
17
+ email: yaroslav@markin.net
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.textile
24
+ - LICENSE
25
+ - TODO
26
+ files:
27
+ - LICENSE
28
+ - README.textile
29
+ - Rakefile
30
+ - TODO
31
+ - init.rb
32
+ - lib/russian
33
+ - lib/russian/action_view_ext
34
+ - lib/russian/action_view_ext/helpers
35
+ - lib/russian/action_view_ext/helpers/date_helper.rb
36
+ - lib/russian/active_record_ext
37
+ - lib/russian/active_record_ext/custom_error_message.rb
38
+ - lib/russian/backend
39
+ - lib/russian/backend/advanced.rb
40
+ - lib/russian/core_ext
41
+ - lib/russian/locale
42
+ - lib/russian/locale/actionview.yml
43
+ - lib/russian/locale/activerecord.yml
44
+ - lib/russian/locale/activesupport.yml
45
+ - lib/russian/locale/datetime.yml
46
+ - lib/russian/locale/pluralize.rb
47
+ - lib/russian.rb
48
+ - lib/vendor
49
+ - lib/vendor/i18n
50
+ - lib/vendor/i18n/i18n.gemspec
51
+ - lib/vendor/i18n/lib
52
+ - lib/vendor/i18n/lib/i18n
53
+ - lib/vendor/i18n/lib/i18n/backend
54
+ - lib/vendor/i18n/lib/i18n/backend/simple.rb
55
+ - lib/vendor/i18n/lib/i18n/exceptions.rb
56
+ - lib/vendor/i18n/lib/i18n.rb
57
+ - lib/vendor/i18n/MIT-LICENSE
58
+ - lib/vendor/i18n/README.textile
59
+ - lib/vendor/i18n/test
60
+ - lib/vendor/i18n/test/all.rb
61
+ - lib/vendor/i18n/test/i18n_exceptions_test.rb
62
+ - lib/vendor/i18n/test/i18n_test.rb
63
+ - lib/vendor/i18n/test/locale
64
+ - lib/vendor/i18n/test/locale/en-US.rb
65
+ - lib/vendor/i18n/test/locale/en-US.yml
66
+ - lib/vendor/i18n/test/simple_backend_test.rb
67
+ - spec/i18n
68
+ - spec/i18n/locale
69
+ - spec/i18n/locale/datetime_spec.rb
70
+ - spec/i18n/locale/pluralization_spec.rb
71
+ - spec/russian_spec.rb
72
+ - spec/spec_helper.rb
73
+ has_rdoc: true
74
+ homepage: http://github.com/yaroslav/russian/
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 1.2.0
96
+ signing_key:
97
+ specification_version: 2
98
+ summary: Russian language support for Ruby and Rails
99
+ test_files: []
100
+