rails-i18n 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rails_i18n.rb CHANGED
@@ -1 +1,2 @@
1
+ require 'rails_i18n/unicode'
1
2
  require 'rails_i18n/railtie'
@@ -4,7 +4,7 @@ module RailsI18n
4
4
  module Pluralization
5
5
  module OneUptoTwoOther
6
6
  def self.rule
7
- lambda { |n| (0...2).cover?(n) ? :one : :other }
7
+ lambda { |n| n >= 0 && n < 2 ? :one : :other }
8
8
  end
9
9
 
10
10
  def self.with_locale(locale)
@@ -0,0 +1 @@
1
+ $KCODE = "U" if RUBY_VERSION < '1.9' && $KCODE == 'NONE'
@@ -5,7 +5,7 @@ module RailsI18n
5
5
  lambda do |n|
6
6
  if n == 0
7
7
  :zero
8
- elsif (0...2).cover?(n)
8
+ elsif n > 0 && n < 2
9
9
  :one
10
10
  else
11
11
  :other
@@ -25,9 +25,9 @@ module RailsI18n
25
25
  when 'Щ'
26
26
  lookahead_upcase 'SHCH'
27
27
  when 'г'
28
- behind =~ /з/i ? 'gh' : 'h'
28
+ behind =~ /[зЗ]/ ? 'gh' : 'h'
29
29
  when 'Г'
30
- behind =~ /з/i ? lookahead_upcase('GH') : 'H'
30
+ behind =~ /[зЗ]/ ? lookahead_upcase('GH') : 'H'
31
31
  when 'є'
32
32
  letter?(behind) ? 'ie' : 'ye'
33
33
  when 'Є'
@@ -60,22 +60,45 @@ module RailsI18n
60
60
 
61
61
  private
62
62
 
63
- def behind
64
- @pre_match && @pre_match[-1]
65
- end
63
+ if RUBY_VERSION < '1.9'
64
+ # two bytes will be enough for Cyrillic
65
+ class_eval <<-END, __FILE__, __LINE__ + 1
66
+ def behind
67
+ tail = @pre_match && @pre_match[-2..-1]
68
+ tail && tail.split(//).last
69
+ end
70
+
71
+ def ahead
72
+ @post_match && @post_match[0..1].split(//).first
73
+ end
74
+ END
75
+ else
76
+ class_eval <<-END, __FILE__, __LINE__ + 1
77
+ def behind
78
+ @pre_match && @pre_match[-1]
79
+ end
66
80
 
67
- def ahead
68
- @post_match && @post_match[0]
81
+ def ahead
82
+ @post_match && @post_match[0]
83
+ end
84
+ END
69
85
  end
70
86
 
71
87
  def downcased?(symbol)
72
- symbol =~ /\p{Ll}/
88
+ symbol =~ downcased_regexp
89
+ end
90
+
91
+ def downcased_regexp
92
+ @downcased_regexp ||= /[а-яґєії]/
73
93
  end
74
94
 
75
95
  # apostrophe can be inside a word
76
- # TODO what about hyphen?
77
96
  def letter?(symbol)
78
- symbol =~ /[\p{L}'’]/
97
+ symbol =~ letter_regexp
98
+ end
99
+
100
+ def letter_regexp
101
+ @letter_regexp ||= /[а-яґєіїА-ЯҐЄІЇ'’]/
79
102
  end
80
103
 
81
104
  def lookahead_upcase(word)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-25 00:00:00.000000000 Z
12
+ date: 2012-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
- requirement: &14419600 !ruby/object:Gem::Requirement
16
+ requirement: &7186520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14419600
24
+ version_requirements: *7186520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &14418620 !ruby/object:Gem::Requirement
27
+ requirement: &7186000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *14418620
35
+ version_requirements: *7186000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-rails
38
- requirement: &14414740 !ruby/object:Gem::Requirement
38
+ requirement: &7185460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.7.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *14414740
46
+ version_requirements: *7185460
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: i18n-spec
49
- requirement: &14441660 !ruby/object:Gem::Requirement
49
+ requirement: &7184920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.1.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *14441660
57
+ version_requirements: *7184920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: spork
60
- requirement: &14438360 !ruby/object:Gem::Requirement
60
+ requirement: &7184380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 1.0rc
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *14438360
68
+ version_requirements: *7184380
69
69
  description: A set of common locale data and translations to internationalize and/or
70
70
  localize your Rails applications.
71
71
  email: rails-i18n@googlegroups.com
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - lib/rails_i18n/railtie.rb
77
+ - lib/rails_i18n/unicode.rb
77
78
  - lib/rails_i18n/common_pluralizations/only_one.rb
78
79
  - lib/rails_i18n/common_pluralizations/east_slavic.rb
79
80
  - lib/rails_i18n/common_pluralizations/west_slavic.rb