translatable 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/translatable.rb +2 -1
- data/test/posts.rb +1 -1
- data/test/test_translatable.rb +12 -0
- data/translatable.gemspec +2 -2
- metadata +17 -17
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/translatable.rb
CHANGED
@@ -190,8 +190,9 @@ module ActiveRecord
|
|
190
190
|
attr_accessible :translations_attributes
|
191
191
|
|
192
192
|
@translatable[:properties].each do |p|
|
193
|
+
accessible_as = (p.last.delete(:as) || p.first rescue p.first)
|
193
194
|
self.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
194
|
-
def #{
|
195
|
+
def #{accessible_as}
|
195
196
|
current_translation.try(:#{p.first})
|
196
197
|
end
|
197
198
|
RUBY
|
data/test/posts.rb
CHANGED
@@ -56,7 +56,7 @@ class Post < ActiveRecord::Base
|
|
56
56
|
belongs_to :writer
|
57
57
|
|
58
58
|
translatable do
|
59
|
-
translatable :title, :presence => true, :uniqueness => true
|
59
|
+
translatable :title, :as => :translated_title, :presence => true, :uniqueness => true
|
60
60
|
translatable :content, :presence => true
|
61
61
|
translatable_model 'TranslatedPost'
|
62
62
|
translatable_origin :post
|
data/test/test_translatable.rb
CHANGED
@@ -220,6 +220,18 @@ class TestDmTranslatable < Test::Unit::TestCase
|
|
220
220
|
assert_equal post, post.translations.first.post
|
221
221
|
end
|
222
222
|
|
223
|
+
def test_attr_as
|
224
|
+
post = Post.create :translations_attributes => [{:title => "Заголовок",:content => "Содержание", :locale => "ru"},
|
225
|
+
{:title => "Resent Post", :content => "That is where the text goes", :locale => "en"}]
|
226
|
+
assert post.persisted?, "Message had errors: #{post.errors.inspect}"
|
227
|
+
|
228
|
+
assert_equal "Resent Post", post.translated_title
|
229
|
+
|
230
|
+
::I18n.locale = :ru
|
231
|
+
assert_equal "Заголовок", post.translated_title
|
232
|
+
::I18n.locale = ::I18n.default_locale
|
233
|
+
end
|
234
|
+
|
223
235
|
def test_protected_mass_assigment
|
224
236
|
tm = TranslatedMessage.new( :title => "Resent Post", :content => "That is where the text goes", :locale => "en", :message_id => 1)
|
225
237
|
|
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.
|
8
|
+
s.version = "0.2.1"
|
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-
|
12
|
+
s.date = "2012-09-20"
|
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.
|
4
|
+
version: 0.2.1
|
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-
|
12
|
+
date: 2012-09-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement: &
|
16
|
+
requirement: &76245140 !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: *
|
24
|
+
version_requirements: *76245140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: i18n
|
27
|
-
requirement: &
|
27
|
+
requirement: &76244900 !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: *
|
35
|
+
version_requirements: *76244900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &76244660 !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: *
|
46
|
+
version_requirements: *76244660
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &76244420 !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: *
|
57
|
+
version_requirements: *76244420
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &76244180 !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: *
|
68
|
+
version_requirements: *76244180
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &76243940 !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: *
|
79
|
+
version_requirements: *76243940
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rcov
|
82
|
-
requirement: &
|
82
|
+
requirement: &76243700 !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: *
|
90
|
+
version_requirements: *76243700
|
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:
|
133
|
+
hash: -775339121
|
134
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
135
|
none: false
|
136
136
|
requirements:
|