russian 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +24 -0
- data/README.textile +3 -3
- data/Rakefile +3 -3
- data/lib/russian.rb +77 -77
- data/lib/russian/active_support_ext/parameterize.rb +5 -0
- data/lib/russian/backend/advanced.rb +2 -2
- data/lib/russian/locale/actionview.yml +1 -1
- data/lib/russian/locale/activerecord.yml +1 -1
- data/lib/russian/locale/activesupport.yml +1 -1
- data/lib/russian/locale/datetime.yml +1 -1
- data/lib/russian/locale/pluralize.rb +1 -1
- data/lib/russian/transliteration.rb +4 -0
- data/lib/vendor/i18n/Rakefile +5 -0
- data/lib/vendor/i18n/i18n.gemspec +4 -4
- data/lib/vendor/i18n/lib/i18n.rb +3 -3
- data/lib/vendor/i18n/test/i18n_exceptions_test.rb +10 -10
- data/lib/vendor/i18n/test/i18n_test.rb +18 -18
- data/lib/vendor/i18n/test/locale/en.rb +1 -0
- data/lib/vendor/i18n/test/locale/en.yml +3 -0
- data/lib/vendor/i18n/test/simple_backend_test.rb +70 -70
- data/spec/fixtures/{en-US.yml → en.yml} +1 -1
- data/spec/i18n/locale/pluralization_spec.rb +12 -12
- data/spec/locale_spec.rb +1 -0
- data/spec/russian_spec.rb +7 -7
- data/spec/transliteration_spec.rb +1 -1
- metadata +7 -4
- data/lib/vendor/i18n/test/locale/en-US.rb +0 -1
- data/lib/vendor/i18n/test/locale/en-US.yml +0 -3
data/CHANGELOG
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
=== 0.0.9 - 21.11.2008
|
2
|
+
|
3
|
+
* Updated I18n gem due to locale changes (0.1.1)
|
4
|
+
* NB! I18n changed default locale from :'en-US' to :'en', same recommended for other locales by default
|
5
|
+
* NB!! Russian locale is now :'ru' NOT :'ru-RU', update your locale files.
|
6
|
+
|
7
|
+
* I18n gem обновился до 0.1.1 в связи с изменениями в названиях локалей
|
8
|
+
* ВНИМАНИЕ: локаль по умолчанию I18n теперь называется не :'en-US' а :'en', такой же способ именования рекомендуется и для других локалей
|
9
|
+
* ВНИМАНИЕ! Локаль русского языка теперь называется :'ru' а не :'ru-RU'. Не забудьте обновить ваши файлы переводов.
|
10
|
+
|
11
|
+
=== 0.0.8 - 20.11.2008
|
12
|
+
|
13
|
+
* Introduce transliteration (Russian.translit, Russian.transliterate)
|
14
|
+
* Add an ActiveSupport hack for #parameterize
|
15
|
+
|
16
|
+
* Добавилась поддержка транслитерации (Russian.translit, Russian.transliterate)
|
17
|
+
* Добавился хак для #parameterize ActiveSupport (генерация "красивых" URL)
|
18
|
+
|
19
|
+
=== 0.0.7 - 09.11.2008
|
20
|
+
|
21
|
+
* Updated I18n gem
|
22
|
+
|
23
|
+
* Новая версия gem I18n
|
24
|
+
|
data/README.textile
CHANGED
@@ -89,7 +89,7 @@ h1. Использование
|
|
89
89
|
При инициализации:
|
90
90
|
|
91
91
|
* заменяется бэкэнд I18n со стандартного на собственный бекэнд Russian (@I18n::Backend::Advanced@)
|
92
|
-
* _NB:_ локаль русского языка (
|
92
|
+
* _NB:_ локаль русского языка (@:'ru'@) становится локалью по умолчанию
|
93
93
|
* загружаются все файлы переводов, в том числе переводы для Rails.
|
94
94
|
|
95
95
|
После этого можно использовать все стандартные функции библиотеки I18n, пользоваться измененным функционалом для лучшей поддержки русского языка, или использовать хелперы модуля Russian для еще более простой работы с русским языком.
|
@@ -125,7 +125,7 @@ Russian.locale
|
|
125
125
|
Russian::LOCALE
|
126
126
|
</code></pre>
|
127
127
|
|
128
|
-
-- возвращает локаль русского языка (@:'ru
|
128
|
+
-- возвращает локаль русского языка (@:'ru'@).
|
129
129
|
|
130
130
|
<pre><code>
|
131
131
|
Russian::i18n_backend_class
|
@@ -210,7 +210,7 @@ h3. Хелперы
|
|
210
210
|
* в файле переводов:
|
211
211
|
|
212
212
|
<pre><code>
|
213
|
-
ru
|
213
|
+
ru:
|
214
214
|
activerecord:
|
215
215
|
attributes:
|
216
216
|
user:
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rubygems/specification'
|
|
5
5
|
require 'date'
|
6
6
|
|
7
7
|
GEM = "russian"
|
8
|
-
GEM_VERSION = "0.0.
|
8
|
+
GEM_VERSION = "0.0.9"
|
9
9
|
AUTHOR = "Yaroslav Markin"
|
10
10
|
EMAIL = "yaroslav@markin.net"
|
11
11
|
HOMEPAGE = "http://github.com/yaroslav/russian/"
|
@@ -16,7 +16,7 @@ spec = Gem::Specification.new do |s|
|
|
16
16
|
s.version = GEM_VERSION
|
17
17
|
s.platform = Gem::Platform::RUBY
|
18
18
|
s.has_rdoc = true
|
19
|
-
s.extra_rdoc_files = ["README.textile", "LICENSE",
|
19
|
+
s.extra_rdoc_files = ["README.textile", "LICENSE", "CHANGELOG", "TODO"]
|
20
20
|
s.summary = SUMMARY
|
21
21
|
s.description = s.summary
|
22
22
|
s.author = AUTHOR
|
@@ -28,7 +28,7 @@ spec = Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.require_path = 'lib'
|
30
30
|
s.autorequire = GEM
|
31
|
-
s.files = %w(LICENSE README.textile Rakefile TODO init.rb) + Dir.glob("{lib,spec}/**/*")
|
31
|
+
s.files = %w(LICENSE README.textile Rakefile CHANGELOG TODO init.rb) + Dir.glob("{lib,spec}/**/*")
|
32
32
|
end
|
33
33
|
|
34
34
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/lib/russian.rb
CHANGED
@@ -20,96 +20,96 @@ end
|
|
20
20
|
require 'active_support_ext/parameterize' if defined?(ActiveSupport::Inflector)
|
21
21
|
|
22
22
|
module Russian
|
23
|
+
extend self
|
24
|
+
|
23
25
|
module VERSION
|
24
26
|
MAJOR = 0
|
25
27
|
MINOR = 0
|
26
|
-
TINY =
|
28
|
+
TINY = 9
|
27
29
|
|
28
30
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
29
31
|
end
|
30
32
|
|
31
33
|
# Russian locale
|
32
|
-
LOCALE = :'ru
|
34
|
+
LOCALE = :'ru'
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns custom backend class for usage with Russian library
|
41
|
-
#
|
42
|
-
# See I18n::Backend
|
43
|
-
def i18n_backend_class
|
44
|
-
I18n::Backend::Advanced
|
45
|
-
end
|
46
|
-
|
47
|
-
# Init Russian i18n: set custom backend, set default locale to Russian locale, load all translations
|
48
|
-
# shipped with library.
|
49
|
-
def init_i18n
|
50
|
-
I18n.backend = Russian.i18n_backend_class.new
|
51
|
-
I18n.default_locale = LOCALE
|
52
|
-
locale_files.each { |file| I18n.load_path << file }
|
53
|
-
end
|
36
|
+
# Russian locale
|
37
|
+
def locale
|
38
|
+
LOCALE
|
39
|
+
end
|
54
40
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
41
|
+
# Returns custom backend class for usage with Russian library
|
42
|
+
#
|
43
|
+
# See I18n::Backend
|
44
|
+
def i18n_backend_class
|
45
|
+
I18n::Backend::Advanced
|
46
|
+
end
|
47
|
+
|
48
|
+
# Init Russian i18n: set custom backend, set default locale to Russian locale, load all translations
|
49
|
+
# shipped with library.
|
50
|
+
def init_i18n
|
51
|
+
I18n.backend = Russian.i18n_backend_class.new
|
52
|
+
I18n.default_locale = LOCALE
|
53
|
+
locale_files.each { |file| I18n.load_path << file }
|
54
|
+
end
|
55
|
+
|
56
|
+
# See I18n::translate
|
57
|
+
def translate(key, options = {})
|
58
|
+
I18n.translate(key, options.merge({ :locale => LOCALE }))
|
59
|
+
end
|
60
|
+
alias :t :translate
|
61
|
+
|
62
|
+
# See I18n::localize
|
63
|
+
def localize(object, options = {})
|
64
|
+
I18n.localize(object, options.merge({ :locale => LOCALE }))
|
65
|
+
end
|
66
|
+
alias :l :localize
|
67
|
+
|
68
|
+
# strftime() proxy with Russian localization
|
69
|
+
def strftime(object, format = :default)
|
70
|
+
localize(object, { :format => format })
|
71
|
+
end
|
72
|
+
|
73
|
+
# Simple pluralization proxy
|
74
|
+
#
|
75
|
+
# Usage:
|
76
|
+
# Russian.pluralize(1, "вещь", "вещи", "вещей")
|
77
|
+
# Russian.pluralize(3.14, "вещь", "вещи", "вещей", "вещи")
|
78
|
+
def pluralize(n, *variants)
|
79
|
+
raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric)
|
80
|
+
raise ArgumentError, "Must have at least 3 variants for pluralization" if variants.size < 3
|
81
|
+
raise ArgumentError, "Must have at least 4 variants for pluralization" if (variants.size < 4 && n != n.round)
|
82
|
+
variants_hash = pluralization_variants_to_hash(*variants)
|
83
|
+
I18n.backend.send(:pluralize, LOCALE, variants_hash, n)
|
84
|
+
end
|
85
|
+
alias :p :pluralize
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
87
|
+
# Transliteration for russian language
|
88
|
+
#
|
89
|
+
# Usage:
|
90
|
+
# Russian.translit("рубин")
|
91
|
+
# Russian.transliterate("рубин")
|
92
|
+
def transliterate(str)
|
93
|
+
Russian::Transliteration.transliterate(str)
|
94
|
+
end
|
95
|
+
alias :translit :transliterate
|
96
|
+
|
97
|
+
protected
|
98
|
+
# Returns all locale files shipped with library
|
99
|
+
def locale_files
|
100
|
+
Dir[File.join(File.dirname(__FILE__), "russian", "locale", "**/*")]
|
93
101
|
end
|
94
|
-
alias :translit :transliterate
|
95
102
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
:one => variants[0],
|
107
|
-
:few => variants[1],
|
108
|
-
:many => variants[2],
|
109
|
-
:other => variants[3]
|
110
|
-
}
|
111
|
-
end
|
112
|
-
end
|
103
|
+
# Converts an array of pluralization variants to a Hash that can be used
|
104
|
+
# with I18n pluralization.
|
105
|
+
def pluralization_variants_to_hash(*variants)
|
106
|
+
{
|
107
|
+
:one => variants[0],
|
108
|
+
:few => variants[1],
|
109
|
+
:many => variants[2],
|
110
|
+
:other => variants[3]
|
111
|
+
}
|
112
|
+
end
|
113
113
|
end
|
114
114
|
|
115
115
|
Russian.init_i18n
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module ActiveSupport
|
2
2
|
module Inflector
|
3
3
|
# Replaces special characters in a string so that it may be used as part of a 'pretty' URL.
|
4
|
+
# Transliterates all russian characters in string first, then passes it to ActiveSupport Inflector.
|
5
|
+
#
|
6
|
+
# Заменяет все спецсимволы в строке так, что результат может использоваться как часть "красивого" URL.
|
7
|
+
# От стандартного ActiveSupport Inflector отличается тем, что сначала производится транслитерация
|
8
|
+
# букв русского алфавита.
|
4
9
|
#
|
5
10
|
# ==== Examples
|
6
11
|
#
|
@@ -83,7 +83,7 @@ module I18n
|
|
83
83
|
#
|
84
84
|
# Пример задания правила в таблице переводов:
|
85
85
|
#
|
86
|
-
# store_translations :'en
|
86
|
+
# store_translations :'en', {
|
87
87
|
# :pluralize => lambda { |n| n == 1 ? :one : :other }
|
88
88
|
# }
|
89
89
|
#
|
@@ -97,7 +97,7 @@ module I18n
|
|
97
97
|
# This is how pluralization rules are defined in translation tables, English
|
98
98
|
# language for example:
|
99
99
|
#
|
100
|
-
# store_translations :'en
|
100
|
+
# store_translations :'en', {
|
101
101
|
# :pluralize => lambda { |n| n == 1 ? :one : :other }
|
102
102
|
# }
|
103
103
|
#
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Russian
|
2
2
|
# Russian transliteration
|
3
|
+
#
|
4
|
+
# Транслитерация для букв русского алфавита
|
3
5
|
module Transliteration
|
4
6
|
extend self
|
5
7
|
|
@@ -30,6 +32,8 @@ module Russian
|
|
30
32
|
}.freeze
|
31
33
|
|
32
34
|
# Transliterate a string with russian characters
|
35
|
+
#
|
36
|
+
# Возвращает строку, в которой все буквы русского алфавита заменены на похожую по звучанию латиницу
|
33
37
|
def transliterate(str)
|
34
38
|
chars = str.split(//)
|
35
39
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "i18n"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.1"
|
4
4
|
s.date = "2008-10-26"
|
5
5
|
s.summary = "Internationalization support for Ruby"
|
6
6
|
s.email = "rails-i18n@googlegroups.com"
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
'test/all.rb',
|
21
21
|
'test/i18n_exceptions_test.rb',
|
22
22
|
'test/i18n_test.rb',
|
23
|
-
'test/locale/en
|
24
|
-
'test/locale/en
|
23
|
+
'test/locale/en.rb',
|
24
|
+
'test/locale/en.yml',
|
25
25
|
'test/simple_backend_test.rb'
|
26
26
|
]
|
27
|
-
end
|
27
|
+
end
|
data/lib/vendor/i18n/lib/i18n.rb
CHANGED
@@ -11,7 +11,7 @@ require 'i18n/exceptions'
|
|
11
11
|
module I18n
|
12
12
|
@@backend = nil
|
13
13
|
@@load_path = nil
|
14
|
-
@@default_locale = :'en
|
14
|
+
@@default_locale = :'en'
|
15
15
|
@@exception_handler = :default_exception_handler
|
16
16
|
|
17
17
|
class << self
|
@@ -25,7 +25,7 @@ module I18n
|
|
25
25
|
@@backend = backend
|
26
26
|
end
|
27
27
|
|
28
|
-
# Returns the current default locale. Defaults to 'en
|
28
|
+
# Returns the current default locale. Defaults to :'en'
|
29
29
|
def default_locale
|
30
30
|
@@default_locale
|
31
31
|
end
|
@@ -57,7 +57,7 @@ module I18n
|
|
57
57
|
# files which are either named *.rb and contain plain Ruby Hashes or are
|
58
58
|
# named *.yml and contain YAML data. So for the SimpleBackend clients may
|
59
59
|
# register translation files like this:
|
60
|
-
# I18n.load_path << 'path/to/locale/en
|
60
|
+
# I18n.load_path << 'path/to/locale/en.yml'
|
61
61
|
def load_path
|
62
62
|
@@load_path ||= []
|
63
63
|
end
|
@@ -23,7 +23,7 @@ class I18nExceptionsTest < Test::Unit::TestCase
|
|
23
23
|
force_missing_translation_data
|
24
24
|
rescue I18n::ArgumentError => e
|
25
25
|
options = {:scope => :bar}
|
26
|
-
assert_equal 'de
|
26
|
+
assert_equal 'de', e.locale
|
27
27
|
assert_equal :foo, e.key
|
28
28
|
assert_equal options, e.options
|
29
29
|
end
|
@@ -31,7 +31,7 @@ class I18nExceptionsTest < Test::Unit::TestCase
|
|
31
31
|
def test_missing_translation_data_message
|
32
32
|
force_missing_translation_data
|
33
33
|
rescue I18n::ArgumentError => e
|
34
|
-
assert_equal 'translation missing: de
|
34
|
+
assert_equal 'translation missing: de, bar, foo', e.message
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_invalid_pluralization_data_stores_entry_and_count
|
@@ -79,22 +79,22 @@ class I18nExceptionsTest < Test::Unit::TestCase
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def force_missing_translation_data
|
82
|
-
I18n.backend.store_translations 'de
|
83
|
-
I18n.backend.translate 'de
|
82
|
+
I18n.backend.store_translations 'de', :bar => nil
|
83
|
+
I18n.backend.translate 'de', :foo, :scope => :bar
|
84
84
|
end
|
85
85
|
|
86
86
|
def force_invalid_pluralization_data
|
87
|
-
I18n.backend.store_translations 'de
|
88
|
-
I18n.backend.translate 'de
|
87
|
+
I18n.backend.store_translations 'de', :foo => [:bar]
|
88
|
+
I18n.backend.translate 'de', :foo, :count => 1
|
89
89
|
end
|
90
90
|
|
91
91
|
def force_missing_interpolation_argument
|
92
|
-
I18n.backend.store_translations 'de
|
93
|
-
I18n.backend.translate 'de
|
92
|
+
I18n.backend.store_translations 'de', :foo => "{{bar}}"
|
93
|
+
I18n.backend.translate 'de', :foo, :baz => 'baz'
|
94
94
|
end
|
95
95
|
|
96
96
|
def force_reserved_interpolation_key
|
97
|
-
I18n.backend.store_translations 'de
|
98
|
-
I18n.backend.translate 'de
|
97
|
+
I18n.backend.store_translations 'de', :foo => "{{scope}}"
|
98
|
+
I18n.backend.translate 'de', :foo, :baz => 'baz'
|
99
99
|
end
|
100
100
|
end
|
@@ -8,7 +8,7 @@ require 'active_support'
|
|
8
8
|
|
9
9
|
class I18nTest < Test::Unit::TestCase
|
10
10
|
def setup
|
11
|
-
I18n.backend.store_translations :'en
|
11
|
+
I18n.backend.store_translations :'en', {
|
12
12
|
:currency => {
|
13
13
|
:format => {
|
14
14
|
:separator => '.',
|
@@ -29,13 +29,13 @@ class I18nTest < Test::Unit::TestCase
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_uses_en_us_as_default_locale_by_default
|
32
|
-
assert_equal 'en
|
32
|
+
assert_equal 'en', I18n.default_locale
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_can_set_default_locale
|
36
|
-
assert_nothing_raised{ I18n.default_locale = 'de
|
37
|
-
assert_equal 'de
|
38
|
-
I18n.default_locale = 'en
|
36
|
+
assert_nothing_raised{ I18n.default_locale = 'de' }
|
37
|
+
assert_equal 'de', I18n.default_locale
|
38
|
+
I18n.default_locale = 'en'
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_uses_default_locale_as_locale_by_default
|
@@ -43,10 +43,10 @@ class I18nTest < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_can_set_locale_to_thread_current
|
46
|
-
assert_nothing_raised{ I18n.locale = 'de
|
47
|
-
assert_equal 'de
|
48
|
-
assert_equal 'de
|
49
|
-
I18n.locale = 'en
|
46
|
+
assert_nothing_raised{ I18n.locale = 'de' }
|
47
|
+
assert_equal 'de', I18n.locale
|
48
|
+
assert_equal 'de', Thread.current[:locale]
|
49
|
+
I18n.locale = 'en'
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_can_set_exception_handler
|
@@ -62,17 +62,17 @@ class I18nTest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_delegates_translate_to_backend
|
65
|
-
I18n.backend.expects(:translate).with 'de
|
66
|
-
I18n.translate :foo, :locale => 'de
|
65
|
+
I18n.backend.expects(:translate).with 'de', :foo, {}
|
66
|
+
I18n.translate :foo, :locale => 'de'
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_delegates_localize_to_backend
|
70
|
-
I18n.backend.expects(:localize).with 'de
|
71
|
-
I18n.localize :whatever, :locale => 'de
|
70
|
+
I18n.backend.expects(:localize).with 'de', :whatever, :default
|
71
|
+
I18n.localize :whatever, :locale => 'de'
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_translate_given_no_locale_uses_i18n_locale
|
75
|
-
I18n.backend.expects(:translate).with 'en
|
75
|
+
I18n.backend.expects(:translate).with 'en', :foo, {}
|
76
76
|
I18n.translate :foo
|
77
77
|
end
|
78
78
|
|
@@ -101,18 +101,18 @@ class I18nTest < Test::Unit::TestCase
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_translate_with_options_using_scope_works
|
104
|
-
I18n.backend.expects(:translate).with('de
|
105
|
-
I18n.with_options :locale => 'de
|
104
|
+
I18n.backend.expects(:translate).with('de', :precision, :scope => :"currency.format")
|
105
|
+
I18n.with_options :locale => 'de', :scope => :'currency.format' do |locale|
|
106
106
|
locale.t :precision
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
110
|
# def test_translate_given_no_args_raises_missing_translation_data
|
111
|
-
# assert_equal "translation missing: en
|
111
|
+
# assert_equal "translation missing: en, no key", I18n.t
|
112
112
|
# end
|
113
113
|
|
114
114
|
def test_translate_given_a_bogus_key_raises_missing_translation_data
|
115
|
-
assert_equal "translation missing: en
|
115
|
+
assert_equal "translation missing: en, bogus", I18n.t(:bogus)
|
116
116
|
end
|
117
117
|
|
118
118
|
def test_localize_nil_raises_argument_error
|
@@ -0,0 +1 @@
|
|
1
|
+
{:'en-Ruby' => {:foo => {:bar => "baz"}}}
|
@@ -12,7 +12,7 @@ module I18nSimpleBackendTestSetup
|
|
12
12
|
def setup_backend
|
13
13
|
# backend_reset_translations!
|
14
14
|
@backend = I18n::Backend::Simple.new
|
15
|
-
@backend.store_translations 'en
|
15
|
+
@backend.store_translations 'en', :foo => {:bar => 'bar', :baz => 'baz'}
|
16
16
|
@locale_dir = File.dirname(__FILE__) + '/locale'
|
17
17
|
end
|
18
18
|
alias :setup :setup_backend
|
@@ -27,7 +27,7 @@ module I18nSimpleBackendTestSetup
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def add_datetime_translations
|
30
|
-
@backend.store_translations :'de
|
30
|
+
@backend.store_translations :'de', {
|
31
31
|
:date => {
|
32
32
|
:formats => {
|
33
33
|
:default => "%d.%m.%Y",
|
@@ -102,25 +102,25 @@ class I18nSimpleBackendTranslationsTest < Test::Unit::TestCase
|
|
102
102
|
include I18nSimpleBackendTestSetup
|
103
103
|
|
104
104
|
def test_store_translations_adds_translations # no, really :-)
|
105
|
-
@backend.store_translations :'en
|
106
|
-
assert_equal Hash[:'en
|
105
|
+
@backend.store_translations :'en', :foo => 'bar'
|
106
|
+
assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
|
107
107
|
end
|
108
108
|
|
109
109
|
def test_store_translations_deep_merges_translations
|
110
|
-
@backend.store_translations :'en
|
111
|
-
@backend.store_translations :'en
|
112
|
-
assert_equal Hash[:'en
|
110
|
+
@backend.store_translations :'en', :foo => {:bar => 'bar'}
|
111
|
+
@backend.store_translations :'en', :foo => {:baz => 'baz'}
|
112
|
+
assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
|
113
113
|
end
|
114
114
|
|
115
115
|
def test_store_translations_forces_locale_to_sym
|
116
|
-
@backend.store_translations 'en
|
117
|
-
assert_equal Hash[:'en
|
116
|
+
@backend.store_translations 'en', :foo => 'bar'
|
117
|
+
assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_store_translations_converts_keys_to_symbols
|
121
121
|
# backend_reset_translations!
|
122
|
-
@backend.store_translations 'en
|
123
|
-
assert_equal Hash[:'en
|
122
|
+
@backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
|
123
|
+
assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -128,45 +128,45 @@ class I18nSimpleBackendTranslateTest < Test::Unit::TestCase
|
|
128
128
|
include I18nSimpleBackendTestSetup
|
129
129
|
|
130
130
|
def test_translate_calls_lookup_with_locale_given
|
131
|
-
@backend.expects(:lookup).with('de
|
132
|
-
@backend.translate 'de
|
131
|
+
@backend.expects(:lookup).with('de', :bar, [:foo]).returns 'bar'
|
132
|
+
@backend.translate 'de', :bar, :scope => [:foo]
|
133
133
|
end
|
134
134
|
|
135
135
|
def test_given_no_keys_it_returns_the_default
|
136
|
-
assert_equal 'default', @backend.translate('en
|
136
|
+
assert_equal 'default', @backend.translate('en', nil, :default => 'default')
|
137
137
|
end
|
138
138
|
|
139
139
|
def test_translate_given_a_symbol_as_a_default_translates_the_symbol
|
140
|
-
assert_equal 'bar', @backend.translate('en
|
140
|
+
assert_equal 'bar', @backend.translate('en', nil, :scope => [:foo], :default => :bar)
|
141
141
|
end
|
142
142
|
|
143
143
|
def test_translate_given_an_array_as_default_uses_the_first_match
|
144
|
-
assert_equal 'bar', @backend.translate('en
|
144
|
+
assert_equal 'bar', @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar])
|
145
145
|
end
|
146
146
|
|
147
147
|
def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data
|
148
148
|
assert_raises I18n::MissingTranslationData do
|
149
|
-
@backend.translate('en
|
149
|
+
@backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3])
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_translate_an_array_of_keys_translates_all_of_them
|
154
|
-
assert_equal %w(bar baz), @backend.translate('en
|
154
|
+
assert_equal %w(bar baz), @backend.translate('en', [:bar, :baz], :scope => [:foo])
|
155
155
|
end
|
156
156
|
|
157
157
|
def test_translate_calls_pluralize
|
158
|
-
@backend.expects(:pluralize).with 'en
|
159
|
-
@backend.translate 'en
|
158
|
+
@backend.expects(:pluralize).with 'en', 'bar', 1
|
159
|
+
@backend.translate 'en', :bar, :scope => [:foo], :count => 1
|
160
160
|
end
|
161
161
|
|
162
162
|
def test_translate_calls_interpolate
|
163
|
-
@backend.expects(:interpolate).with 'en
|
164
|
-
@backend.translate 'en
|
163
|
+
@backend.expects(:interpolate).with 'en', 'bar', {}
|
164
|
+
@backend.translate 'en', :bar, :scope => [:foo]
|
165
165
|
end
|
166
166
|
|
167
167
|
def test_translate_calls_interpolate_including_count_as_a_value
|
168
|
-
@backend.expects(:interpolate).with 'en
|
169
|
-
@backend.translate 'en
|
168
|
+
@backend.expects(:interpolate).with 'en', 'bar', {:count => 1}
|
169
|
+
@backend.translate 'en', :bar, :scope => [:foo], :count => 1
|
170
170
|
end
|
171
171
|
|
172
172
|
def test_translate_given_nil_as_a_locale_raises_an_argument_error
|
@@ -174,7 +174,7 @@ class I18nSimpleBackendTranslateTest < Test::Unit::TestCase
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def test_translate_with_a_bogus_key_and_no_default_raises_missing_translation_data
|
177
|
-
assert_raises(I18n::MissingTranslationData){ @backend.translate 'de
|
177
|
+
assert_raises(I18n::MissingTranslationData){ @backend.translate 'de', :bogus }
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -183,11 +183,11 @@ class I18nSimpleBackendLookupTest < Test::Unit::TestCase
|
|
183
183
|
|
184
184
|
# useful because this way we can use the backend with no key for interpolation/pluralization
|
185
185
|
def test_lookup_given_nil_as_a_key_returns_nil
|
186
|
-
assert_nil @backend.send(:lookup, 'en
|
186
|
+
assert_nil @backend.send(:lookup, 'en', nil)
|
187
187
|
end
|
188
188
|
|
189
189
|
def test_lookup_given_nested_keys_looks_up_a_nested_hash_value
|
190
|
-
assert_equal 'bar', @backend.send(:lookup, 'en
|
190
|
+
assert_equal 'bar', @backend.send(:lookup, 'en', :bar, [:foo])
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
@@ -274,47 +274,47 @@ class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase
|
|
274
274
|
end
|
275
275
|
|
276
276
|
def test_translate_given_the_short_format_it_uses_it
|
277
|
-
assert_equal '01. Jan', @backend.localize('de
|
277
|
+
assert_equal '01. Jan', @backend.localize('de', @date, :short)
|
278
278
|
end
|
279
279
|
|
280
280
|
def test_translate_given_the_long_format_it_uses_it
|
281
|
-
assert_equal '01. Januar 2008', @backend.localize('de
|
281
|
+
assert_equal '01. Januar 2008', @backend.localize('de', @date, :long)
|
282
282
|
end
|
283
283
|
|
284
284
|
def test_translate_given_the_default_format_it_uses_it
|
285
|
-
assert_equal '01.01.2008', @backend.localize('de
|
285
|
+
assert_equal '01.01.2008', @backend.localize('de', @date, :default)
|
286
286
|
end
|
287
287
|
|
288
288
|
def test_translate_given_a_day_name_format_it_returns_a_day_name
|
289
|
-
assert_equal 'Dienstag', @backend.localize('de
|
289
|
+
assert_equal 'Dienstag', @backend.localize('de', @date, '%A')
|
290
290
|
end
|
291
291
|
|
292
292
|
def test_translate_given_an_abbr_day_name_format_it_returns_an_abbrevated_day_name
|
293
|
-
assert_equal 'Di', @backend.localize('de
|
293
|
+
assert_equal 'Di', @backend.localize('de', @date, '%a')
|
294
294
|
end
|
295
295
|
|
296
296
|
def test_translate_given_a_month_name_format_it_returns_a_month_name
|
297
|
-
assert_equal 'Januar', @backend.localize('de
|
297
|
+
assert_equal 'Januar', @backend.localize('de', @date, '%B')
|
298
298
|
end
|
299
299
|
|
300
300
|
def test_translate_given_an_abbr_month_name_format_it_returns_an_abbrevated_month_name
|
301
|
-
assert_equal 'Jan', @backend.localize('de
|
301
|
+
assert_equal 'Jan', @backend.localize('de', @date, '%b')
|
302
302
|
end
|
303
303
|
|
304
304
|
def test_translate_given_no_format_it_does_not_fail
|
305
|
-
assert_nothing_raised{ @backend.localize 'de
|
305
|
+
assert_nothing_raised{ @backend.localize 'de', @date }
|
306
306
|
end
|
307
307
|
|
308
308
|
def test_translate_given_an_unknown_format_it_does_not_fail
|
309
|
-
assert_nothing_raised{ @backend.localize 'de
|
309
|
+
assert_nothing_raised{ @backend.localize 'de', @date, '%x' }
|
310
310
|
end
|
311
311
|
|
312
312
|
def test_localize_nil_raises_argument_error
|
313
|
-
assert_raises(I18n::ArgumentError) { @backend.localize 'de
|
313
|
+
assert_raises(I18n::ArgumentError) { @backend.localize 'de', nil }
|
314
314
|
end
|
315
315
|
|
316
316
|
def test_localize_object_raises_argument_error
|
317
|
-
assert_raises(I18n::ArgumentError) { @backend.localize 'de
|
317
|
+
assert_raises(I18n::ArgumentError) { @backend.localize 'de', Object.new }
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
@@ -329,44 +329,44 @@ class I18nSimpleBackendLocalizeDateTimeTest < Test::Unit::TestCase
|
|
329
329
|
end
|
330
330
|
|
331
331
|
def test_translate_given_the_short_format_it_uses_it
|
332
|
-
assert_equal '01. Jan 06:00', @backend.localize('de
|
332
|
+
assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short)
|
333
333
|
end
|
334
334
|
|
335
335
|
def test_translate_given_the_long_format_it_uses_it
|
336
|
-
assert_equal '01. Januar 2008 06:00', @backend.localize('de
|
336
|
+
assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long)
|
337
337
|
end
|
338
338
|
|
339
339
|
def test_translate_given_the_default_format_it_uses_it
|
340
|
-
assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de
|
340
|
+
assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default)
|
341
341
|
end
|
342
342
|
|
343
343
|
def test_translate_given_a_day_name_format_it_returns_the_correct_day_name
|
344
|
-
assert_equal 'Dienstag', @backend.localize('de
|
344
|
+
assert_equal 'Dienstag', @backend.localize('de', @morning, '%A')
|
345
345
|
end
|
346
346
|
|
347
347
|
def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
|
348
|
-
assert_equal 'Di', @backend.localize('de
|
348
|
+
assert_equal 'Di', @backend.localize('de', @morning, '%a')
|
349
349
|
end
|
350
350
|
|
351
351
|
def test_translate_given_a_month_name_format_it_returns_the_correct_month_name
|
352
|
-
assert_equal 'Januar', @backend.localize('de
|
352
|
+
assert_equal 'Januar', @backend.localize('de', @morning, '%B')
|
353
353
|
end
|
354
354
|
|
355
355
|
def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
|
356
|
-
assert_equal 'Jan', @backend.localize('de
|
356
|
+
assert_equal 'Jan', @backend.localize('de', @morning, '%b')
|
357
357
|
end
|
358
358
|
|
359
359
|
def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
|
360
|
-
assert_equal 'am', @backend.localize('de
|
361
|
-
assert_equal 'pm', @backend.localize('de
|
360
|
+
assert_equal 'am', @backend.localize('de', @morning, '%p')
|
361
|
+
assert_equal 'pm', @backend.localize('de', @evening, '%p')
|
362
362
|
end
|
363
363
|
|
364
364
|
def test_translate_given_no_format_it_does_not_fail
|
365
|
-
assert_nothing_raised{ @backend.localize 'de
|
365
|
+
assert_nothing_raised{ @backend.localize 'de', @morning }
|
366
366
|
end
|
367
367
|
|
368
368
|
def test_translate_given_an_unknown_format_it_does_not_fail
|
369
|
-
assert_nothing_raised{ @backend.localize 'de
|
369
|
+
assert_nothing_raised{ @backend.localize 'de', @morning, '%x' }
|
370
370
|
end
|
371
371
|
end
|
372
372
|
|
@@ -386,45 +386,45 @@ class I18nSimpleBackendLocalizeTimeTest < Test::Unit::TestCase
|
|
386
386
|
end
|
387
387
|
|
388
388
|
def test_translate_given_the_short_format_it_uses_it
|
389
|
-
assert_equal '01. Jan 06:00', @backend.localize('de
|
389
|
+
assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short)
|
390
390
|
end
|
391
391
|
|
392
392
|
def test_translate_given_the_long_format_it_uses_it
|
393
|
-
assert_equal '01. Januar 2008 06:00', @backend.localize('de
|
393
|
+
assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long)
|
394
394
|
end
|
395
395
|
|
396
396
|
# TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
|
397
397
|
# def test_translate_given_the_default_format_it_uses_it
|
398
|
-
# assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de
|
398
|
+
# assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default)
|
399
399
|
# end
|
400
400
|
|
401
401
|
def test_translate_given_a_day_name_format_it_returns_the_correct_day_name
|
402
|
-
assert_equal 'Dienstag', @backend.localize('de
|
402
|
+
assert_equal 'Dienstag', @backend.localize('de', @morning, '%A')
|
403
403
|
end
|
404
404
|
|
405
405
|
def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
|
406
|
-
assert_equal 'Di', @backend.localize('de
|
406
|
+
assert_equal 'Di', @backend.localize('de', @morning, '%a')
|
407
407
|
end
|
408
408
|
|
409
409
|
def test_translate_given_a_month_name_format_it_returns_the_correct_month_name
|
410
|
-
assert_equal 'Januar', @backend.localize('de
|
410
|
+
assert_equal 'Januar', @backend.localize('de', @morning, '%B')
|
411
411
|
end
|
412
412
|
|
413
413
|
def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
|
414
|
-
assert_equal 'Jan', @backend.localize('de
|
414
|
+
assert_equal 'Jan', @backend.localize('de', @morning, '%b')
|
415
415
|
end
|
416
416
|
|
417
417
|
def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
|
418
|
-
assert_equal 'am', @backend.localize('de
|
419
|
-
assert_equal 'pm', @backend.localize('de
|
418
|
+
assert_equal 'am', @backend.localize('de', @morning, '%p')
|
419
|
+
assert_equal 'pm', @backend.localize('de', @evening, '%p')
|
420
420
|
end
|
421
421
|
|
422
422
|
def test_translate_given_no_format_it_does_not_fail
|
423
|
-
assert_nothing_raised{ @backend.localize 'de
|
423
|
+
assert_nothing_raised{ @backend.localize 'de', @morning }
|
424
424
|
end
|
425
425
|
|
426
426
|
def test_translate_given_an_unknown_format_it_does_not_fail
|
427
|
-
assert_nothing_raised{ @backend.localize 'de
|
427
|
+
assert_nothing_raised{ @backend.localize 'de', @morning, '%x' }
|
428
428
|
end
|
429
429
|
end
|
430
430
|
|
@@ -444,29 +444,29 @@ class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase
|
|
444
444
|
include I18nSimpleBackendTestSetup
|
445
445
|
|
446
446
|
def test_load_translations_with_unknown_file_type_raises_exception
|
447
|
-
assert_raises(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en
|
447
|
+
assert_raises(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en.xml" }
|
448
448
|
end
|
449
449
|
|
450
450
|
def test_load_translations_with_ruby_file_type_does_not_raise_exception
|
451
|
-
assert_nothing_raised { @backend.load_translations "#{@locale_dir}/en
|
451
|
+
assert_nothing_raised { @backend.load_translations "#{@locale_dir}/en.rb" }
|
452
452
|
end
|
453
453
|
|
454
454
|
def test_load_rb_loads_data_from_ruby_file
|
455
|
-
data = @backend.send :load_rb, "#{@locale_dir}/en
|
456
|
-
assert_equal({:'en-
|
455
|
+
data = @backend.send :load_rb, "#{@locale_dir}/en.rb"
|
456
|
+
assert_equal({:'en-Ruby' => {:foo => {:bar => "baz"}}}, data)
|
457
457
|
end
|
458
458
|
|
459
459
|
def test_load_rb_loads_data_from_yaml_file
|
460
|
-
data = @backend.send :load_yml, "#{@locale_dir}/en
|
461
|
-
assert_equal({'en-
|
460
|
+
data = @backend.send :load_yml, "#{@locale_dir}/en.yml"
|
461
|
+
assert_equal({'en-Yaml' => {'foo' => {'bar' => 'baz'}}}, data)
|
462
462
|
end
|
463
463
|
|
464
464
|
def test_load_translations_loads_from_different_file_formats
|
465
465
|
@backend = I18n::Backend::Simple.new
|
466
|
-
@backend.load_translations "#{@locale_dir}/en
|
466
|
+
@backend.load_translations "#{@locale_dir}/en.rb", "#{@locale_dir}/en.yml"
|
467
467
|
expected = {
|
468
|
-
:'en-
|
469
|
-
:'en-
|
468
|
+
:'en-Ruby' => {:foo => {:bar => "baz"}},
|
469
|
+
:'en-Yaml' => {:foo => {:bar => "baz"}}
|
470
470
|
}
|
471
471
|
assert_equal expected, backend_get_translations
|
472
472
|
end
|
@@ -477,7 +477,7 @@ class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
|
|
477
477
|
|
478
478
|
def setup
|
479
479
|
@backend = I18n::Backend::Simple.new
|
480
|
-
I18n.load_path = [File.dirname(__FILE__) + '/locale/en
|
480
|
+
I18n.load_path = [File.dirname(__FILE__) + '/locale/en.yml']
|
481
481
|
assert_nil backend_get_translations
|
482
482
|
@backend.send :init_translations
|
483
483
|
end
|
@@ -10,17 +10,17 @@ describe I18n, "Russian pluralization" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should pluralize correctly" do
|
13
|
-
@backend.send(:pluralize, :'ru
|
14
|
-
@backend.send(:pluralize, :'ru
|
15
|
-
@backend.send(:pluralize, :'ru
|
16
|
-
@backend.send(:pluralize, :'ru
|
17
|
-
@backend.send(:pluralize, :'ru
|
18
|
-
@backend.send(:pluralize, :'ru
|
19
|
-
@backend.send(:pluralize, :'ru
|
20
|
-
@backend.send(:pluralize, :'ru
|
21
|
-
@backend.send(:pluralize, :'ru
|
22
|
-
@backend.send(:pluralize, :'ru
|
23
|
-
@backend.send(:pluralize, :'ru
|
24
|
-
@backend.send(:pluralize, :'ru
|
13
|
+
@backend.send(:pluralize, :'ru', @hash, 1).should == 'one'
|
14
|
+
@backend.send(:pluralize, :'ru', @hash, 2).should == 'few'
|
15
|
+
@backend.send(:pluralize, :'ru', @hash, 3).should == 'few'
|
16
|
+
@backend.send(:pluralize, :'ru', @hash, 5).should == 'many'
|
17
|
+
@backend.send(:pluralize, :'ru', @hash, 10).should == 'many'
|
18
|
+
@backend.send(:pluralize, :'ru', @hash, 11).should == 'many'
|
19
|
+
@backend.send(:pluralize, :'ru', @hash, 21).should == 'one'
|
20
|
+
@backend.send(:pluralize, :'ru', @hash, 29).should == 'many'
|
21
|
+
@backend.send(:pluralize, :'ru', @hash, 131).should == 'one'
|
22
|
+
@backend.send(:pluralize, :'ru', @hash, 1.31).should == 'other'
|
23
|
+
@backend.send(:pluralize, :'ru', @hash, 2.31).should == 'other'
|
24
|
+
@backend.send(:pluralize, :'ru', @hash, 3.31).should == 'other'
|
25
25
|
end
|
26
26
|
end
|
data/spec/locale_spec.rb
CHANGED
data/spec/russian_spec.rb
CHANGED
@@ -10,11 +10,11 @@ end
|
|
10
10
|
|
11
11
|
describe Russian do
|
12
12
|
describe "with locale" do
|
13
|
-
it "should define :'ru
|
14
|
-
Russian::LOCALE.should == :'ru
|
13
|
+
it "should define :'ru' LOCALE" do
|
14
|
+
Russian::LOCALE.should == :'ru'
|
15
15
|
end
|
16
16
|
|
17
|
-
it "should provide
|
17
|
+
it "should provide 'locale' proxy" do
|
18
18
|
Russian.locale.should == Russian::LOCALE
|
19
19
|
end
|
20
20
|
end
|
@@ -32,9 +32,9 @@ describe Russian do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should keep existing translations while switching backends" do
|
35
|
-
I18n.load_path << File.join(File.dirname(__FILE__), 'fixtures', 'en
|
35
|
+
I18n.load_path << File.join(File.dirname(__FILE__), 'fixtures', 'en.yml')
|
36
36
|
Russian.init_i18n
|
37
|
-
I18n.t(:foo, :locale => :'en
|
37
|
+
I18n.t(:foo, :locale => :'en').should == "bar"
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should set default locale to Russian locale" do
|
@@ -50,7 +50,7 @@ describe Russian do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
%w(l localize).each do |method|
|
53
|
-
it "#{method} should call I18n backend localize" do
|
53
|
+
it "'#{method}' should call I18n backend localize" do
|
54
54
|
I18n.should_receive(:localize).with(@time, @options.merge({ :locale => Russian.locale }))
|
55
55
|
Russian.send(method, @time, @options)
|
56
56
|
end
|
@@ -64,7 +64,7 @@ describe Russian do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
%w(t translate).each do |method|
|
67
|
-
it "#{method} should call I18n backend translate" do
|
67
|
+
it "'#{method}' should call I18n backend translate" do
|
68
68
|
I18n.should_receive(:translate).with(@object, @options.merge({ :locale => Russian.locale }))
|
69
69
|
Russian.send(method, @object, @options)
|
70
70
|
end
|
@@ -7,7 +7,7 @@ describe Russian do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
%w(transliterate translit).each do |method|
|
10
|
-
it "#{method} method should perform transliteration" do
|
10
|
+
it "'#{method}' method should perform transliteration" do
|
11
11
|
str = mock(:str)
|
12
12
|
Russian::Transliteration.should_receive(:transliterate).with(str)
|
13
13
|
Russian.send(method, str)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: russian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Markin
|
@@ -22,11 +22,13 @@ extensions: []
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- README.textile
|
24
24
|
- LICENSE
|
25
|
+
- CHANGELOG
|
25
26
|
- TODO
|
26
27
|
files:
|
27
28
|
- LICENSE
|
28
29
|
- README.textile
|
29
30
|
- Rakefile
|
31
|
+
- CHANGELOG
|
30
32
|
- TODO
|
31
33
|
- init.rb
|
32
34
|
- lib/russian
|
@@ -58,14 +60,15 @@ files:
|
|
58
60
|
- lib/vendor/i18n/lib/i18n/exceptions.rb
|
59
61
|
- lib/vendor/i18n/lib/i18n.rb
|
60
62
|
- lib/vendor/i18n/MIT-LICENSE
|
63
|
+
- lib/vendor/i18n/Rakefile
|
61
64
|
- lib/vendor/i18n/README.textile
|
62
65
|
- lib/vendor/i18n/test
|
63
66
|
- lib/vendor/i18n/test/all.rb
|
64
67
|
- lib/vendor/i18n/test/i18n_exceptions_test.rb
|
65
68
|
- lib/vendor/i18n/test/i18n_test.rb
|
66
69
|
- lib/vendor/i18n/test/locale
|
67
|
-
- lib/vendor/i18n/test/locale/en
|
68
|
-
- lib/vendor/i18n/test/locale/en
|
70
|
+
- lib/vendor/i18n/test/locale/en.rb
|
71
|
+
- lib/vendor/i18n/test/locale/en.yml
|
69
72
|
- lib/vendor/i18n/test/simple_backend_test.rb
|
70
73
|
- lib/vendor/i18n_label
|
71
74
|
- lib/vendor/i18n_label/init.rb
|
@@ -81,7 +84,7 @@ files:
|
|
81
84
|
- lib/vendor/i18n_label/tasks/i18n_label_tasks.rake
|
82
85
|
- lib/vendor/i18n_label/uninstall.rb
|
83
86
|
- spec/fixtures
|
84
|
-
- spec/fixtures/en
|
87
|
+
- spec/fixtures/en.yml
|
85
88
|
- spec/i18n
|
86
89
|
- spec/i18n/locale
|
87
90
|
- spec/i18n/locale/datetime_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
{:'en-US-Ruby' => {:foo => {:bar => "baz"}}}
|