Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
source :rubygems
# frozen_string_literal: true

gem 'rake'
gem 'i18n', '>= 0.5.0'
gem 'rspec', '~> 2.7.0'
ruby "2.7.5"

# Rails 3+
gem 'activesupport', '~> 3.0.0'
source 'https://rubygems.org'

gem 'rake', '~> 12.3'
gem "i18n", "1.8.11"
gem 'rspec', '~> 3.12.0'

# Rails 6+
gem 'activesupport', '~> 6.1.0'

56 changes: 39 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
activesupport (3.0.10)
diff-lcs (1.1.3)
i18n (0.6.0)
rake (0.9.2.2)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
rspec-mocks (~> 2.7.0)
rspec-core (2.7.1)
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.7.0)
activesupport (6.1.7.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
concurrent-ruby (1.2.3)
diff-lcs (1.5.0)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
minitest (5.21.1)
rake (12.3.3)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
zeitwerk (2.6.12)

PLATFORMS
ruby

DEPENDENCIES
activesupport (~> 3.0.0)
i18n (>= 0.5.0)
rake
rspec (~> 2.7.0)
activesupport (~> 6.1.0)
i18n (= 1.8.11)
rake (~> 12.3)
rspec (~> 3.12.0)

RUBY VERSION
ruby 2.7.5p203

BUNDLED WITH
2.4.19
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ require 'rubygems/specification'
task :default => :spec
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = %w(-fs --color)
t.pattern = 'spec/**/*_spec.rb'
t.rspec_opts = %w(-fd --color)
end
4 changes: 2 additions & 2 deletions lib/russian.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def init_i18n

# See I18n::translate
def translate(key, options = {})
I18n.translate(key, options.merge({ :locale => LOCALE }))
I18n.translate(key, **options.merge({ :locale => LOCALE }))
end
alias :t :translate

# See I18n::localize
def localize(object, options = {})
I18n.localize(object, options.merge({ :locale => LOCALE }))
I18n.localize(object, **options.merge({ :locale => LOCALE }))
end
alias :l :localize

Expand Down
70 changes: 0 additions & 70 deletions lib/russian/active_model_ext/custom_error_message.rb

This file was deleted.

6 changes: 1 addition & 5 deletions lib/russian/russian_rails.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Rails hacks
if defined?(ActiveModel)
require 'active_model_ext/custom_error_message'
end

if defined?(ActionView::Helpers)
require 'action_view_ext/helpers/date_helper'
require 'action_view_ext/helpers/date_helper'
end
6 changes: 3 additions & 3 deletions lib/russian/version.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Russian
module VERSION
MAJOR = 0
MINOR = 6
TINY = 0
MAJOR = 1
MINOR = 0
TINY = 1

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down
6 changes: 3 additions & 3 deletions russian.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.summary = %q{Russian language support for Ruby and Rails}

s.add_dependency('i18n', '>= 0.5.0')
s.add_dependency('i18n', '> 1.8.11')

s.add_development_dependency 'activesupport', '>= 3.0.0'
s.add_development_dependency 'rspec', '~> 2.7.0'
s.add_development_dependency 'activesupport', '>= 6.1.0'
s.add_development_dependency 'rspec', '~> 3.12.0'
end
63 changes: 32 additions & 31 deletions spec/i18n/locale/datetime_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-

require "active_support/core_ext/date"
require File.dirname(__FILE__) + '/../../spec_helper'

describe I18n, "Russian Date/Time localization" do
Expand All @@ -11,91 +12,91 @@

describe "with date formats" do
it "should use default format" do
l(@date).should == "01.12.1985"
expect(l(@date)).to eq "01.12.1985"
end

it "should use short format" do
l(@date, :format => :short).should == "01 дек."
expect(l(@date, :format => :short)).to eq "01 дек."
end

it "should use long format" do
l(@date, :format => :long).should == "01 декабря 1985"
expect(l(@date, :format => :long)).to eq "01 декабря 1985"
end
end

describe "with date day names" do
it "should use day names" do
l(@date, :format => "%d %B (%A)").should == "01 декабря (воскресенье)"
l(@date, :format => "%d %B %Y года было %A").should == "01 декабря 1985 года было воскресенье"
expect(l(@date, :format => "%d %B (%A)")).to eq "01 декабря (воскресенье)"
expect(l(@date, :format => "%d %B %Y года было %A")).to eq "01 декабря 1985 года было воскресенье"
end

it "should use standalone day names" do
l(@date, :format => "%A").should == "Воскресенье"
l(@date, :format => "%A, %d %B").should == "Воскресенье, 01 декабря"
expect(l(@date, :format => "%A")).to eq "Воскресенье"
expect(l(@date, :format => "%A, %d %B")).to eq "Воскресенье, 01 декабря"
end

it "should use abbreviated day names" do
l(@date, :format => "%a").should == "Вс"
l(@date, :format => "%a, %d %b %Y").should == "Вс, 01 дек. 1985"
expect(l(@date, :format => "%a")).to eq "Вс"
expect(l(@date, :format => "%a, %d %b %Y")).to eq "Вс, 01 дек. 1985"
end
end

describe "with month names" do
it "should use month names" do
l(@date, :format => "%d %B").should == "01 декабря"
l(@date, :format => "%-d %B").should == "1 декабря"
expect(l(@date, :format => "%d %B")).to eq "01 декабря"
expect(l(@date, :format => "%-d %B")).to eq "1 декабря"

if RUBY_VERSION > "1.9.2"
l(@date, :format => "%1d %B").should == "1 декабря"
l(@date, :format => "%2d %B").should == "01 декабря"
expect(l(@date, :format => "%1d %B")).to eq "1 декабря"
expect(l(@date, :format => "%2d %B")).to eq "01 декабря"
end

l(@date, :format => "%e %B %Y").should == " 1 декабря 1985"
l(@date, :format => "<b>%d</b> %B").should == "<b>01</b> декабря"
l(@date, :format => "<strong>%e</strong> %B %Y").should == "<strong> 1</strong> декабря 1985"
l(@date, :format => "А было тогда %eе число %B %Y").should == "А было тогда 1е число декабря 1985"
expect(l(@date, :format => "%e %B %Y")).to eq " 1 декабря 1985"
expect(l(@date, :format => "<b>%d</b> %B")).to eq "<b>01</b> декабря"
expect(l(@date, :format => "<strong>%e</strong> %B %Y")).to eq "<strong> 1</strong> декабря 1985"
expect(l(@date, :format => "А было тогда %eе число %B %Y")).to eq "А было тогда 1е число декабря 1985"
end

it "should use standalone month names" do
l(@date, :format => "%B").should == "Декабрь"
l(@date, :format => "%B %Y").should == "Декабрь 1985"
expect(l(@date, :format => "%B")).to eq "Декабрь"
expect(l(@date, :format => "%B %Y")).to eq "Декабрь 1985"
end

it "should use abbreviated month names" do
@date = Date.parse("1985-03-01")
l(@date, :format => "%d %b").should == "01 марта"
l(@date, :format => "%e %b %Y").should == " 1 марта 1985"
l(@date, :format => "<b>%d</b> %b").should == "<b>01</b> марта"
l(@date, :format => "<strong>%e</strong> %b %Y").should == "<strong> 1</strong> марта 1985"
expect(l(@date, :format => "%d %b")).to eq "01 марта"
expect(l(@date, :format => "%e %b %Y")).to eq " 1 марта 1985"
expect(l(@date, :format => "<b>%d</b> %b")).to eq "<b>01</b> марта"
expect(l(@date, :format => "<strong>%e</strong> %b %Y")).to eq "<strong> 1</strong> марта 1985"
end

it "should use standalone abbreviated month names" do
@date = Date.parse("1985-03-01")
l(@date, :format => "%b").should == "март"
l(@date, :format => "%b %Y").should == "март 1985"
expect(l(@date, :format => "%b")).to eq "март"
expect(l(@date, :format => "%b %Y")).to eq "март 1985"
end
end

it "should define default date components order: day, month, year" do
I18n.backend.translate(Russian.locale, :"date.order").should == [:day, :month, :year]
expect(I18n.backend.translate(Russian.locale, :"date.order")).to eq [:day, :month, :year]
end

describe "with time formats" do
it "should use default format" do
l(@time).should =~ /^Вс, 01 дек. 1985, 16:05:00/
expect(l(@time)).to match /^Вс, 01 дек. 1985, 16:05:00/
end

it "should use short format" do
l(@time, :format => :short).should == "01 дек., 16:05"
expect(l(@time, :format => :short)).to eq "01 дек., 16:05"
end

it "should use long format" do
l(@time, :format => :long).should == "01 декабря 1985, 16:05"
expect(l(@time, :format => :long)).to eq "01 декабря 1985, 16:05"
end

it "should define am and pm" do
I18n.backend.translate(Russian.locale, :"time.am").should_not be_nil
I18n.backend.translate(Russian.locale, :"time.pm").should_not be_nil
expect(I18n.backend.translate(Russian.locale, :"time.am")).to_not be_nil
expect(I18n.backend.translate(Russian.locale, :"time.pm")).to_not be_nil
end
end

Expand Down
24 changes: 12 additions & 12 deletions spec/i18n/locale/pluralization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
end

it "should pluralize correctly" do
@backend.send(:pluralize, :'ru', @hash, 1).should == 'one'
@backend.send(:pluralize, :'ru', @hash, 2).should == 'few'
@backend.send(:pluralize, :'ru', @hash, 3).should == 'few'
@backend.send(:pluralize, :'ru', @hash, 5).should == 'many'
@backend.send(:pluralize, :'ru', @hash, 10).should == 'many'
@backend.send(:pluralize, :'ru', @hash, 11).should == 'many'
@backend.send(:pluralize, :'ru', @hash, 21).should == 'one'
@backend.send(:pluralize, :'ru', @hash, 29).should == 'many'
@backend.send(:pluralize, :'ru', @hash, 131).should == 'one'
@backend.send(:pluralize, :'ru', @hash, 1.31).should == 'other'
@backend.send(:pluralize, :'ru', @hash, 2.31).should == 'other'
@backend.send(:pluralize, :'ru', @hash, 3.31).should == 'other'
expect(@backend.send(:pluralize, :'ru', @hash, 1)).to eq 'one'
expect(@backend.send(:pluralize, :'ru', @hash, 2)).to eq 'few'
expect(@backend.send(:pluralize, :'ru', @hash, 3)).to eq 'few'
expect(@backend.send(:pluralize, :'ru', @hash, 5)).to eq 'many'
expect(@backend.send(:pluralize, :'ru', @hash, 10)).to eq 'many'
expect(@backend.send(:pluralize, :'ru', @hash, 11)).to eq 'many'
expect(@backend.send(:pluralize, :'ru', @hash, 21)).to eq 'one'
expect(@backend.send(:pluralize, :'ru', @hash, 29)).to eq 'many'
expect(@backend.send(:pluralize, :'ru', @hash, 131)).to eq 'one'
expect(@backend.send(:pluralize, :'ru', @hash, 1.31)).to eq 'other'
expect(@backend.send(:pluralize, :'ru', @hash, 2.31)).to eq 'other'
expect(@backend.send(:pluralize, :'ru', @hash, 3.31)).to eq 'other'
end
end
10 changes: 5 additions & 5 deletions spec/locale_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
time.pm
).each do |key|
it "should define '#{key}' in datetime translations" do
lookup(key).should_not be_nil
expect(lookup(key)).to_not be_nil
end
end

it "should load pluralization rules" do
lookup(:'i18n.plural.rule').should_not be_nil
lookup(:'i18n.plural.rule').is_a?(Proc).should be_true
expect(lookup(:'i18n.plural.rule')).to_not be_nil
expect(lookup(:'i18n.plural.rule').is_a?(Proc)).to be true
end

it "should load transliteration rule" do
lookup(:'i18n.transliterate.rule').should_not be_nil
lookup(:'i18n.transliterate.rule').is_a?(Proc).should be_true
expect(lookup(:'i18n.transliterate.rule')).to_not be_nil
expect(lookup(:'i18n.transliterate.rule').is_a?(Proc)).to be true
end

def lookup(*args)
Expand Down
Loading