has_translations 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- HasTranslations v0.3.pre
2
- ====================
1
+ HasTranslations v0.3.1
2
+ ======================
3
3
 
4
4
  This simple plugin creates translations for your model.
5
5
  Uses delegation pattern: http://en.wikipedia.org/wiki/Delegation_pattern
6
6
 
7
+ Tested with ActiveRecord versions: 2.3.5, 2.3.9, 3.0.0 (to test with Rails 3 run `rake RAILS_VERSION=3.0`)
8
+
7
9
  Installation
8
10
  ============
9
11
 
@@ -117,7 +119,6 @@ I suggest you to use latest i18n gem, include it in your rails 2 environment:
117
119
  TODO
118
120
  ====
119
121
 
120
- * active record 3 (rails 3) support
121
122
  * add installation description to readme
122
123
  * model and migration generators
123
124
  * caching
@@ -139,9 +140,7 @@ I know three of them:
139
140
  Used in
140
141
  =======
141
142
 
142
- * [noch.es](http://noch.es/)
143
- * [eten.es](http://www.eten.es))
144
- * [sem.ee](http://sem.ee/)
143
+ [noch.es](http://noch.es/), [eten.es](http://www.eten.es), [sem.ee](http://sem.ee/)
145
144
 
146
145
 
147
- Copyright (c) 2009-2010 [Dmitry Polushkin], released under the MIT license
146
+ Copyright (c) 2009-2010 [Dmitry Polushkin], released under the MIT license
@@ -140,7 +140,12 @@ class ActiveRecord::Base
140
140
  translation_class.validates_presence_of :locale
141
141
  translation_class.validates_uniqueness_of :locale, :scope => :"#{belongs_to}_id"
142
142
 
143
- named_scope :translated, lambda { |locale| {:conditions => ["#{translation_class.table_name}.locale = ?", locale.to_s], :joins => :translations} }
143
+ # Rails 3.0
144
+ if Object.const_defined?("ActiveModel")
145
+ scope :translated, lambda { |locale| {:conditions => ["#{translation_class.table_name}.locale = ?", locale.to_s], :joins => :translations} }
146
+ else
147
+ named_scope :translated, lambda { |locale| {:conditions => ["#{translation_class.table_name}.locale = ?", locale.to_s], :joins => :translations} }
148
+ end
144
149
 
145
150
  private
146
151
 
@@ -149,4 +154,4 @@ class ActiveRecord::Base
149
154
  translations.detect { |t| t.locale == locale }
150
155
  end
151
156
  end
152
- end
157
+ end
@@ -7,7 +7,6 @@ class HasTranslationsTest < Test::Unit::TestCase
7
7
  [Article, ArticleTranslation, Team, TeamTranslation].each do |k|
8
8
  k.delete_all
9
9
  end
10
- I18n.available_locales = :ru, :en, :es
11
10
  I18n.locale = :ru
12
11
  end
13
12
 
data/test/test_helper.rb CHANGED
@@ -1,14 +1,26 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
 
4
- gem 'activerecord', '~> 2.3'
5
- gem 'i18n', '~> 0.4'
4
+ case ENV['RAILS_VERSION']
5
+ when '3.0' then
6
+ gem 'activerecord', '~> 3.0.0'
7
+ gem 'activesupport', '~> 3.0.0'
8
+ else
9
+ gem 'activerecord', '~> 2.3.0'
10
+ gem 'activesupport', '~> 2.3.0'
11
+ end
6
12
 
7
13
  require 'active_record'
8
14
  require 'logger'
9
15
 
10
16
  require 'has_translations'
11
17
 
18
+ begin
19
+ I18n.available_locales = :ru, :en, :es
20
+ rescue
21
+ p "[WARNING]: This test should have the I18n.available_locales= method, which were included in versions ~> 0.3.0"
22
+ end
23
+
12
24
  #ActiveRecord::Base.logger = Logger.new(STDOUT)
13
25
  ActiveRecord::Base.logger = nil
14
26
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
@@ -22,4 +34,4 @@ def teardown_db
22
34
  ActiveRecord::Base.connection.tables.each do |table|
23
35
  ActiveRecord::Base.connection.drop_table(table)
24
36
  end
25
- end
37
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_translations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dmitry Polushkin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-25 00:00:00 +01:00
18
+ date: 2010-09-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21