rabelyoda 1.1.0 → 1.1.1
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/VERSION +1 -1
- data/lib/rabelyoda/hash.rb +6 -2
- data/test/rabelyoda/hash_test.rb +42 -0
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/lib/rabelyoda/hash.rb
CHANGED
@@ -4,8 +4,8 @@ class Hash
|
|
4
4
|
def locale_diff(b)
|
5
5
|
a = self
|
6
6
|
(a.keys | b.keys).inject({}) do |diff, k|
|
7
|
-
if a[k].respond_to?(:
|
8
|
-
deeper_diff = a[k].
|
7
|
+
if a[k].respond_to?(:locale_diff) && b[k].respond_to?(:locale_diff)
|
8
|
+
deeper_diff = a[k].locale_diff(b[k])
|
9
9
|
diff[k] = deeper_diff if deeper_diff != {}
|
10
10
|
else
|
11
11
|
if !a.keys.include?(k)
|
@@ -13,6 +13,10 @@ class Hash
|
|
13
13
|
# diff[k] = 'extra'
|
14
14
|
elsif !b.keys.include?(k)
|
15
15
|
diff[k] = '[pls translate]' + a[k]
|
16
|
+
elsif b.keys.include?(k) && b[k] == a[k]
|
17
|
+
diff[k] = '[pls translate]' + a[k]
|
18
|
+
elsif b.keys.include?(k)
|
19
|
+
# do nothing
|
16
20
|
else
|
17
21
|
# keep translated strings
|
18
22
|
diff[k] = b[k]
|
@@ -0,0 +1,42 @@
|
|
1
|
+
root = File.expand_path(File.dirname(__FILE__))
|
2
|
+
require File.join root, '../../lib/rabelyoda/hash'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
module RabelYoda
|
6
|
+
class HashTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@en = {'user' => "User",
|
9
|
+
'company' => 'Company',
|
10
|
+
'position' => 'Position',
|
11
|
+
'department' => 'Department',
|
12
|
+
'activerecord' => {
|
13
|
+
'validations' => {
|
14
|
+
'email' => 'Should be like email',
|
15
|
+
'name' => 'Should contain only letters'}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
@ru = {'user' => "Пользователь",
|
19
|
+
'company' => 'Компания',
|
20
|
+
'position' => 'Position',
|
21
|
+
'activerecord' => {
|
22
|
+
'validations' => {
|
23
|
+
'email' => 'Should be like email'},
|
24
|
+
'age' => 'Должен быть числом'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_locale_diff
|
30
|
+
assert_equal @en.locale_diff(@ru), {
|
31
|
+
'department' => '[pls translate]Department',
|
32
|
+
'position' => '[pls translate]Position',
|
33
|
+
'activerecord' => {
|
34
|
+
'validations' => {
|
35
|
+
'name' => '[pls translate]Should contain only letters',
|
36
|
+
'email' => '[pls translate]Should be like email'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 1
|
9
|
+
version: 1.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andrey Subbotin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-24 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
- rabelyoda
|
20
20
|
dependencies:
|
@@ -100,5 +100,5 @@ rubygems_version: 1.3.6
|
|
100
100
|
signing_key:
|
101
101
|
specification_version: 3
|
102
102
|
summary: Rails project localization made easy
|
103
|
-
test_files:
|
104
|
-
|
103
|
+
test_files:
|
104
|
+
- test/rabelyoda/hash_test.rb
|