mova-i18n 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +47 -0
- data/Gemfile +26 -0
- data/LICENSE.txt +22 -0
- data/README.md +93 -0
- data/Rakefile +24 -0
- data/lib/mova-i18n.rb +77 -0
- data/lib/mova-i18n/bridge.rb +69 -0
- data/lib/mova-i18n/config.rb +36 -0
- data/mova-i18n.gemspec +21 -0
- data/test/exists_test.rb +29 -0
- data/test/locale/en.yml +2 -0
- data/test/localize_test.rb +58 -0
- data/test/mova_config_test.rb +17 -0
- data/test/test_helper.rb +61 -0
- data/test/transfer_translations_test.rb +27 -0
- data/test/translate/default_test.rb +45 -0
- data/test/translate/pluralization_test.rb +62 -0
- data/test/translate/scope_test.rb +26 -0
- data/test/translate_test.rb +61 -0
- data/test/transliterate_test.rb +28 -0
- data/test_rails/dummy/.gitignore +15 -0
- data/test_rails/dummy/app/controllers/hello_controller.rb +2 -0
- data/test_rails/dummy/app/views/hello/html_safe_key.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/html_safe_underscored.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/html_unsafe.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/locale_option.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/missing_translation.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/partial_scope.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/raise_error.html.erb +1 -0
- data/test_rails/dummy/app/views/hello/translate.html.erb +1 -0
- data/test_rails/dummy/config.ru +4 -0
- data/test_rails/dummy/config/application.rb +13 -0
- data/test_rails/dummy/config/environment.rb +5 -0
- data/test_rails/dummy/config/environments/test.rb +10 -0
- data/test_rails/dummy/config/locales/uk.rb +20 -0
- data/test_rails/dummy/config/locales/uk.yml +252 -0
- data/test_rails/dummy/config/locales/views.yml +11 -0
- data/test_rails/helpers_test.rb +37 -0
- data/test_rails/test_helper.rb +11 -0
- data/test_rails/view_test.rb +55 -0
- metadata +154 -0
@@ -0,0 +1 @@
|
|
1
|
+
<%= t ".html" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t :safe_html %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t :html_unsafe %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t :hi, locale: :uk %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t :missing %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t ".rails" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t :missing, raise: true %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t :hi %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "action_controller/railtie"
|
2
|
+
require "mova-i18n"
|
3
|
+
|
4
|
+
module Dummy
|
5
|
+
class Application < Rails::Application
|
6
|
+
config.i18n.enforce_available_locales = true
|
7
|
+
config.i18n.available_locales = :en, :ru, :uk
|
8
|
+
|
9
|
+
config.default_locale = :en
|
10
|
+
|
11
|
+
config.secret_key_base = '-'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
config.eager_load = false
|
3
|
+
config.cache_classes = true
|
4
|
+
config.serve_static_assets = true
|
5
|
+
config.consider_all_requests_local = true
|
6
|
+
config.action_controller.perform_caching = false
|
7
|
+
config.action_dispatch.show_exceptions = false
|
8
|
+
config.action_controller.allow_forgery_protection = false
|
9
|
+
config.active_support.deprecation = :stderr
|
10
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{uk: {
|
2
|
+
i18n: {
|
3
|
+
plural: {
|
4
|
+
rule: lambda do |n|
|
5
|
+
mod10 = n % 10
|
6
|
+
mod100 = n % 100
|
7
|
+
|
8
|
+
if mod10 == 1 && mod100 != 11
|
9
|
+
:one
|
10
|
+
elsif [2, 3, 4].include?(mod10) && ![12, 13, 14].include?(mod100)
|
11
|
+
:few
|
12
|
+
elsif mod10 == 0 || (5..9).to_a.include?(mod10) || (11..14).to_a.include?(mod100)
|
13
|
+
:many
|
14
|
+
else
|
15
|
+
:other
|
16
|
+
end
|
17
|
+
end
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}}
|
@@ -0,0 +1,252 @@
|
|
1
|
+
uk:
|
2
|
+
date:
|
3
|
+
abbr_day_names:
|
4
|
+
- нд.
|
5
|
+
- пн.
|
6
|
+
- вт.
|
7
|
+
- ср.
|
8
|
+
- чт.
|
9
|
+
- пт.
|
10
|
+
- сб.
|
11
|
+
abbr_month_names:
|
12
|
+
-
|
13
|
+
- січ.
|
14
|
+
- лют.
|
15
|
+
- бер.
|
16
|
+
- квіт.
|
17
|
+
- трав.
|
18
|
+
- черв.
|
19
|
+
- лип.
|
20
|
+
- серп.
|
21
|
+
- вер.
|
22
|
+
- жовт.
|
23
|
+
- лист.
|
24
|
+
- груд.
|
25
|
+
day_names:
|
26
|
+
- неділя
|
27
|
+
- понеділок
|
28
|
+
- вівторок
|
29
|
+
- середа
|
30
|
+
- четвер
|
31
|
+
- п'ятниця
|
32
|
+
- субота
|
33
|
+
formats:
|
34
|
+
default: ! '%d.%m.%Y'
|
35
|
+
long: ! '%d %B %Y'
|
36
|
+
short: ! '%d %b'
|
37
|
+
month_names:
|
38
|
+
-
|
39
|
+
- Січня
|
40
|
+
- Лютого
|
41
|
+
- Березня
|
42
|
+
- Квітня
|
43
|
+
- Травня
|
44
|
+
- Червня
|
45
|
+
- Липня
|
46
|
+
- Серпня
|
47
|
+
- Вересня
|
48
|
+
- Жовтня
|
49
|
+
- Листопада
|
50
|
+
- Грудня
|
51
|
+
order:
|
52
|
+
- :day
|
53
|
+
- :month
|
54
|
+
- :year
|
55
|
+
datetime:
|
56
|
+
distance_in_words:
|
57
|
+
about_x_hours:
|
58
|
+
few: близько %{count} години
|
59
|
+
many: близько %{count} годин
|
60
|
+
one: близько %{count} година
|
61
|
+
other: близько %{count} години
|
62
|
+
about_x_months:
|
63
|
+
few: близько %{count} місяців
|
64
|
+
many: близько %{count} місяців
|
65
|
+
one: близько %{count} місяця
|
66
|
+
other: близько %{count} місяця
|
67
|
+
about_x_years:
|
68
|
+
few: близько %{count} років
|
69
|
+
many: близько %{count} років
|
70
|
+
one: близько %{count} року
|
71
|
+
other: близько %{count} року
|
72
|
+
almost_x_years:
|
73
|
+
few: майже %{count} років
|
74
|
+
many: майже %{count} років
|
75
|
+
one: майже %{count} роки
|
76
|
+
other: майже %{count} років
|
77
|
+
half_a_minute: півхвилини
|
78
|
+
less_than_x_minutes:
|
79
|
+
few: менше %{count} хвилин
|
80
|
+
many: менше %{count} хвилин
|
81
|
+
one: менше %{count} хвилини
|
82
|
+
other: менше %{count} хвилини
|
83
|
+
less_than_x_seconds:
|
84
|
+
few: менше %{count} секунд
|
85
|
+
many: менше %{count} секунд
|
86
|
+
one: менше %{count} секунди
|
87
|
+
other: менше %{count} секунди
|
88
|
+
over_x_years:
|
89
|
+
few: більше %{count} років
|
90
|
+
many: більше %{count} років
|
91
|
+
one: більше %{count} року
|
92
|
+
other: більше %{count} року
|
93
|
+
x_days:
|
94
|
+
few: ! '%{count} дні'
|
95
|
+
many: ! '%{count} днів'
|
96
|
+
one: ! '%{count} день'
|
97
|
+
other: ! '%{count} дня'
|
98
|
+
x_minutes:
|
99
|
+
few: ! '%{count} хвилини'
|
100
|
+
many: ! '%{count} хвилин'
|
101
|
+
one: ! '%{count} хвилина'
|
102
|
+
other: ! '%{count} хвилини'
|
103
|
+
x_months:
|
104
|
+
few: ! '%{count} місяці'
|
105
|
+
many: ! '%{count} місяців'
|
106
|
+
one: ! '%{count} місяць'
|
107
|
+
other: ! '%{count} місяця'
|
108
|
+
x_seconds:
|
109
|
+
few: ! '%{count} секунди'
|
110
|
+
many: ! '%{count} секунд'
|
111
|
+
one: ! '%{count} секунда'
|
112
|
+
other: ! '%{count} секунди'
|
113
|
+
prompts:
|
114
|
+
day: День
|
115
|
+
hour: Година
|
116
|
+
minute: Хвилина
|
117
|
+
month: Місяць
|
118
|
+
second: Секунда
|
119
|
+
year: Рік
|
120
|
+
errors:
|
121
|
+
format: ! '%{attribute} %{message}'
|
122
|
+
messages:
|
123
|
+
accepted: має бути прийнятий
|
124
|
+
blank: не може бути пустим
|
125
|
+
confirmation: не збігається з підтвердженням
|
126
|
+
empty: не може бути порожнім
|
127
|
+
equal_to: має дорівнювати %{count}
|
128
|
+
even: має бути парним
|
129
|
+
exclusion: зарезервовано
|
130
|
+
greater_than: має бути більше ніж %{count}
|
131
|
+
greater_than_or_equal_to: має бути більше ніж або дорівнювати %{count}
|
132
|
+
inclusion: не включено до переліку
|
133
|
+
invalid: недійсний
|
134
|
+
less_than: має бути менше ніж %{count}
|
135
|
+
less_than_or_equal_to: має бути менше ніж або дорівнювати %{count}
|
136
|
+
not_a_number: не число
|
137
|
+
not_an_integer: не э цілим числом
|
138
|
+
odd: має бути непарним
|
139
|
+
record_invalid: ! 'Виникли помилки: %{errors}'
|
140
|
+
taken: вже зайнятий
|
141
|
+
too_long:
|
142
|
+
few: занадто довгий (максимум %{count} знаки)
|
143
|
+
many: занадто довгий (максимум %{count} знаків)
|
144
|
+
one: занадто довгий (максимум %{count} знак)
|
145
|
+
other: занадто довгий (максимум %{count} знаку)
|
146
|
+
too_short:
|
147
|
+
few: занадто короткий (мінімум %{count} знаки)
|
148
|
+
many: занадто короткий (мінімум %{count} знаків)
|
149
|
+
one: занадто короткий (мінімум %{count} знак)
|
150
|
+
other: занадто короткий (мінімум %{count} знаку)
|
151
|
+
wrong_length:
|
152
|
+
few: неправильна довжина (має бути %{count} знаки)
|
153
|
+
many: неправильна довжина (має бути %{count} знаків)
|
154
|
+
one: неправильна довжина (має бути %{count} знак)
|
155
|
+
other: неправильна довжина (має бути %{count} знаку)
|
156
|
+
template:
|
157
|
+
body: ! 'Помилки виявлено в таких полях:'
|
158
|
+
header:
|
159
|
+
few: ! '%{model} не збережено через %{count} помилки'
|
160
|
+
many: ! '%{model} не збережено через %{count} помилок'
|
161
|
+
one: ! '%{model} не збережено через %{count} помилку'
|
162
|
+
other: ! '%{model} не збережено через %{count} помилки'
|
163
|
+
helpers:
|
164
|
+
select:
|
165
|
+
prompt: ! 'Оберіть: '
|
166
|
+
submit:
|
167
|
+
create: Створити %{model}
|
168
|
+
submit: Зберегти %{model}
|
169
|
+
update: Зберегти %{model}
|
170
|
+
number:
|
171
|
+
currency:
|
172
|
+
format:
|
173
|
+
delimiter: ! ' '
|
174
|
+
format: ! '%n %u'
|
175
|
+
precision: 2
|
176
|
+
separator: ! ','
|
177
|
+
significant: false
|
178
|
+
strip_insignificant_zeros: false
|
179
|
+
unit: грн.
|
180
|
+
format:
|
181
|
+
delimiter: ! ' '
|
182
|
+
precision: 3
|
183
|
+
separator: ! ','
|
184
|
+
significant: false
|
185
|
+
strip_insignificant_zeros: false
|
186
|
+
human:
|
187
|
+
decimal_units:
|
188
|
+
format: ! '%n %u'
|
189
|
+
units:
|
190
|
+
billion:
|
191
|
+
few: Мільярдів
|
192
|
+
many: Мільярдів
|
193
|
+
one: Мільярд
|
194
|
+
other: Мільярдів
|
195
|
+
million:
|
196
|
+
few: Мільйонів
|
197
|
+
many: Мільйонів
|
198
|
+
one: Мільйон
|
199
|
+
other: Мільйонів
|
200
|
+
quadrillion:
|
201
|
+
few: Квадрильйонів
|
202
|
+
many: Квадрильйонів
|
203
|
+
one: Кквадрильйон
|
204
|
+
other: Квадрильйонів
|
205
|
+
thousand:
|
206
|
+
few: Тисяч
|
207
|
+
many: Тисяч
|
208
|
+
one: Тисяча
|
209
|
+
other: Тисяч
|
210
|
+
trillion:
|
211
|
+
few: Трильйонів
|
212
|
+
many: Трильйонів
|
213
|
+
one: Трильйон
|
214
|
+
other: Трильйонів
|
215
|
+
unit: ''
|
216
|
+
format:
|
217
|
+
delimiter: ''
|
218
|
+
precision: 1
|
219
|
+
significant: false
|
220
|
+
strip_insignificant_zeros: false
|
221
|
+
storage_units:
|
222
|
+
format: ! '%n %u'
|
223
|
+
units:
|
224
|
+
byte:
|
225
|
+
few: байти
|
226
|
+
many: байтів
|
227
|
+
one: байт
|
228
|
+
other: байту
|
229
|
+
gb: ГБ
|
230
|
+
kb: кБ
|
231
|
+
mb: МБ
|
232
|
+
tb: ТБ
|
233
|
+
percentage:
|
234
|
+
format:
|
235
|
+
precision: 0
|
236
|
+
delimiter: ''
|
237
|
+
precision:
|
238
|
+
format:
|
239
|
+
precision: 2
|
240
|
+
delimiter: ''
|
241
|
+
support:
|
242
|
+
array:
|
243
|
+
last_word_connector: ! ' та '
|
244
|
+
two_words_connector: ! ' і '
|
245
|
+
words_connector: ! ', '
|
246
|
+
time:
|
247
|
+
am: до полудня
|
248
|
+
formats:
|
249
|
+
default: ! '%a, %d %b %Y, %H:%M:%S %z'
|
250
|
+
long: ! '%d %B %Y, %H:%M'
|
251
|
+
short: ! '%d %b, %H:%M'
|
252
|
+
pm: по полудні
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class HelpersTest < ActionView::TestCase
|
4
|
+
def test_number_with_delimiter
|
5
|
+
assert_equal "1 240,503", number_with_delimiter(1240.503)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_number_to_currency
|
9
|
+
assert_equal "1 240,50 грн.", number_to_currency(1240.503, unit: "грн.")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_number_to_percentage
|
13
|
+
assert_equal "90%", number_to_percentage(90)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_number_with_precision
|
17
|
+
assert_equal "123,45", number_with_precision(123.45334)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_number_to_human
|
21
|
+
assert_equal "123,5 Тисяч", number_to_human(123456.45334)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_number_to_human_size
|
25
|
+
assert_equal "795 байтів", number_to_human_size(795)
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup
|
29
|
+
@locale = I18n.locale
|
30
|
+
I18n.locale = :uk
|
31
|
+
end
|
32
|
+
|
33
|
+
def teardown
|
34
|
+
I18n.locale = @locale
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Rails setup is heavily based on https://github.com/semaperepelitsa/subdomain_locale
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
7
|
+
require "minitest/autorun"
|
8
|
+
require "rails/test_help"
|
9
|
+
Rails.backtrace_cleaner.remove_silencers!
|
10
|
+
|
11
|
+
$VERBOSE = true
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class HelloControllerTest < ActionController::TestCase
|
4
|
+
def body
|
5
|
+
response.body.chomp
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_translate
|
9
|
+
get :translate
|
10
|
+
assert_equal "Hi!", body
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_locale_option
|
14
|
+
get :locale_option
|
15
|
+
assert_equal "Привіт", body
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_missing_translation
|
19
|
+
get :missing_translation
|
20
|
+
assert_equal '<span class="translation_missing" title="translation missing: en.missing">Missing</span>', body
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_partial_scope
|
24
|
+
get :partial_scope
|
25
|
+
assert_equal "Hello, Rails!", body
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_html_safe_underscored
|
29
|
+
get :html_safe_underscored
|
30
|
+
assert_equal "<span>No escaping</span>", body
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_html_safe_key
|
34
|
+
get :html_safe_key
|
35
|
+
assert_equal "<span>No escaping</span>", body
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_html_unsafe
|
39
|
+
get :html_unsafe
|
40
|
+
assert_equal "<span>No escaping?</span>", body
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_raise_error
|
44
|
+
assert_raises(ActionView::Template::Error) { get :raise_error }
|
45
|
+
end
|
46
|
+
|
47
|
+
this = self
|
48
|
+
Dummy::Application.routes.draw do
|
49
|
+
this.instance_methods(false).grep(/^test_/).each do |method|
|
50
|
+
route = method[/^test_(.+)$/, 1]
|
51
|
+
get route => "hello##{route}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|