dm-validations-i18n 0.3.1 → 0.3.2
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.
- data/Gemfile +11 -0
- data/Gemfile.lock +41 -0
- data/Rakefile +28 -29
- data/VERSION +1 -1
- data/dm-validations-i18n.gemspec +39 -22
- data/lib/class.rb +48 -0
- data/lib/dm-validations-i18n.rb +1 -0
- data/locale/it.yml +22 -0
- data/test/test_dm-validations-i18n.rb +92 -11
- metadata +98 -19
- data/.gitignore +0 -21
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.4)
|
5
|
+
configuration (1.2.0)
|
6
|
+
dm-core (1.1.0)
|
7
|
+
addressable (~> 2.2.4)
|
8
|
+
dm-validations (1.1.0)
|
9
|
+
dm-core (~> 1.1.0)
|
10
|
+
git (1.2.5)
|
11
|
+
guard (0.3.0)
|
12
|
+
open_gem (~> 1.4.2)
|
13
|
+
thor (~> 0.14.6)
|
14
|
+
guard-test (0.1.6)
|
15
|
+
guard (~> 0.3.0)
|
16
|
+
test-unit (~> 2.1.2)
|
17
|
+
jeweler (1.5.2)
|
18
|
+
bundler (~> 1.0.0)
|
19
|
+
git (>= 1.2.5)
|
20
|
+
rake
|
21
|
+
launchy (0.3.7)
|
22
|
+
configuration (>= 0.0.5)
|
23
|
+
rake (>= 0.8.1)
|
24
|
+
open_gem (1.4.2)
|
25
|
+
launchy (~> 0.3.5)
|
26
|
+
rake (0.8.7)
|
27
|
+
rcov (0.9.9)
|
28
|
+
shoulda (2.11.3)
|
29
|
+
test-unit (2.1.2)
|
30
|
+
thor (0.14.6)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler (~> 1.0.0)
|
37
|
+
dm-validations (>= 1.0.2)
|
38
|
+
guard-test
|
39
|
+
jeweler (~> 1.5.2)
|
40
|
+
rcov
|
41
|
+
shoulda (>= 2.11.3)
|
data/Rakefile
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
2
10
|
require 'rake'
|
3
11
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "dm-validations-i18n"
|
16
|
+
gem.homepage = "http://github.com/komagata/dm-validations-i18n"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{localize dm-validations}
|
19
|
+
gem.description = %Q{Localize error messages in dm-validations.}
|
20
|
+
gem.email = "komagata@gmail.com"
|
21
|
+
gem.authors = ["Masaki Komagata"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
gem.add_runtime_dependency 'dm-validations', '>= 1.0.2'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
20
26
|
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
21
28
|
|
22
29
|
require 'rake/testtask'
|
23
30
|
Rake::TestTask.new(:test) do |test|
|
@@ -26,21 +33,13 @@ Rake::TestTask.new(:test) do |test|
|
|
26
33
|
test.verbose = true
|
27
34
|
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
test.verbose = true
|
35
|
-
end
|
36
|
-
rescue LoadError
|
37
|
-
task :rcov do
|
38
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
-
end
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
40
41
|
end
|
41
42
|
|
42
|
-
task :test => :check_dependencies
|
43
|
-
|
44
43
|
task :default => :test
|
45
44
|
|
46
45
|
require 'rake/rdoctask'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/dm-validations-i18n.gemspec
CHANGED
@@ -1,61 +1,78 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-validations-i18n}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Masaki
|
12
|
-
s.date = %q{
|
11
|
+
s.authors = ["Masaki Komagata"]
|
12
|
+
s.date = %q{2011-04-06}
|
13
13
|
s.description = %q{Localize error messages in dm-validations.}
|
14
14
|
s.email = %q{komagata@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"dm-validations-i18n.gemspec",
|
28
|
+
"lib/class.rb",
|
29
|
+
"lib/dm-validations-i18n.rb",
|
30
|
+
"locale/en.yml",
|
31
|
+
"locale/it.yml",
|
32
|
+
"locale/ja.yml",
|
33
|
+
"locale/zh-CN.yml",
|
34
|
+
"locale/zh-TW.yml",
|
35
|
+
"test/helper.rb",
|
36
|
+
"test/test_dm-validations-i18n.rb"
|
34
37
|
]
|
35
38
|
s.homepage = %q{http://github.com/komagata/dm-validations-i18n}
|
36
|
-
s.
|
39
|
+
s.licenses = ["MIT"]
|
37
40
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = %q{1.
|
41
|
+
s.rubygems_version = %q{1.4.2}
|
39
42
|
s.summary = %q{localize dm-validations}
|
40
43
|
s.test_files = [
|
41
44
|
"test/helper.rb",
|
42
|
-
|
45
|
+
"test/test_dm-validations-i18n.rb"
|
43
46
|
]
|
44
47
|
|
45
48
|
if s.respond_to? :specification_version then
|
46
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
49
|
s.specification_version = 3
|
48
50
|
|
49
51
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
52
|
s.add_runtime_dependency(%q<dm-validations>, [">= 1.0.2"])
|
51
53
|
s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
|
54
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
55
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
56
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<guard-test>, [">= 0"])
|
58
|
+
s.add_runtime_dependency(%q<dm-validations>, [">= 1.0.2"])
|
52
59
|
else
|
53
60
|
s.add_dependency(%q<dm-validations>, [">= 1.0.2"])
|
54
61
|
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
64
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
65
|
+
s.add_dependency(%q<guard-test>, [">= 0"])
|
66
|
+
s.add_dependency(%q<dm-validations>, [">= 1.0.2"])
|
55
67
|
end
|
56
68
|
else
|
57
69
|
s.add_dependency(%q<dm-validations>, [">= 1.0.2"])
|
58
70
|
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
71
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
73
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
74
|
+
s.add_dependency(%q<guard-test>, [">= 0"])
|
75
|
+
s.add_dependency(%q<dm-validations>, [">= 1.0.2"])
|
59
76
|
end
|
60
77
|
end
|
61
78
|
|
data/lib/class.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
class Class
|
2
|
+
def cattr_reader(*syms)
|
3
|
+
syms.flatten.each do |sym|
|
4
|
+
next if sym.is_a?(Hash)
|
5
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
6
|
+
unless defined? @@#{sym}
|
7
|
+
@@#{sym} = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.#{sym}
|
11
|
+
@@#{sym}
|
12
|
+
end
|
13
|
+
|
14
|
+
def #{sym}
|
15
|
+
@@#{sym}
|
16
|
+
end
|
17
|
+
RUBY
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def cattr_writer(*syms)
|
22
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
23
|
+
syms.flatten.each do |sym|
|
24
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
25
|
+
unless defined? @@#{sym}
|
26
|
+
@@#{sym} = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.#{sym}=(obj)
|
30
|
+
@@#{sym} = obj
|
31
|
+
end
|
32
|
+
RUBY
|
33
|
+
|
34
|
+
unless options[:instance_writer] == false
|
35
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
36
|
+
def #{sym}=(obj)
|
37
|
+
@@#{sym} = obj
|
38
|
+
end
|
39
|
+
RUBY
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def cattr_accessor(*syms, &blk)
|
45
|
+
cattr_reader(*syms)
|
46
|
+
cattr_writer(*syms, &blk)
|
47
|
+
end
|
48
|
+
end
|
data/lib/dm-validations-i18n.rb
CHANGED
data/locale/it.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
absent: %s non deve essere presente
|
2
|
+
inclusion: "%s deve essere un valore tra questi: %s"
|
3
|
+
invalid: %s ha un formato non valido
|
4
|
+
confirmation: %s non è confermata
|
5
|
+
accepted: %s non è accettato/a
|
6
|
+
'nil': %s non deve essere nullo
|
7
|
+
blank: %s non deve essere vuoto
|
8
|
+
length_between: %s deve essere tra %s e %s caratteri
|
9
|
+
too_long: %s deve essere massimo %s caratteri
|
10
|
+
too_short: %s deve essere minimo %s caratteri
|
11
|
+
wrong_length: %s deve essere %s caratteri
|
12
|
+
taken: %s è già in uso
|
13
|
+
not_a_number: %s deve essere un numero
|
14
|
+
not_an_integer: %s deve essere un numero intero
|
15
|
+
greater_than: %s deve essere più grande di %s
|
16
|
+
greater_than_or_equal_to: %s deve essere più grande o uguale a %s
|
17
|
+
equal_to: %s deve essere uguale a %s
|
18
|
+
not_equal_to: %s non deve essere uguale a %s
|
19
|
+
less_than: %s deve essere minore di %s
|
20
|
+
less_than_or_equal_to: %s deve essere minore o uguale a %s
|
21
|
+
value_between: %s deve essere tra %s e %s
|
22
|
+
primitive: %s deve essere di tipo %s
|
@@ -4,19 +4,29 @@ class TestDmValidationsI18n < Test::Unit::TestCase
|
|
4
4
|
context 'load_locale' do
|
5
5
|
should "return locale data" do
|
6
6
|
assert_equal '%s must be absent', DataMapper::Validations::I18n.load_locale('en')['absent']
|
7
|
+
assert_equal '%s non deve essere presente', DataMapper::Validations::I18n.load_locale('it')['absent']
|
7
8
|
assert_equal '%sがありません。', DataMapper::Validations::I18n.load_locale('ja')['absent']
|
9
|
+
assert_equal '%s 必须留空', DataMapper::Validations::I18n.load_locale('zh-CN')['absent']
|
10
|
+
assert_equal '%s 必須留空', DataMapper::Validations::I18n.load_locale('zh-TW')['absent']
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
11
14
|
context 'locale!' do
|
12
15
|
should "set to default_error_messages" do
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
+
DataMapper::Validations::I18n.localize!('en')
|
17
|
+
assert_equal '%s must be absent', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:absent]
|
16
18
|
|
17
19
|
DataMapper::Validations::I18n.localize!('ja')
|
20
|
+
assert_equal '%sがありません。', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:absent]
|
21
|
+
|
22
|
+
DataMapper::Validations::I18n.localize!('it')
|
23
|
+
assert_equal '%s non deve essere presente', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:absent]
|
24
|
+
|
25
|
+
DataMapper::Validations::I18n.localize!('zh-CN')
|
26
|
+
assert_equal '%s 必须留空', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:absent]
|
18
27
|
|
19
|
-
|
28
|
+
DataMapper::Validations::I18n.localize!('zh-TW')
|
29
|
+
assert_equal '%s 必須留空', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:absent]
|
20
30
|
end
|
21
31
|
end
|
22
32
|
|
@@ -25,6 +35,18 @@ class TestDmValidationsI18n < Test::Unit::TestCase
|
|
25
35
|
# manually set to nil, beacuse this test might not be the first to run.
|
26
36
|
DataMapper::Validations::I18n.field_name_translator = nil
|
27
37
|
|
38
|
+
DataMapper::Validations::I18n.localize!('en')
|
39
|
+
assert_equal("height has an invalid format", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
40
|
+
|
41
|
+
DataMapper::Validations::I18n.localize!('it')
|
42
|
+
assert_equal("height ha un formato non valido", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
43
|
+
|
44
|
+
DataMapper::Validations::I18n.localize!('ja')
|
45
|
+
assert_equal("heightは不正な値です。", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
46
|
+
|
47
|
+
DataMapper::Validations::I18n.localize!('zh-CN')
|
48
|
+
assert_equal("height 无效", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
49
|
+
|
28
50
|
DataMapper::Validations::I18n.localize!('zh-TW')
|
29
51
|
assert_equal("height 無效", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
30
52
|
end
|
@@ -37,33 +59,92 @@ class TestDmValidationsI18n < Test::Unit::TestCase
|
|
37
59
|
end
|
38
60
|
end
|
39
61
|
|
40
|
-
DataMapper::Validations::I18n.localize!('zh-TW')
|
41
62
|
DataMapper::Validations::I18n.translate_field_name_with :rails
|
42
63
|
|
64
|
+
DataMapper::Validations::I18n.localize!('en')
|
65
|
+
assert_equal("Dummy I18n.t has an invalid format", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
66
|
+
|
67
|
+
DataMapper::Validations::I18n.localize!('it')
|
68
|
+
assert_equal("Dummy I18n.t ha un formato non valido", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
69
|
+
|
70
|
+
DataMapper::Validations::I18n.localize!('ja')
|
71
|
+
assert_equal("Dummy I18n.tは不正な値です。", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
72
|
+
|
73
|
+
DataMapper::Validations::I18n.localize!('zh-CN')
|
74
|
+
assert_equal("Dummy I18n.t 无效", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
75
|
+
|
76
|
+
DataMapper::Validations::I18n.localize!('zh-TW')
|
43
77
|
assert_equal("Dummy I18n.t 無效", DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height))
|
44
78
|
end
|
45
79
|
|
46
80
|
should "localize field names with callback" do
|
81
|
+
DataMapper::Validations::I18n.translate_field_name_with {|field| "Dummy" }
|
82
|
+
|
83
|
+
DataMapper::Validations::I18n.localize!('en')
|
84
|
+
assert_equal 'Dummy has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
85
|
+
|
86
|
+
DataMapper::Validations::I18n.localize!('it')
|
87
|
+
assert_equal 'Dummy ha un formato non valido', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
88
|
+
|
89
|
+
DataMapper::Validations::I18n.localize!('ja')
|
90
|
+
assert_equal 'Dummyは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
91
|
+
|
92
|
+
DataMapper::Validations::I18n.localize!('zh-CN')
|
93
|
+
assert_equal 'Dummy 无效', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
94
|
+
|
47
95
|
DataMapper::Validations::I18n.localize!('zh-TW')
|
48
|
-
DataMapper::Validations::I18n.translate_field_name_with do |field|
|
49
|
-
"Dummy"
|
50
|
-
end
|
51
96
|
assert_equal 'Dummy 無效', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
52
97
|
end
|
53
98
|
|
54
99
|
should "localize field names with hash" do
|
100
|
+
DataMapper::Validations::I18n.localize!('en')
|
101
|
+
DataMapper::Validations::I18n.translate_field_name_with({'en' => { "height" => "height", "weight" => "weight" }})
|
102
|
+
assert_equal '%s has an invalid format', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:invalid]
|
103
|
+
assert_equal 'height has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
104
|
+
assert_equal 'weight has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :weight)
|
105
|
+
assert_equal 'length has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :length), "Fallback to original field name if missing the translated version."
|
106
|
+
|
107
|
+
# TODO: for it
|
108
|
+
|
109
|
+
DataMapper::Validations::I18n.localize!('ja')
|
110
|
+
DataMapper::Validations::I18n.translate_field_name_with({'ja' => { "height" => "高さ", "weight" => "重さ" }})
|
111
|
+
assert_equal '%sは不正な値です。', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:invalid]
|
112
|
+
assert_equal '高さは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
113
|
+
assert_equal '重さは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :weight)
|
114
|
+
assert_equal 'lengthは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :length), "Fallback to original field name if missing the translated version."
|
115
|
+
|
116
|
+
# TODO: for zh-CN
|
117
|
+
|
55
118
|
DataMapper::Validations::I18n.localize!('zh-TW')
|
56
119
|
DataMapper::Validations::I18n.translate_field_name_with({'zh-TW' => { "height" => "高度", "weight" => "重量" }})
|
57
|
-
|
58
120
|
assert_equal '%s 無效', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:invalid]
|
59
|
-
|
60
121
|
assert_equal '高度 無效', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
61
122
|
assert_equal '重量 無效', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :weight)
|
62
|
-
|
63
123
|
assert_equal 'length 無效', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :length), "Fallback to original field name if missing the translated version."
|
64
124
|
end
|
65
125
|
|
66
126
|
should "localize field names with hash, even with diffenert setup order." do
|
127
|
+
=begin
|
128
|
+
DataMapper::Validations::I18n.translate_field_name_with({'en' => { "height" => "height", "weight" => "weight" }})
|
129
|
+
DataMapper::Validations::I18n.localize!('en')
|
130
|
+
assert_equal '%s has an invalid format', DataMapper::Validations::ValidationErrors.send(:class_variable_get, '@@default_error_messages')[:invalid]
|
131
|
+
assert_equal 'height has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
132
|
+
assert_equal 'weight has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :weight)
|
133
|
+
assert_equal 'length has an invalid format', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :length), "Fallback to original field name if missing the translated version."
|
134
|
+
=end
|
135
|
+
|
136
|
+
# TODO: for it
|
137
|
+
|
138
|
+
=begin
|
139
|
+
DataMapper::Validations::I18n.translate_field_name_with({'ja' => { "height" => "高さ", "weight" => "重さ" }})
|
140
|
+
DataMapper::Validations::I18n.localize!('ja')
|
141
|
+
assert_equal '高さは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
142
|
+
assert_equal '重さは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :weight)
|
143
|
+
assert_equal 'lengthは不正な値です。', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :length), "Fallback to original field name if missing the translated version."
|
144
|
+
=end
|
145
|
+
|
146
|
+
# TODO: for zh-CN
|
147
|
+
|
67
148
|
DataMapper::Validations::I18n.translate_field_name_with({'zh-TW' => { "height" => "高度", "weight" => "重量" }})
|
68
149
|
DataMapper::Validations::I18n.localize!('zh-TW')
|
69
150
|
assert_equal '高度 無效', DataMapper::Validations::ValidationErrors.default_error_message(:invalid, :height)
|
metadata
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-validations-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- Masaki
|
13
|
+
- Masaki Komagata
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-04-06 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: dm-validations
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
name: dm-validations
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
27
|
requirements:
|
27
28
|
- - ">="
|
@@ -32,12 +33,12 @@ dependencies:
|
|
32
33
|
- 0
|
33
34
|
- 2
|
34
35
|
version: 1.0.2
|
35
|
-
|
36
|
-
version_requirements: *id001
|
36
|
+
requirement: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name: shoulda
|
39
38
|
prerelease: false
|
40
|
-
|
39
|
+
name: shoulda
|
40
|
+
type: :development
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
42
|
none: false
|
42
43
|
requirements:
|
43
44
|
- - ">="
|
@@ -48,8 +49,83 @@ dependencies:
|
|
48
49
|
- 11
|
49
50
|
- 3
|
50
51
|
version: 2.11.3
|
52
|
+
requirement: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
name: bundler
|
56
|
+
type: :development
|
57
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 23
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 0
|
66
|
+
- 0
|
67
|
+
version: 1.0.0
|
68
|
+
requirement: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
prerelease: false
|
71
|
+
name: jeweler
|
72
|
+
type: :development
|
73
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 7
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 5
|
82
|
+
- 2
|
83
|
+
version: 1.5.2
|
84
|
+
requirement: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
prerelease: false
|
87
|
+
name: rcov
|
88
|
+
type: :development
|
89
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirement: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
prerelease: false
|
101
|
+
name: guard-test
|
51
102
|
type: :development
|
52
|
-
version_requirements:
|
103
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
version: "0"
|
112
|
+
requirement: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
prerelease: false
|
115
|
+
name: dm-validations
|
116
|
+
type: :runtime
|
117
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 19
|
123
|
+
segments:
|
124
|
+
- 1
|
125
|
+
- 0
|
126
|
+
- 2
|
127
|
+
version: 1.0.2
|
128
|
+
requirement: *id007
|
53
129
|
description: Localize error messages in dm-validations.
|
54
130
|
email: komagata@gmail.com
|
55
131
|
executables: []
|
@@ -61,14 +137,17 @@ extra_rdoc_files:
|
|
61
137
|
- README.rdoc
|
62
138
|
files:
|
63
139
|
- .document
|
64
|
-
-
|
140
|
+
- Gemfile
|
141
|
+
- Gemfile.lock
|
65
142
|
- LICENSE
|
66
143
|
- README.rdoc
|
67
144
|
- Rakefile
|
68
145
|
- VERSION
|
69
146
|
- dm-validations-i18n.gemspec
|
147
|
+
- lib/class.rb
|
70
148
|
- lib/dm-validations-i18n.rb
|
71
149
|
- locale/en.yml
|
150
|
+
- locale/it.yml
|
72
151
|
- locale/ja.yml
|
73
152
|
- locale/zh-CN.yml
|
74
153
|
- locale/zh-TW.yml
|
@@ -76,11 +155,11 @@ files:
|
|
76
155
|
- test/test_dm-validations-i18n.rb
|
77
156
|
has_rdoc: true
|
78
157
|
homepage: http://github.com/komagata/dm-validations-i18n
|
79
|
-
licenses:
|
80
|
-
|
158
|
+
licenses:
|
159
|
+
- MIT
|
81
160
|
post_install_message:
|
82
|
-
rdoc_options:
|
83
|
-
|
161
|
+
rdoc_options: []
|
162
|
+
|
84
163
|
require_paths:
|
85
164
|
- lib
|
86
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -104,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
183
|
requirements: []
|
105
184
|
|
106
185
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.
|
186
|
+
rubygems_version: 1.4.2
|
108
187
|
signing_key:
|
109
188
|
specification_version: 3
|
110
189
|
summary: localize dm-validations
|