yaroslav-russian 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +6 -1
- data/Rakefile +1 -1
- data/lib/russian/locale/actionview.yml +4 -4
- data/lib/russian/locale/activerecord.yml +36 -12
- data/lib/russian.rb +1 -1
- data/spec/locale_spec.rb +114 -0
- data/spec/russian_spec.rb +0 -35
- metadata +3 -2
data/README.textile
CHANGED
@@ -46,7 +46,8 @@ Russian можно установить как gem с github. Для этого:
|
|
46
46
|
|
47
47
|
@gem install yaroslav-russian@
|
48
48
|
|
49
|
-
|
49
|
+
|
50
|
+
_NB:_ Gem @russian@ также зеркалируется на RubyForge, поэтому его можно установить командой
|
50
51
|
|
51
52
|
@gem install russian@.
|
52
53
|
|
@@ -114,6 +115,10 @@ h2. Отличия от стандартной библиотеки I18n
|
|
114
115
|
|
115
116
|
h1. Справочник
|
116
117
|
|
118
|
+
h2. Примеры и справка по переводам (I18n)
|
119
|
+
|
120
|
+
Небольшую справку по переводам (I18n) и пример того, как можно переводить имена моделей, атрибутов, и многие другие вещи, определенные в Rails или I18n, можно посмотреть в директории @lib/russian/locale@. Там находятся файлы переводов, которые используются в Russian, со всеми комментариями.
|
121
|
+
|
117
122
|
h2. Вспомогательные методы модуля Russian
|
118
123
|
|
119
124
|
<pre></code>
|
data/Rakefile
CHANGED
@@ -115,10 +115,10 @@ ru-RU:
|
|
115
115
|
template:
|
116
116
|
# Заголовок сообщения об ошибке
|
117
117
|
header:
|
118
|
-
one: "{{model}} не удалось
|
119
|
-
few: "{{model}} не удалось
|
120
|
-
many: "{{model}} не удалось
|
121
|
-
other: "{{model}} не удалось
|
118
|
+
one: "{{model}}: сохранение не удалось из-за 1 ошибки"
|
119
|
+
few: "{{model}}: сохранение не удалось из-за {{count}} ошибок"
|
120
|
+
many: "{{model}}: сохранение не удалось из-за {{count}} ошибок"
|
121
|
+
other: "{{model}}: сохранение не удалось из-за {{count}} ошибок"
|
122
122
|
|
123
123
|
# Первый параграф сообщения об ошибке. Можно использовать макрос {{count}}
|
124
124
|
#
|
@@ -47,20 +47,44 @@ ru-RU:
|
|
47
47
|
less_than_or_equal_to: "может иметь значение меньшее или равное {{count}}"
|
48
48
|
odd: "может иметь лишь четное значение"
|
49
49
|
even: "может иметь лишь нечетное значение"
|
50
|
-
# Можно добавить собственные сообщения об ошибке тут или в
|
50
|
+
# Можно добавить собственные сообщения об ошибке тут или задавать их в контексте атрибута.
|
51
51
|
#
|
52
52
|
#
|
53
53
|
# Append your own errors here or at the model/attributes scope.
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# Например,
|
57
|
+
# models:
|
58
|
+
# user:
|
59
|
+
# # Задает сообщение об ошибке (пустое значение) для атрибутов модели User
|
60
|
+
# # Можно использовать макросы {{model}}, {{attribute}}.
|
61
|
+
# # Также можно использовать сообщения, начинающиеся с "^" -- в этом случае
|
62
|
+
# # в списке ошибок валидации перед конкретным сообщением не будет выводиться имя атрибута.
|
63
|
+
# blank: "собственное сообщение об ошибке (пустой атрибут) для модели {{model}} и атрибута {{attribute}}"
|
64
|
+
# attributes:
|
65
|
+
# # Также можно задавать собственные сообщения об ошибке для конкретных атрибутов модели.
|
66
|
+
# # Ниже определим собственное сообщение об ошибке для атрибута name модели User.
|
67
|
+
# name:
|
68
|
+
# blank: "Атрибут {{attribute}} особенный -- у него свое сообщение об ошибке при пустом атрибуте"
|
54
69
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
models:
|
71
|
+
# Перевод названий моделей. Используется в Model.human_name().
|
72
|
+
#
|
73
|
+
# Например,
|
74
|
+
# user: "Пользователь"
|
75
|
+
# переведет модель User как "Пользователь".
|
76
|
+
#
|
77
|
+
#
|
78
|
+
# Overrides default messages
|
79
|
+
|
80
|
+
attributes:
|
81
|
+
# Перевод названий атрибутов моделей. Используется в Model.human_attribute_name(attribute).
|
82
|
+
#
|
83
|
+
# Например,
|
84
|
+
# user:
|
85
|
+
# name: "Имя"
|
86
|
+
# переведет атрибут name модели User как "Имя".
|
87
|
+
#
|
88
|
+
#
|
89
|
+
# Overrides model and default messages.
|
66
90
|
|
data/lib/russian.rb
CHANGED
data/spec/locale_spec.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Russian, "loading locales" do
|
4
|
+
before(:all) do
|
5
|
+
Russian.init_i18n
|
6
|
+
end
|
7
|
+
|
8
|
+
%w(
|
9
|
+
date.formats.default
|
10
|
+
date.formats.short
|
11
|
+
date.formats.long
|
12
|
+
date.day_names
|
13
|
+
date.standalone_day_names
|
14
|
+
date.abbr_day_names
|
15
|
+
date.month_names
|
16
|
+
date.standalone_month_names
|
17
|
+
date.abbr_month_names
|
18
|
+
date.standalone_abbr_month_names
|
19
|
+
date.order
|
20
|
+
|
21
|
+
time.formats.default
|
22
|
+
time.formats.short
|
23
|
+
time.formats.long
|
24
|
+
time.am
|
25
|
+
time.pm
|
26
|
+
).each do |key|
|
27
|
+
it "should define '#{key}' in datetime translations" do
|
28
|
+
lookup(key).should_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should load pluralization rules" do
|
33
|
+
lookup(:"pluralize").should_not be_nil
|
34
|
+
lookup(:"pluralize").is_a?(Proc).should be_true
|
35
|
+
end
|
36
|
+
|
37
|
+
%w(
|
38
|
+
number.format.separator
|
39
|
+
number.format.delimiter
|
40
|
+
number.format.precision
|
41
|
+
number.currency.format.format
|
42
|
+
number.currency.format.unit
|
43
|
+
number.currency.format.separator
|
44
|
+
number.currency.format.delimiter
|
45
|
+
number.currency.format.precision
|
46
|
+
number.percentage.format.delimiter
|
47
|
+
number.percentage.format.precision
|
48
|
+
number.precision.format.delimiter
|
49
|
+
number.human.format.delimiter
|
50
|
+
number.human.format.precision
|
51
|
+
|
52
|
+
datetime.distance_in_words.half_a_minute
|
53
|
+
datetime.distance_in_words.less_than_x_seconds
|
54
|
+
datetime.distance_in_words.x_seconds
|
55
|
+
datetime.distance_in_words.less_than_x_minutes
|
56
|
+
datetime.distance_in_words.x_minutes
|
57
|
+
datetime.distance_in_words.about_x_hours
|
58
|
+
datetime.distance_in_words.x_days
|
59
|
+
datetime.distance_in_words.about_x_months
|
60
|
+
datetime.distance_in_words.x_months
|
61
|
+
datetime.distance_in_words.about_x_years
|
62
|
+
datetime.distance_in_words.over_x_years
|
63
|
+
|
64
|
+
activerecord.errors.template.header
|
65
|
+
activerecord.errors.template.body
|
66
|
+
).each do |key|
|
67
|
+
it "should define '#{key}' in actionview translations" do
|
68
|
+
lookup(key).should_not be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
%w(
|
73
|
+
activerecord.errors.messages.inclusion
|
74
|
+
activerecord.errors.messages.exclusion
|
75
|
+
activerecord.errors.messages.invalid
|
76
|
+
activerecord.errors.messages.confirmation
|
77
|
+
activerecord.errors.messages.accepted
|
78
|
+
activerecord.errors.messages.empty
|
79
|
+
activerecord.errors.messages.blank
|
80
|
+
activerecord.errors.messages.too_long
|
81
|
+
activerecord.errors.messages.too_short
|
82
|
+
activerecord.errors.messages.wrong_length
|
83
|
+
activerecord.errors.messages.taken
|
84
|
+
activerecord.errors.messages.not_a_number
|
85
|
+
activerecord.errors.messages.greater_than
|
86
|
+
activerecord.errors.messages.greater_than_or_equal_to
|
87
|
+
activerecord.errors.messages.equal_to
|
88
|
+
activerecord.errors.messages.less_than
|
89
|
+
activerecord.errors.messages.less_than_or_equal_to
|
90
|
+
activerecord.errors.messages.odd
|
91
|
+
activerecord.errors.messages.even
|
92
|
+
).each do |key|
|
93
|
+
it "should define '#{key}' in activerecord translations" do
|
94
|
+
lookup(key).should_not be_nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
%w(
|
99
|
+
support.array.sentence_connector
|
100
|
+
).each do |key|
|
101
|
+
it "should define '#{key}' in activesupport translations" do
|
102
|
+
lookup(key).should_not be_nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
it "should load activesupport translations" do
|
108
|
+
lookup(:"support.array.sentence_connector").should_not be_nil
|
109
|
+
end
|
110
|
+
|
111
|
+
def lookup(*args)
|
112
|
+
I18n.backend.send(:lookup, Russian.locale, *args)
|
113
|
+
end
|
114
|
+
end
|
data/spec/russian_spec.rb
CHANGED
@@ -35,41 +35,6 @@ describe Russian do
|
|
35
35
|
Russian.init_i18n
|
36
36
|
I18n.default_locale.should == Russian.locale
|
37
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
38
|
end
|
74
39
|
|
75
40
|
describe "with localize proxy" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaroslav-russian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Markin
|
@@ -9,7 +9,7 @@ autorequire: russian
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- spec/i18n/locale
|
69
69
|
- spec/i18n/locale/datetime_spec.rb
|
70
70
|
- spec/i18n/locale/pluralization_spec.rb
|
71
|
+
- spec/locale_spec.rb
|
71
72
|
- spec/russian_spec.rb
|
72
73
|
- spec/spec_helper.rb
|
73
74
|
has_rdoc: true
|