russian 0.0.5 → 0.0.6

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.
@@ -18,7 +18,7 @@ Russian -- это библиотека для полноценной подде
18
18
 
19
19
  Russian использует библиотеку I18n (включена в поставку), несколько хаков поверх нее (собственный бекэнд с поддержкой спецефичного для русского форматирования даты и времени, поддержкой плюрализации), несколько хаков поверх Rails (хаки хелперов даты-времени, хак для сообщений валидации) и файлы переводов, а также набор хелперов, упрощающий работу с русским языком (простая плюрализация, простой strftime и др.).
20
20
 
21
- Russian стремится быть минимально деструктивной для окружения и быть полностью совместимой с другими языками (таким образом, когда приложение использует Russian и собственный бекэнд Russian, оно остается польностью совместимым с Rails i18n).
21
+ Russian стремится быть минимально деструктивной для окружения и быть полностью совместимой с другими языками (таким образом, когда приложение использует Russian и собственный бекэнд Russian, оно остается полностью совместимым с Rails i18n).
22
22
 
23
23
  h2. Что такое I18n
24
24
 
@@ -75,8 +75,7 @@ end
75
75
 
76
76
  @script/plugin install git://github.com/yaroslav/russian.git@
77
77
 
78
- _NB:_ вполне вероятно, что на Windows нет нормальной реализации git, поэтому вам придется загружать исходники
79
- в виде архива с github или же просто использовать gem.
78
+ Для Windows можно использовать версию git, расположенную по адресу: "http://code.google.com/p/msysgit/":http://code.google.com/p/msysgit/
80
79
 
81
80
  h1. Использование
82
81
 
@@ -121,20 +120,20 @@ h2. Примеры и справка по переводам (I18n)
121
120
 
122
121
  h2. Вспомогательные методы модуля Russian
123
122
 
124
- <pre></code>
123
+ <pre><code>
125
124
  Russian.locale
126
125
  Russian::LOCALE
127
126
  </code></pre>
128
127
 
129
128
  -- возвращает локаль русского языка (@ru-RU@).
130
129
 
131
- <pre></code>
130
+ <pre><code>
132
131
  Russian::i18n_backend_class
133
132
  </code></pre>
134
133
 
135
134
  -- возвращает класс собственного бекенда I18n
136
135
 
137
- <pre></code>
136
+ <pre><code>
138
137
  Russian::init_i18n
139
138
  </code></pre>
140
139
 
@@ -142,21 +141,21 @@ Russian::init_i18n
142
141
 
143
142
  _NB:_ Выполняется автоматически при загрузке.
144
143
 
145
- <pre></code>
144
+ <pre><code>
146
145
  Russian::translate
147
146
  Russian::t
148
147
  </code></pre>
149
148
 
150
149
  -- прокси для метода @translate@ I18n, форсирует использование русской локали.
151
150
 
152
- <pre></code>
151
+ <pre><code>
153
152
  Russian::localize
154
153
  Russian::l
155
154
  </code></pre>
156
155
 
157
156
  -- прокси для метода @localize@ I18n, форсирует использование русской локали.
158
157
 
159
- <pre></code>
158
+ <pre><code>
160
159
  Russian::strftime
161
160
 
162
161
  Russian::strftime(Time.now)
@@ -167,7 +166,7 @@ Russian::strftime(Time.now, "%B")
167
166
 
168
167
  -- @strftime@ с форсированием русской локали (упрощенный вариант @localize@)
169
168
 
170
- <pre></code>
169
+ <pre><code>
171
170
  Russian::pluralize
172
171
  Russian::p
173
172
 
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.5"
8
+ GEM_VERSION = "0.0.6"
9
9
  AUTHOR = "Yaroslav Markin"
10
10
  EMAIL = "yaroslav@markin.net"
11
11
  HOMEPAGE = "http://github.com/yaroslav/russian/"
data/TODO CHANGED
@@ -1,9 +1,10 @@
1
1
  TODO
2
2
  ====
3
+ * RDoc
3
4
  * check Unicode CLDR to ensure all datetime formats are correct
4
- * examples of custom translations, AR models/attributes/messages translations
5
5
  * refactor Advanced backend localize method (looks ugly)
6
- * Countries list
6
+ * refactor DateTimeSelector#translated_month_names
7
+ * Countries list (not in Rails I18n)
7
8
 
8
9
  Questionable
9
10
  ============
@@ -22,7 +22,7 @@ module Russian
22
22
  module VERSION
23
23
  MAJOR = 0
24
24
  MINOR = 0
25
- TINY = 5
25
+ TINY = 6
26
26
 
27
27
  STRING = [MAJOR, MINOR, TINY].join('.')
28
28
  end
@@ -46,11 +46,9 @@ module Russian
46
46
  # Init Russian i18n: set custom backend, set default locale to Russian locale, load all translations
47
47
  # shipped with library.
48
48
  def init_i18n
49
- loaded_translations = I18n.backend.__send__(:translations)
50
49
  I18n.backend = Russian.i18n_backend_class.new
51
- loaded_translations.each_pair { |locale, data| I18n.backend.store_translations(locale, data) }
52
50
  I18n.default_locale = LOCALE
53
- locale_files.each { |file| I18n.backend.load_translations(file) }
51
+ locale_files.each { |file| I18n.load_path << file }
54
52
  end
55
53
 
56
54
  # See I18n::translate
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
  "spec/core_ext_spec.rb",
20
20
  "spec/i18n_spec.rb",
21
21
  "spec/spec.opts",
22
- "spec/spec_helper.rb"
22
+ "spec/spec/helper.rb"
23
23
  ]
24
24
  end
@@ -10,7 +10,8 @@ require 'i18n/exceptions'
10
10
 
11
11
  module I18n
12
12
  @@backend = nil
13
- @@default_locale = 'en-US'
13
+ @@load_path = []
14
+ @@default_locale = :'en-US'
14
15
  @@exception_handler = :default_exception_handler
15
16
 
16
17
  class << self
@@ -49,14 +50,20 @@ module I18n
49
50
  @@exception_handler = exception_handler
50
51
  end
51
52
 
52
- # Allows client libraries to pass arguments that specify a source for
53
- # translation data to be loaded by the backend. The backend defines
54
- # acceptable sources.
53
+ # Allow clients to register paths providing translation data sources. The
54
+ # backend defines acceptable sources.
55
+ #
55
56
  # E.g. the provided SimpleBackend accepts a list of paths to translation
56
57
  # files which are either named *.rb and contain plain Ruby Hashes or are
57
- # named *.yml and contain YAML data.)
58
- def load_translations(*args)
59
- backend.load_translations(*args)
58
+ # named *.yml and contain YAML data. So for the SimpleBackend clients may
59
+ # register translation files like this:
60
+ # I18n.load_path << 'path/to/locale/en-US.yml'
61
+ def load_path
62
+ @@load_path
63
+ end
64
+
65
+ def load_path=(load_path)
66
+ @@load_path = load_path
60
67
  end
61
68
 
62
69
  # Translates, pluralizes and interpolates a given key using a given locale,
@@ -175,6 +182,4 @@ module I18n
175
182
  keys.flatten.map{|k| k.to_sym}
176
183
  end
177
184
  end
178
- end
179
-
180
-
185
+ end
@@ -60,6 +60,11 @@ module I18n
60
60
  end
61
61
 
62
62
  protected
63
+
64
+ def init_translations
65
+ load_translations(*I18n.load_path)
66
+ @initialized = true
67
+ end
63
68
 
64
69
  def translations
65
70
  @translations ||= {}
@@ -72,6 +77,7 @@ module I18n
72
77
  # <tt>%w(currency format)</tt>.
73
78
  def lookup(locale, key, scope = [])
74
79
  return unless key
80
+ init_translations unless @initialized
75
81
  keys = I18n.send :normalize_translation_keys, locale, key, scope
76
82
  keys.inject(translations){|result, k| result[k.to_sym] or return nil }
77
83
  end
@@ -0,0 +1,4 @@
1
+ # Fixture dummy translation
2
+ # Need this to test if we preserve translation data that is already loaded when switching backends
3
+ en-US:
4
+ foo: "bar"
@@ -32,7 +32,7 @@ describe Russian do
32
32
  end
33
33
 
34
34
  it "should keep existing translations while switching backends" do
35
- I18n.backend.store_translations(:'en-US', { :foo => "bar" })
35
+ I18n.load_path << File.join(File.dirname(__FILE__), 'fixtures', 'en-US.yml')
36
36
  Russian.init_i18n
37
37
  I18n.t(:foo, :locale => :'en-US').should == "bar"
38
38
  end
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.5
4
+ version: 0.0.6
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-14 00:00:00 +04:00
12
+ date: 2008-10-16 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -77,6 +77,8 @@ files:
77
77
  - lib/vendor/i18n_label/tasks
78
78
  - lib/vendor/i18n_label/tasks/i18n_label_tasks.rake
79
79
  - lib/vendor/i18n_label/uninstall.rb
80
+ - spec/fixtures
81
+ - spec/fixtures/en-US.yml
80
82
  - spec/i18n
81
83
  - spec/i18n/locale
82
84
  - spec/i18n/locale/datetime_spec.rb
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  requirements: []
107
109
 
108
110
  rubyforge_project:
109
- rubygems_version: 1.2.0
111
+ rubygems_version: 1.3.0
110
112
  signing_key:
111
113
  specification_version: 2
112
114
  summary: Russian language support for Ruby and Rails