gettext_simple_rails 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gettext_simple_rails/translators/active_admin_translator.rb +8 -0
- data/lib/gettext_simple_rails/translators/active_record_translator.rb +10 -12
- data/lib/gettext_simple_rails/version.rb +1 -1
- data/spec/active_record_spec.rb +1 -0
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/lib/gettext_simple_rails/active_record_translator_translations.rb +2 -0
- data/spec/dummy/log/test.log +12 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a87f38683b4bbeb1223fc58afd9c567339cde259
|
4
|
+
data.tar.gz: b6be09ff859f2771112810d69c62c220bdb584c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6659037d43de6e7e6284a06ff49f95609ac098a3027fc5696b25311d5c6c835bf03c9bd4f54a734e58b11bf87a2fa03b94ffa9a65f47c22e2cd2537cb227f375
|
7
|
+
data.tar.gz: a0a4794a71e4641ef3438e368b0c33532e4a93b2f5716c574d8f0a43a548f0afb32ccca8d187ed35cb8e97738f8f6a07a2e9c211dc8f68c3fa23070eb870162b
|
@@ -9,6 +9,14 @@ class GettextSimpleRails::Translators::ActiveAdminTranslator
|
|
9
9
|
"globalize" => {
|
10
10
|
"language" => {},
|
11
11
|
"translations" => ""
|
12
|
+
},
|
13
|
+
"devise" => {
|
14
|
+
"email" => {
|
15
|
+
"title" => "Email"
|
16
|
+
},
|
17
|
+
"password" => {
|
18
|
+
"title" => "Password"
|
19
|
+
}
|
12
20
|
}
|
13
21
|
}
|
14
22
|
}
|
@@ -33,17 +33,11 @@ private
|
|
33
33
|
attributes_hash[attribute_name] = {} unless attributes_hash.key?(attribute_name)
|
34
34
|
attribute_hash = attributes_hash[attribute_name]
|
35
35
|
|
36
|
-
if validator.is_a?(ActiveModel::Validations::LengthValidator)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
translations_for_uniqueness_validator(validator, attribute_hash)
|
42
|
-
elsif validator.is_a?(ActiveRecord::Validations::PresenceValidator)
|
43
|
-
translations_for_presence_Validator(validator, attribute_hash)
|
44
|
-
else
|
45
|
-
puts "Unknown validator: #{validator.class.name}"
|
46
|
-
end
|
36
|
+
translations_for_length_validator(validator, attribute_hash) if validator.is_a?(ActiveModel::Validations::LengthValidator)
|
37
|
+
translations_for_format_validator(validator, attribute_hash) if validator.is_a?(ActiveModel::Validations::FormatValidator)
|
38
|
+
translations_for_uniqueness_validator(validator, attribute_hash) if validator.is_a?(ActiveRecord::Validations::UniquenessValidator)
|
39
|
+
translations_for_presence_validator(validator, attribute_hash) if validator.is_a?(ActiveRecord::Validations::PresenceValidator)
|
40
|
+
translations_for_email_validator(validator, attribute_hash) if validator.class.name == "EmailValidator"
|
47
41
|
end
|
48
42
|
end
|
49
43
|
end
|
@@ -71,7 +65,11 @@ private
|
|
71
65
|
attribute_hash["taken"] = "has already been taken"
|
72
66
|
end
|
73
67
|
|
74
|
-
def
|
68
|
+
def translations_for_presence_validator(validator, attribute_hash)
|
75
69
|
attribute_hash["blank"] = "cannot be blank"
|
76
70
|
end
|
71
|
+
|
72
|
+
def translations_for_email_validator(validator, attribute_hash)
|
73
|
+
attribute_hash["invalid"] = "is invalid"
|
74
|
+
end
|
77
75
|
end
|
data/spec/active_record_spec.rb
CHANGED
@@ -24,5 +24,6 @@ describe GettextSimpleRails::Translators::ActiveRecordTranslator do
|
|
24
24
|
cont.should include "_('activerecord.errors.models.user.attributes.name.blank')"
|
25
25
|
cont.should include "_('activerecord.errors.models.user.attributes.name.taken')"
|
26
26
|
cont.should include "_('activerecord.errors.models.user.attributes.name.invalid')"
|
27
|
+
cont.should include "_('activerecord.errors.models.user.attributes.email.invalid')"
|
27
28
|
end
|
28
29
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
require "email_validator"
|
2
|
+
|
1
3
|
class User < ActiveRecord::Base
|
2
4
|
has_many :roles
|
3
5
|
|
4
6
|
validates :name, :length => {:in => 2..255}
|
5
7
|
validates :name, :uniqueness => true, :presence => true
|
6
8
|
validates :name, :format => {:with => /\A[A-z]+\Z/}
|
9
|
+
|
10
|
+
validates :email, :email => true
|
7
11
|
end
|
@@ -12,5 +12,7 @@ class GettextSimpleRails::MonthNames
|
|
12
12
|
_('activerecord.errors.models.user.attributes.name.blank')
|
13
13
|
#. Default value: is invalid
|
14
14
|
_('activerecord.errors.models.user.attributes.name.invalid')
|
15
|
+
#. Default value: is invalid
|
16
|
+
_('activerecord.errors.models.user.attributes.email.invalid')
|
15
17
|
end
|
16
18
|
end
|
data/spec/dummy/log/test.log
CHANGED
@@ -330,3 +330,15 @@
|
|
330
330
|
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
331
331
|
[1m[35m (0.1ms)[0m begin transaction
|
332
332
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
333
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
334
|
+
[1m[35m (0.1ms)[0m begin transaction
|
335
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
336
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
337
|
+
[1m[35m (0.1ms)[0m begin transaction
|
338
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
339
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
340
|
+
[1m[35m (0.1ms)[0m begin transaction
|
341
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
342
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
343
|
+
[1m[35m (0.1ms)[0m begin transaction
|
344
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettext_simple_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: email_validator
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Inspects models and other modules to easily generate .po-files and translate
|
84
98
|
them with POEdit.
|
85
99
|
email:
|