translatable 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/lib/translatable.rb CHANGED
@@ -199,16 +199,6 @@ module ActiveRecord
199
199
  end
200
200
 
201
201
  self.module_eval <<-RUBY, __FILE__, __LINE__ + 1
202
- def current_translation
203
- if translatable_locale_changed?
204
- @translatable_locale = ::I18n.locale.to_s
205
- translatable_set_current
206
- end
207
- @current_translation
208
- end
209
- protected :current_translation
210
-
211
-
212
202
  def translatable_set_current
213
203
  @current_translation = translations.where(:#{@translatable[:locale]} => @translatable_locale).first
214
204
  end
@@ -243,8 +233,20 @@ module ActiveRecord
243
233
 
244
234
  module InstanceMethods
245
235
 
246
- protected
236
+ def current_translation
237
+ if translatable_locale_changed?
238
+ @translatable_locale = ::I18n.locale.to_s
239
+ translatable_set_current
240
+ end
241
+ @current_translation
242
+ end
247
243
 
244
+ def other_translations
245
+ translations - [current_translation]
246
+ end
247
+
248
+ protected
249
+
248
250
  def translatable_locale_changed?
249
251
  @translatable_locale.to_s != ::I18n.locale.to_s
250
252
  end
@@ -91,6 +91,18 @@ class TestDmTranslatable < Test::Unit::TestCase
91
91
  assert_equal "ru", t_news.locale
92
92
  end
93
93
 
94
+ def test_no_other_translations
95
+ news = News.create :translations_attributes => [{ :title => "Заголовок", :content => "Содержание", :locale => "ru"}]
96
+
97
+ assert news.persisted?
98
+
99
+ t_news = TranslatableNews.last
100
+ assert_equal [t_news], news.other_translations
101
+ ::I18n.locale = :ru
102
+ assert_equal [], news.other_translations
103
+ ::I18n.locale = ::I18n.default_locale
104
+ end
105
+
94
106
  def test_create_with_translation_with_multiple_locales
95
107
  news = News.create :translations_attributes => [{ :title => "Заголовок", :content => "Содержание", :locale => "ru"},
96
108
  {:title => "Resent News", :content => "That is where the text goes", :locale => "en"}]
@@ -120,7 +132,7 @@ class TestDmTranslatable < Test::Unit::TestCase
120
132
  assert_equal "That is where the text goes", news.content
121
133
  end
122
134
 
123
- def test_access_of_other_translation
135
+ def test_access_of_different_translation
124
136
  news = News.create :translations_attributes => [{:title => "Заголовок", :content => "Содержание", :locale => "ru"},
125
137
  {:title => "Resent News", :content => "That is where the text goes", :locale => "en"}]
126
138
 
data/translatable.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "translatable"
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["E-Max"]
12
- s.date = "2012-09-20"
12
+ s.date = "2012-09-23"
13
13
  s.description = "This game was build to make whole proccess of working with translation for DM to be almost invisble. That was THE AIM."
14
14
  s.email = "max@studentify.nl"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-20 00:00:00.000000000Z
12
+ date: 2012-09-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &76245140 !ruby/object:Gem::Requirement
16
+ requirement: &81412010 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *76245140
24
+ version_requirements: *81412010
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &76244900 !ruby/object:Gem::Requirement
27
+ requirement: &81411770 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *76244900
35
+ version_requirements: *81411770
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &76244660 !ruby/object:Gem::Requirement
38
+ requirement: &81411530 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *76244660
46
+ version_requirements: *81411530
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &76244420 !ruby/object:Gem::Requirement
49
+ requirement: &81411290 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *76244420
57
+ version_requirements: *81411290
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &76244180 !ruby/object:Gem::Requirement
60
+ requirement: &81411050 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *76244180
68
+ version_requirements: *81411050
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &76243940 !ruby/object:Gem::Requirement
71
+ requirement: &81410810 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.6.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *76243940
79
+ version_requirements: *81410810
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &76243700 !ruby/object:Gem::Requirement
82
+ requirement: &81410570 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 1.0.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *76243700
90
+ version_requirements: *81410570
91
91
  description: This game was build to make whole proccess of working with translation
92
92
  for DM to be almost invisble. That was THE AIM.
93
93
  email: max@studentify.nl
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  segments:
132
132
  - 0
133
- hash: -775339121
133
+ hash: -89848195
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  none: false
136
136
  requirements: