rs_russian 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/russian/locale/datetime.rb +4 -4
- data/lib/russian/rails_admin_datetime.rb +43 -0
- data/lib/russian/version.rb +1 -1
- data/lib/russian.rb +6 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f295ea63db240fb3c88171a84fb4fe382b06b15e
|
4
|
+
data.tar.gz: 964f4a1c737c49c9192e626dc51311c25cb19822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba8338eb610117b005814c079649d953fb8db53ced331a98e0775f9c9750358f35ef2be2e248bd49ed9e49fc694c8df8592741f2f1eab025990f45fbaecce3d
|
7
|
+
data.tar.gz: fd886e2f2b41ba97e584db222986ca9d59fc471947c61d8b0d172287272c7956a14f5c2753665f0ea5f2f645dac1c6939b7f25398db5a656aedecc2a3e95d285
|
data/Gemfile.lock
CHANGED
@@ -7,28 +7,28 @@
|
|
7
7
|
:ru => {
|
8
8
|
:date => {
|
9
9
|
:abbr_day_names => lambda { |key, options|
|
10
|
-
if options[:format] && options[:format] =~ Russian::LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH
|
10
|
+
if options[:format] && options[:format] =~ Russian::LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH && !Russian.force_standalone
|
11
11
|
:'date.common_abbr_day_names'
|
12
12
|
else
|
13
13
|
:'date.standalone_abbr_day_names'
|
14
14
|
end
|
15
15
|
},
|
16
16
|
:day_names => lambda { |key, options|
|
17
|
-
if options[:format] && options[:format] =~ Russian::LOCALIZE_STANDALONE_DAY_NAMES_MATCH
|
17
|
+
if options[:format] && options[:format] =~ Russian::LOCALIZE_STANDALONE_DAY_NAMES_MATCH && !Russian.force_standalone
|
18
18
|
:'date.standalone_day_names'
|
19
19
|
else
|
20
20
|
:'date.common_day_names'
|
21
21
|
end
|
22
22
|
},
|
23
23
|
:abbr_month_names => lambda { |key, options|
|
24
|
-
if options[:format] && options[:format] =~ Russian::LOCALIZE_ABBR_MONTH_NAMES_MATCH
|
24
|
+
if options[:format] && options[:format] =~ Russian::LOCALIZE_ABBR_MONTH_NAMES_MATCH && !Russian.force_standalone
|
25
25
|
:'date.common_abbr_month_names'
|
26
26
|
else
|
27
27
|
:'date.standalone_abbr_month_names'
|
28
28
|
end
|
29
29
|
},
|
30
30
|
:month_names => lambda { |key, options|
|
31
|
-
if options[:format] && options[:format] =~ Russian::LOCALIZE_MONTH_NAMES_MATCH
|
31
|
+
if options[:format] && options[:format] =~ Russian::LOCALIZE_MONTH_NAMES_MATCH && !Russian.force_standalone
|
32
32
|
:'date.common_month_names'
|
33
33
|
else
|
34
34
|
:'date.standalone_month_names'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails_admin/config/fields/types/datetime'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module Config
|
5
|
+
module Fields
|
6
|
+
module Types
|
7
|
+
class Datetime < RailsAdmin::Config::Fields::Base
|
8
|
+
def parse_input(params)
|
9
|
+
str = params[name]
|
10
|
+
unless I18n.locale == :en
|
11
|
+
strftime_format.to_s.scan(/%[AaBbp]/) do |match|
|
12
|
+
case match
|
13
|
+
when '%B'
|
14
|
+
english = I18n.t('date.month_names', :locale => :en)[1..-1]
|
15
|
+
common_month_names = I18n.t('date.common_month_names')[1..-1]
|
16
|
+
common_month_names.each_with_index {|m, i| str = str.gsub(/#{m}/i, english[i]) }
|
17
|
+
when '%b'
|
18
|
+
english = I18n.t('date.abbr_month_names', :locale => :en)[1..-1]
|
19
|
+
common_abbr_month_names = I18n.t('date.common_abbr_month_names')[1..-1]
|
20
|
+
common_abbr_month_names.each_with_index {|m, i| str = str.gsub(/#{m}/i, english[i]) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
params[name] = parser.parse_string(str) if params[name]
|
25
|
+
end
|
26
|
+
|
27
|
+
register_instance_option :formatted_value do
|
28
|
+
ret = if time = (value || default_value)
|
29
|
+
opt = {format: strftime_format, standalone: true}
|
30
|
+
Russian.force_standalone = true
|
31
|
+
r = ::I18n.l(time, opt)
|
32
|
+
Russian.force_standalone = false
|
33
|
+
r
|
34
|
+
else
|
35
|
+
''.html_safe
|
36
|
+
end
|
37
|
+
ret
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/russian/version.rb
CHANGED
data/lib/russian.rb
CHANGED
@@ -18,6 +18,8 @@ module Russian
|
|
18
18
|
|
19
19
|
autoload :Transliteration, 'transliteration'
|
20
20
|
|
21
|
+
cattr_accessor :force_standalone
|
22
|
+
|
21
23
|
# Russian locale
|
22
24
|
LOCALE = :'ru'
|
23
25
|
|
@@ -120,3 +122,7 @@ end
|
|
120
122
|
|
121
123
|
Russian.init_i18n
|
122
124
|
|
125
|
+
if Object.const_defined?('RailsAdmin')
|
126
|
+
require 'rails_admin_datetime'
|
127
|
+
end
|
128
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs_russian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/russian/locale/datetime.yml
|
139
139
|
- lib/russian/locale/pluralization.rb
|
140
140
|
- lib/russian/locale/transliterator.rb
|
141
|
+
- lib/russian/rails_admin_datetime.rb
|
141
142
|
- lib/russian/russian_rails.rb
|
142
143
|
- lib/russian/transliteration.rb
|
143
144
|
- lib/russian/version.rb
|