localization 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/localization.rb +10 -6
- data/lib/localization/version.rb +1 -1
- data/spec/lib/localization_spec.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7558ebec4986dc1feb1b4df6e5ff59384c57ef9
|
4
|
+
data.tar.gz: 4da1907e712acb41b1f4e48b974a70b29ba6c888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6504db30636dd52dd4167cd4c9a3f0132cfecd08144c5318f88268a7acd0b822092d404fafb932d069c114285d83229002b4ca6c49646ca174e20518dcdb5aad
|
7
|
+
data.tar.gz: a76fada2cd8ed09304b4e885722de3a800a0e6580f4f11ac01d1733bb63b6522924786162b225abed7c1583e0859e92b98b9eced49d3fdc673780210d5778dc7
|
data/lib/localization.rb
CHANGED
@@ -12,10 +12,14 @@ class Localization
|
|
12
12
|
@@sources
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize(tree = nil, assignments = nil, parent = nil)
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def initialize(tree = nil, assignments = nil, parent = nil, error = nil)
|
16
|
+
unless error
|
17
|
+
@assignments = assignments || {}
|
18
|
+
@parent = parent
|
19
|
+
@tree = tree || default_tree
|
20
|
+
else
|
21
|
+
@error = error
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def method_missing(name, *arguments, &block)
|
@@ -24,12 +28,12 @@ class Localization
|
|
24
28
|
Localization.new(@tree[name.to_s], arguments.first, self)
|
25
29
|
when !@parent.nil?
|
26
30
|
@parent.send(name, arguments.first)
|
27
|
-
else "Localized text missing for #{name}"
|
31
|
+
else Localization.new(nil, nil, nil, @error || "Localized text missing for #{name}")
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
35
|
def to_s
|
32
|
-
Mustache.render(@tree, @assignments)
|
36
|
+
@error || Mustache.render(@tree, @assignments)
|
33
37
|
end
|
34
38
|
|
35
39
|
private
|
data/lib/localization/version.rb
CHANGED
@@ -58,12 +58,16 @@ describe Localization do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns content any level up if it can find it" do
|
61
|
-
expect(content.
|
61
|
+
expect(content.name.to_s).to eq("Funworld")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "returns unfindable message if it can never find it" do
|
65
65
|
expect(content.woop.to_s).to eq("Localized text missing for woop")
|
66
66
|
end
|
67
|
+
|
68
|
+
it "returns unfindable message even if we call other stuff on it" do
|
69
|
+
expect(content.woop.foop.to_s).to eq("Localized text missing for woop")
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
# def roots
|