russian 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ === 0.2.0 - 16.03.2009
2
+
3
+ * number_to_human_size() translations: using edge format (Rails 2.3)
4
+ * i18n gem updated (0.1.3)
5
+ * Rails 2.3 compat
6
+
7
+ * Перевод для number_to_human_size(): испольуется форматирование из edge (Rails 2.3)
8
+ * Обновлен gem i18n до версии 0.1.3
9
+ * Совместимость с Rails 2.3
10
+
1
11
  === 0.1.3 - 27.12.2008
2
12
 
3
13
  * Add support.array.words_connector/two_words_connector/last_word_connector (Array#to_sentence) (Rails Edge)
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rubygems/specification'
5
5
  require 'date'
6
6
 
7
7
  GEM = "russian"
8
- GEM_VERSION = "0.1.3"
8
+ GEM_VERSION = "0.2.0"
9
9
  AUTHOR = "Yaroslav Markin"
10
10
  EMAIL = "yaroslav@markin.net"
11
11
  HOMEPAGE = "http://github.com/yaroslav/russian/"
@@ -52,4 +52,4 @@ task :make_spec do
52
52
  File.open("#{GEM}.gemspec", "w") do |file|
53
53
  file.puts spec.to_ruby
54
54
  end
55
- end
55
+ end
data/TODO CHANGED
@@ -4,8 +4,6 @@ TODO
4
4
  * check Unicode CLDR to ensure all datetime formats are correct
5
5
  * refactor Advanced backend localize method (looks ugly)
6
6
  * refactor DateTimeSelector#translated_month_names
7
- * stuff from english gem
8
- * Countries list (not in Rails I18n)
9
7
 
10
8
  Questionable
11
9
  ============
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  $KCODE='u'
2
4
 
3
5
  $:.push File.join(File.dirname(__FILE__), 'russian')
@@ -24,8 +26,8 @@ module Russian
24
26
 
25
27
  module VERSION
26
28
  MAJOR = 0
27
- MINOR = 1
28
- TINY = 3
29
+ MINOR = 2
30
+ TINY = 0
29
31
 
30
32
  STRING = [MAJOR, MINOR, TINY].join('.')
31
33
  end
@@ -48,10 +50,9 @@ module Russian
48
50
  # Init Russian i18n: set custom backend, set default locale to Russian locale, load all translations
49
51
  # shipped with library.
50
52
  def init_i18n
51
- old_load_path = I18n.load_path
52
53
  I18n.backend = Russian.i18n_backend_class.new
53
54
  I18n.default_locale = LOCALE
54
- I18n.load_path = locale_files + old_load_path
55
+ I18n.load_path.unshift(*locale_files)
55
56
  end
56
57
 
57
58
  # See I18n::translate
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  # Заменяет хелпер Rails <tt>select_month</tt> и метод <tt>translated_month_names</tt>
2
4
  # для поддержки функционала "отдельностоящих имен месяцев".
3
5
  #
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  # The following is taken from custom_error_message plugin by David Easley
2
4
  # (http://rubyforge.org/projects/custom-err-msg/)
3
5
  module ActiveRecord
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module ActiveSupport
2
4
  module Inflector
3
5
  # Replaces special characters in a string so that it may be used as part of a 'pretty' URL.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module I18n
2
4
  module Backend
3
5
  # "Продвинутый" бекэнд для I18n.
@@ -49,7 +49,25 @@ ru:
49
49
  # separator:
50
50
  delimiter: ""
51
51
  precision: 1
52
- storage_units: [байт, КБ, МБ, ГБ, ТБ]
52
+
53
+ # Rails 2.2
54
+ # storage_units: [байт, КБ, МБ, ГБ, ТБ]
55
+
56
+ # Rails 2.3
57
+ storage_units:
58
+ # Storage units output formatting.
59
+ # %u is the storage unit, %n is the number (default: 2 MB)
60
+ format: "%n %u"
61
+ units:
62
+ byte:
63
+ one: "байт"
64
+ few: "байта"
65
+ many: "байт"
66
+ other: "байта"
67
+ kb: "КБ"
68
+ mb: "МБ"
69
+ gb: "ГБ"
70
+ tb: "ТБ"
53
71
 
54
72
  # Используется в хелперах distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
55
73
  #
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  {
2
4
  :'ru' => {
3
5
  :pluralize => lambda { |n|
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Russian
2
4
  # Russian transliteration
3
5
  #
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "i18n"
3
- s.version = "0.1.1"
4
- s.date = "2008-10-26"
3
+ s.version = "0.1.3"
4
+ s.date = "2009-01-09"
5
5
  s.summary = "Internationalization support for Ruby"
6
6
  s.email = "rails-i18n@googlegroups.com"
7
7
  s.homepage = "http://rails-i18n.org"
@@ -45,6 +45,11 @@ module I18n
45
45
  Thread.current[:locale] = locale
46
46
  end
47
47
 
48
+ # Returns an array of locales for which translations are available
49
+ def available_locales
50
+ backend.available_locales
51
+ end
52
+
48
53
  # Sets the exception handler.
49
54
  def exception_handler=(exception_handler)
50
55
  @@exception_handler = exception_handler
@@ -69,6 +69,12 @@ module I18n
69
69
  @initialized ||= false
70
70
  end
71
71
 
72
+ # Returns an array of locales for which translations are available
73
+ def available_locales
74
+ init_translations unless initialized?
75
+ translations.keys
76
+ end
77
+
72
78
  def reload!
73
79
  @initialized = false
74
80
  @translations = nil
@@ -76,7 +82,7 @@ module I18n
76
82
 
77
83
  protected
78
84
  def init_translations
79
- load_translations(*I18n.load_path)
85
+ load_translations(*I18n.load_path.flatten)
80
86
  @initialized = true
81
87
  end
82
88
 
@@ -145,12 +151,7 @@ module I18n
145
151
  def interpolate(locale, string, values = {})
146
152
  return string unless string.is_a?(String)
147
153
 
148
- if string.respond_to?(:force_encoding)
149
- original_encoding = string.encoding
150
- string.force_encoding(Encoding::BINARY)
151
- end
152
-
153
- result = string.gsub(MATCH) do
154
+ string.gsub(MATCH) do
154
155
  escaped, pattern, key = $1, $2, $2.to_sym
155
156
 
156
157
  if escaped
@@ -163,9 +164,6 @@ module I18n
163
164
  values[key].to_s
164
165
  end
165
166
  end
166
-
167
- result.force_encoding(original_encoding) if original_encoding
168
- result
169
167
  end
170
168
 
171
169
  # Loads a single translations file by delegating to #load_rb or
@@ -124,6 +124,16 @@ class I18nSimpleBackendTranslationsTest < Test::Unit::TestCase
124
124
  end
125
125
  end
126
126
 
127
+ class I18nSimpleBackendAvailableLocalesTest < Test::Unit::TestCase
128
+ def test_available_locales
129
+ @backend = I18n::Backend::Simple.new
130
+ @backend.store_translations 'de', :foo => 'bar'
131
+ @backend.store_translations 'en', :foo => 'foo'
132
+
133
+ assert_equal ['de', 'en'], @backend.available_locales.map{|locale| locale.to_s }.sort
134
+ end
135
+ end
136
+
127
137
  class I18nSimpleBackendTranslateTest < Test::Unit::TestCase
128
138
  include I18nSimpleBackendTestSetup
129
139
 
@@ -243,6 +253,32 @@ class I18nSimpleBackendInterpolateTest < Test::Unit::TestCase
243
253
  assert_equal 'Häi David!', @backend.send(:interpolate, nil, 'Häi {{name}}!', :name => 'David')
244
254
  end
245
255
 
256
+ def test_interpolate_given_an_unicode_value_hash_interpolates_to_the_string
257
+ assert_equal 'Hi ゆきひろ!', @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => 'ゆきひろ')
258
+ end
259
+
260
+ def test_interpolate_given_an_unicode_value_hash_interpolates_into_unicode_string
261
+ assert_equal 'こんにちは、ゆきひろさん!', @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => 'ゆきひろ')
262
+ end
263
+
264
+ if Kernel.const_defined?(:Encoding)
265
+ def test_interpolate_given_a_non_unicode_multibyte_value_hash_interpolates_into_a_string_with_the_same_encoding
266
+ assert_equal euc_jp('Hi ゆきひろ!'), @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => euc_jp('ゆきひろ'))
267
+ end
268
+
269
+ def test_interpolate_given_an_unicode_value_hash_into_a_non_unicode_multibyte_string_raises_encoding_compatibility_error
270
+ assert_raises(Encoding::CompatibilityError) do
271
+ @backend.send(:interpolate, nil, euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ')
272
+ end
273
+ end
274
+
275
+ def test_interpolate_given_a_non_unicode_multibyte_value_hash_into_an_unicode_string_raises_encoding_compatibility_error
276
+ assert_raises(Encoding::CompatibilityError) do
277
+ @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => euc_jp('ゆきひろ'))
278
+ end
279
+ end
280
+ end
281
+
246
282
  def test_interpolate_given_nil_as_a_string_returns_nil
247
283
  assert_nil @backend.send(:interpolate, nil, nil, :name => 'David')
248
284
  end
@@ -262,6 +298,12 @@ class I18nSimpleBackendInterpolateTest < Test::Unit::TestCase
262
298
  def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key
263
299
  assert_raises(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) }
264
300
  end
301
+
302
+ private
303
+
304
+ def euc_jp(string)
305
+ string.encode!(Encoding::EUC_JP)
306
+ end
265
307
  end
266
308
 
267
309
  class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase
@@ -472,6 +514,30 @@ class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase
472
514
  end
473
515
  end
474
516
 
517
+ class I18nSimpleBackendLoadPathTest < Test::Unit::TestCase
518
+ include I18nSimpleBackendTestSetup
519
+
520
+ def teardown
521
+ I18n.load_path = []
522
+ end
523
+
524
+ def test_nested_load_paths_do_not_break_locale_loading
525
+ @backend = I18n::Backend::Simple.new
526
+ I18n.load_path = [[File.dirname(__FILE__) + '/locale/en.yml']]
527
+ assert_nil backend_get_translations
528
+ assert_nothing_raised { @backend.send :init_translations }
529
+ assert_not_nil backend_get_translations
530
+ end
531
+
532
+ def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading
533
+ @backend = I18n::Backend::Simple.new
534
+ I18n.load_path << Dir[File.dirname(__FILE__) + '/locale/*.{rb,yml}']
535
+ assert_nil backend_get_translations
536
+ assert_nothing_raised { @backend.send :init_translations }
537
+ assert_not_nil backend_get_translations
538
+ end
539
+ end
540
+
475
541
  class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
476
542
  include I18nSimpleBackendTestSetup
477
543
 
@@ -499,4 +565,4 @@ class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
499
565
  @backend.reload!
500
566
  assert_equal @backend.initialized?, false
501
567
  end
502
- end
568
+ end
@@ -1,7 +1,9 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require File.dirname(__FILE__) + '/../../spec_helper'
2
4
 
3
5
  describe I18n, "Russian Date/Time localization" do
4
- before(:each) do
6
+ before(:all) do
5
7
  @date = Date.parse("1985-12-01")
6
8
  @time = Time.local(1985, 12, 01, 16, 05)
7
9
  end
@@ -88,4 +90,4 @@ describe I18n, "Russian Date/Time localization" do
88
90
  def l(object, options = {})
89
91
  I18n.l(object, options.merge( { :locale => Russian.locale }))
90
92
  end
91
- end
93
+ end
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require File.dirname(__FILE__) + '/../../spec_helper'
2
4
 
3
5
  describe I18n, "Russian pluralization" do
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require File.dirname(__FILE__) + '/spec_helper'
2
4
 
3
5
  describe Russian, "loading locales" do
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require File.dirname(__FILE__) + '/spec_helper'
2
4
 
3
5
  describe Russian, "VERSION" do
@@ -26,6 +28,11 @@ describe Russian do
26
28
  end
27
29
 
28
30
  describe "during i18n initialization" do
31
+ after(:each) do
32
+ I18n.load_path = []
33
+ Russian.init_i18n
34
+ end
35
+
29
36
  it "should set I18n backend to an instance of a custom backend" do
30
37
  Russian.init_i18n
31
38
  I18n.backend.class.should == Russian.i18n_backend_class
@@ -126,4 +133,4 @@ describe Russian do
126
133
  end
127
134
  end
128
135
  end
129
- end
136
+ end
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  $TESTING=true
2
4
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
5
 
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require File.dirname(__FILE__) + '/spec_helper'
2
4
 
3
5
  describe Russian do
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.1.3
4
+ version: 0.2.0
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-12-27 00:00:00 +03:00
12
+ date: 2009-03-16 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -32,67 +32,66 @@ files:
32
32
  - TODO
33
33
  - init.rb
34
34
  - lib/russian
35
- - lib/russian/action_view_ext
36
- - lib/russian/action_view_ext/helpers
37
- - lib/russian/action_view_ext/helpers/date_helper.rb
38
35
  - lib/russian/active_record_ext
39
36
  - lib/russian/active_record_ext/custom_error_message.rb
40
37
  - lib/russian/active_support_ext
41
38
  - lib/russian/active_support_ext/parameterize.rb
42
- - lib/russian/backend
43
- - lib/russian/backend/advanced.rb
44
- - lib/russian/core_ext
45
39
  - lib/russian/locale
46
40
  - lib/russian/locale/actionview.yml
41
+ - lib/russian/locale/pluralize.rb
42
+ - lib/russian/locale/datetime.yml
47
43
  - lib/russian/locale/activerecord.yml
48
44
  - lib/russian/locale/activesupport.yml
49
- - lib/russian/locale/datetime.yml
50
- - lib/russian/locale/pluralize.rb
45
+ - lib/russian/action_view_ext
46
+ - lib/russian/action_view_ext/helpers
47
+ - lib/russian/action_view_ext/helpers/date_helper.rb
51
48
  - lib/russian/transliteration.rb
52
- - lib/russian.rb
49
+ - lib/russian/backend
50
+ - lib/russian/backend/advanced.rb
53
51
  - lib/vendor
54
52
  - lib/vendor/i18n
53
+ - lib/vendor/i18n/test
54
+ - lib/vendor/i18n/test/i18n_exceptions_test.rb
55
+ - lib/vendor/i18n/test/simple_backend_test.rb
56
+ - lib/vendor/i18n/test/all.rb
57
+ - lib/vendor/i18n/test/i18n_test.rb
58
+ - lib/vendor/i18n/test/locale
59
+ - lib/vendor/i18n/test/locale/en.yml
60
+ - lib/vendor/i18n/test/locale/en.rb
55
61
  - lib/vendor/i18n/i18n.gemspec
56
62
  - lib/vendor/i18n/lib
63
+ - lib/vendor/i18n/lib/i18n.rb
57
64
  - lib/vendor/i18n/lib/i18n
65
+ - lib/vendor/i18n/lib/i18n/exceptions.rb
58
66
  - lib/vendor/i18n/lib/i18n/backend
59
67
  - lib/vendor/i18n/lib/i18n/backend/simple.rb
60
- - lib/vendor/i18n/lib/i18n/exceptions.rb
61
- - lib/vendor/i18n/lib/i18n.rb
62
68
  - lib/vendor/i18n/MIT-LICENSE
63
- - lib/vendor/i18n/Rakefile
64
69
  - lib/vendor/i18n/README.textile
65
- - lib/vendor/i18n/test
66
- - lib/vendor/i18n/test/all.rb
67
- - lib/vendor/i18n/test/i18n_exceptions_test.rb
68
- - lib/vendor/i18n/test/i18n_test.rb
69
- - lib/vendor/i18n/test/locale
70
- - lib/vendor/i18n/test/locale/en.rb
71
- - lib/vendor/i18n/test/locale/en.yml
72
- - lib/vendor/i18n/test/simple_backend_test.rb
70
+ - lib/vendor/i18n/Rakefile
73
71
  - lib/vendor/i18n_label
72
+ - lib/vendor/i18n_label/spec
73
+ - lib/vendor/i18n_label/spec/spec_helper.rb
74
+ - lib/vendor/i18n_label/spec/i18n_label_spec.rb
74
75
  - lib/vendor/i18n_label/init.rb
75
76
  - lib/vendor/i18n_label/install.rb
77
+ - lib/vendor/i18n_label/uninstall.rb
76
78
  - lib/vendor/i18n_label/lib
77
79
  - lib/vendor/i18n_label/lib/i18n_label.rb
78
- - lib/vendor/i18n_label/Rakefile
79
80
  - lib/vendor/i18n_label/README.textile
80
- - lib/vendor/i18n_label/spec
81
- - lib/vendor/i18n_label/spec/i18n_label_spec.rb
82
- - lib/vendor/i18n_label/spec/spec_helper.rb
83
81
  - lib/vendor/i18n_label/tasks
84
82
  - lib/vendor/i18n_label/tasks/i18n_label_tasks.rake
85
- - lib/vendor/i18n_label/uninstall.rb
86
- - spec/fixtures
87
- - spec/fixtures/en.yml
88
- - spec/fixtures/ru.yml
83
+ - lib/vendor/i18n_label/Rakefile
84
+ - lib/russian.rb
85
+ - spec/russian_spec.rb
86
+ - spec/spec_helper.rb
87
+ - spec/locale_spec.rb
89
88
  - spec/i18n
90
89
  - spec/i18n/locale
91
- - spec/i18n/locale/datetime_spec.rb
92
90
  - spec/i18n/locale/pluralization_spec.rb
93
- - spec/locale_spec.rb
94
- - spec/russian_spec.rb
95
- - spec/spec_helper.rb
91
+ - spec/i18n/locale/datetime_spec.rb
92
+ - spec/fixtures
93
+ - spec/fixtures/ru.yml
94
+ - spec/fixtures/en.yml
96
95
  - spec/transliteration_spec.rb
97
96
  has_rdoc: true
98
97
  homepage: http://github.com/yaroslav/russian/