belorussian 0.6.0

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,4 @@
1
+ # Fixture dummy translation
2
+ # Need this to test if we preserve translation data that is already loaded when switching backends
3
+ en:
4
+ foo: "bar"
@@ -0,0 +1,4 @@
1
+ by:
2
+ date:
3
+ formats:
4
+ default: "override"
@@ -0,0 +1,106 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../../spec_helper'
4
+
5
+ describe I18n, "Belorussian Date/Time localization" do
6
+ before(:all) do
7
+ Belorussian.init_i18n
8
+ @date = Date.parse("1985-12-01")
9
+ @time = Time.local(1985, 12, 01, 16, 05)
10
+ end
11
+
12
+ describe "with date formats" do
13
+ it "should use default format" do
14
+ l(@date).should == "01.12.1985"
15
+ end
16
+
17
+ it "should use short format" do
18
+ l(@date, :format => :short).should == "01 дек."
19
+ end
20
+
21
+ it "should use long format" do
22
+ l(@date, :format => :long).should == "01 декабря 1985"
23
+ end
24
+ end
25
+
26
+ describe "with date day names" do
27
+ it "should use day names" do
28
+ l(@date, :format => "%d %B (%A)").should == "01 декабря (воскресенье)"
29
+ l(@date, :format => "%d %B %Y года было %A").should == "01 декабря 1985 года было воскресенье"
30
+ end
31
+
32
+ it "should use standalone day names" do
33
+ l(@date, :format => "%A").should == "Воскресенье"
34
+ l(@date, :format => "%A, %d %B").should == "Воскресенье, 01 декабря"
35
+ end
36
+
37
+ it "should use abbreviated day names" do
38
+ l(@date, :format => "%a").should == "Вс"
39
+ l(@date, :format => "%a, %d %b %Y").should == "Вс, 01 дек. 1985"
40
+ end
41
+ end
42
+
43
+ describe "with month names" do
44
+ it "should use month names" do
45
+ l(@date, :format => "%d %B").should == "01 декабря"
46
+ l(@date, :format => "%-d %B").should == "1 декабря"
47
+
48
+ if RUBY_VERSION > "1.9.2"
49
+ l(@date, :format => "%1d %B").should == "1 декабря"
50
+ l(@date, :format => "%2d %B").should == "01 декабря"
51
+ end
52
+
53
+ l(@date, :format => "%e %B %Y").should == " 1 декабря 1985"
54
+ l(@date, :format => "<b>%d</b> %B").should == "<b>01</b> декабря"
55
+ l(@date, :format => "<strong>%e</strong> %B %Y").should == "<strong> 1</strong> декабря 1985"
56
+ l(@date, :format => "А было тогда %eе число %B %Y").should == "А было тогда 1е число декабря 1985"
57
+ end
58
+
59
+ it "should use standalone month names" do
60
+ l(@date, :format => "%B").should == "Декабрь"
61
+ l(@date, :format => "%B %Y").should == "Декабрь 1985"
62
+ end
63
+
64
+ it "should use abbreviated month names" do
65
+ @date = Date.parse("1985-03-01")
66
+ l(@date, :format => "%d %b").should == "01 марта"
67
+ l(@date, :format => "%e %b %Y").should == " 1 марта 1985"
68
+ l(@date, :format => "<b>%d</b> %b").should == "<b>01</b> марта"
69
+ l(@date, :format => "<strong>%e</strong> %b %Y").should == "<strong> 1</strong> марта 1985"
70
+ end
71
+
72
+ it "should use standalone abbreviated month names" do
73
+ @date = Date.parse("1985-03-01")
74
+ l(@date, :format => "%b").should == "март"
75
+ l(@date, :format => "%b %Y").should == "март 1985"
76
+ end
77
+ end
78
+
79
+ it "should define default date components order: day, month, year" do
80
+ I18n.backend.translate(Belorussian.locale, :"date.order").should == [:day, :month, :year]
81
+ end
82
+
83
+ describe "with time formats" do
84
+ it "should use default format" do
85
+ l(@time).should =~ /^Вс, 01 дек. 1985, 16:05:00/
86
+ end
87
+
88
+ it "should use short format" do
89
+ l(@time, :format => :short).should == "01 дек., 16:05"
90
+ end
91
+
92
+ it "should use long format" do
93
+ l(@time, :format => :long).should == "01 декабря 1985, 16:05"
94
+ end
95
+
96
+ it "should define am and pm" do
97
+ I18n.backend.translate(Belorussian.locale, :"time.am").should_not be_nil
98
+ I18n.backend.translate(Belorussian.locale, :"time.pm").should_not be_nil
99
+ end
100
+ end
101
+
102
+ protected
103
+ def l(object, options = {})
104
+ I18n.l(object, options.merge( { :locale => Belorussian.locale }))
105
+ end
106
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../../spec_helper'
4
+
5
+ describe I18n, "Belorussian pluralization" do
6
+ before(:each) do
7
+ @hash = {}
8
+ %w(one few many other).each do |key|
9
+ @hash[key.to_sym] = key
10
+ end
11
+ @backend = I18n.backend
12
+ end
13
+
14
+ it "should pluralize correctly" do
15
+ @backend.send(:pluralize, :'by', @hash, 1).should == 'one'
16
+ @backend.send(:pluralize, :'by', @hash, 2).should == 'few'
17
+ @backend.send(:pluralize, :'by', @hash, 3).should == 'few'
18
+ @backend.send(:pluralize, :'by', @hash, 5).should == 'many'
19
+ @backend.send(:pluralize, :'by', @hash, 10).should == 'many'
20
+ @backend.send(:pluralize, :'by', @hash, 11).should == 'many'
21
+ @backend.send(:pluralize, :'by', @hash, 21).should == 'one'
22
+ @backend.send(:pluralize, :'by', @hash, 29).should == 'many'
23
+ @backend.send(:pluralize, :'by', @hash, 131).should == 'one'
24
+ @backend.send(:pluralize, :'by', @hash, 1.31).should == 'other'
25
+ @backend.send(:pluralize, :'by', @hash, 2.31).should == 'other'
26
+ @backend.send(:pluralize, :'by', @hash, 3.31).should == 'other'
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper'
4
+
5
+ describe Belorussian, "loading locales" do
6
+ before(:all) do
7
+ Belorussian.init_i18n
8
+ end
9
+
10
+ %w(
11
+ date.formats.default
12
+ date.formats.short
13
+ date.formats.long
14
+ date.day_names
15
+ date.standalone_day_names
16
+ date.abbr_day_names
17
+ date.month_names
18
+ date.standalone_month_names
19
+ date.abbr_month_names
20
+ date.standalone_abbr_month_names
21
+ date.order
22
+
23
+ time.formats.default
24
+ time.formats.short
25
+ time.formats.long
26
+ time.am
27
+ time.pm
28
+ ).each do |key|
29
+ it "should define '#{key}' in datetime translations" do
30
+ lookup(key).should_not be_nil
31
+ end
32
+ end
33
+
34
+ it "should load pluralization rules" do
35
+ lookup(:'i18n.plural.rule').should_not be_nil
36
+ lookup(:'i18n.plural.rule').is_a?(Proc).should be_true
37
+ end
38
+
39
+ it "should load transliteration rule" do
40
+ lookup(:'i18n.transliterate.rule').should_not be_nil
41
+ lookup(:'i18n.transliterate.rule').is_a?(Proc).should be_true
42
+ end
43
+
44
+ def lookup(*args)
45
+ I18n.backend.send(:lookup, Belorussian.locale, *args)
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $TESTING=true
4
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
+
6
+ require 'belorussian'
7
+
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper'
4
+
5
+ describe Belorussian do
6
+ describe "transliteration" do
7
+ def t(str)
8
+ Belorussian::transliterate(str)
9
+ end
10
+
11
+ %w(transliterate translit).each do |method|
12
+ it "'#{method}' method should perform transliteration" do
13
+ str = mock(:str)
14
+ Belorussian::Transliteration.should_receive(:transliterate).with(str)
15
+ Belorussian.send(method, str)
16
+ end
17
+ end
18
+
19
+ # These tests are from rutils, <http://rutils.rubyforge.org>.
20
+
21
+ it "should transliterate properly" do
22
+ t("Это просто некий текст").should == "Eto prosto nekiy tekst"
23
+ t("щ").should == "sch"
24
+ t("стансы").should == "stansy"
25
+ t("упущение").should == "upuschenie"
26
+ t("ш").should == "sh"
27
+ t("Ш").should == "SH"
28
+ t("ц").should == "ts"
29
+ end
30
+
31
+ it "should properly transliterate mixed belorussian-english strings" do
32
+ t("Это кусок строки русских букв v peremeshku s latinizey i амперсандом (pozor!) & something").should ==
33
+ "Eto kusok stroki russkih bukv v peremeshku s latinizey i ampersandom (pozor!) & something"
34
+ end
35
+
36
+ it "should properly transliterate mixed case chars in a string" do
37
+ t("НЕВЕРОЯТНОЕ УПУЩЕНИЕ").should == "NEVEROYATNOE UPUSCHENIE"
38
+ t("Невероятное Упущение").should == "Neveroyatnoe Upuschenie"
39
+ t("Шерстяной Заяц").should == "Sherstyanoy Zayats"
40
+ t("Н.П. Шерстяков").should == "N.P. Sherstyakov"
41
+ t("ШАРОВАРЫ").should == "SHAROVARY"
42
+ end
43
+
44
+ it "should work for multi-char substrings" do
45
+ t("38 воробьёв").should == "38 vorobiev"
46
+ t("Вася Воробьёв").should == "Vasya Vorobiev"
47
+ t("Алябьев").should == "Alyabiev"
48
+ t("АЛЯБЬЕВ").should == "ALYABIEV"
49
+ end
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: belorussian
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yaroslav Markin
9
+ autorequire: belorussian
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: i18n
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.5.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.5.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.7.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.7.0
62
+ description: Belorussian language support for Ruby and Rails
63
+ email: yaroslav@markin.net
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files:
67
+ - README.textile
68
+ - LICENSE
69
+ - CHANGELOG
70
+ - TODO
71
+ files:
72
+ - lib/belorussian/active_model_ext/custom_error_message.rb
73
+ - lib/belorussian/action_view_ext/helpers/date_helper.rb
74
+ - lib/belorussian/belorussian_rails.rb
75
+ - lib/belorussian/version.rb
76
+ - lib/belorussian/locale/actionview.yml
77
+ - lib/belorussian/locale/transliterator.rb
78
+ - lib/belorussian/locale/datetime.yml
79
+ - lib/belorussian/locale/datetime.rb
80
+ - lib/belorussian/locale/activesupport.yml
81
+ - lib/belorussian/locale/activerecord.yml
82
+ - lib/belorussian/locale/activemodel.yml
83
+ - lib/belorussian/locale/pluralization.rb
84
+ - lib/belorussian/transliteration.rb
85
+ - lib/belorussian.rb
86
+ - spec/spec_helper.rb
87
+ - spec/transliteration_spec.rb
88
+ - spec/i18n/locale/datetime_spec.rb
89
+ - spec/i18n/locale/pluralization_spec.rb
90
+ - spec/fixtures/en.yml
91
+ - spec/fixtures/ru.yml
92
+ - spec/belorussian_spec.rb
93
+ - spec/locale_spec.rb
94
+ - CHANGELOG
95
+ - Gemfile
96
+ - LICENSE
97
+ - Rakefile
98
+ - README.textile
99
+ - belorussian.gemspec
100
+ - TODO
101
+ homepage: http://github.com/yaroslav/belorussian/
102
+ licenses: []
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: 1.3.5
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.24
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Belorussian language support for Ruby and Rails
125
+ test_files: []