herbgobbler 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,10 @@ class BaseTranslationStore
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def start_new_context( new_context )
|
20
|
-
|
20
|
+
# Rails does not allow contexts that begin with an underscore. If we are
|
21
|
+
# converting erb partials that start with underscores we want to ensure
|
22
|
+
# we strip those so that we handle Rails i18n conventions properly.
|
23
|
+
@context = new_context.gsub(/(^|\/)_/, '\1')
|
21
24
|
end
|
22
25
|
|
23
26
|
def add_translation( key, value )
|
@@ -50,16 +50,28 @@ class RailsTranslationStore < BaseTranslationStore
|
|
50
50
|
# and serialize the hash
|
51
51
|
def serialize
|
52
52
|
to_return = "#{@language}:\n"
|
53
|
-
|
53
|
+
last_context_array = []
|
54
54
|
self.each do |context, key, value|
|
55
55
|
whitespace_depth = 2
|
56
|
+
new_context_array = []
|
56
57
|
context_array = context.split('/')
|
57
|
-
|
58
|
-
|
58
|
+
|
59
|
+
context_array.zip(last_context_array) do |new, old|
|
60
|
+
if new != old || new_context_array.any?
|
61
|
+
new_context_array << new
|
62
|
+
else
|
63
|
+
new_context_array << nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
new_context_array.each do |split_context|
|
68
|
+
if split_context != nil
|
69
|
+
to_return << "#{build_whitespace( whitespace_depth )}#{split_context}:\n"
|
70
|
+
end
|
59
71
|
whitespace_depth += 2
|
60
|
-
end
|
61
|
-
|
62
|
-
|
72
|
+
end
|
73
|
+
to_return << "#{build_whitespace( 2 + 2 * context_array.length )}#{key}: \"#{escape(value)}\"\n"
|
74
|
+
last_context_array = context_array
|
63
75
|
end
|
64
76
|
|
65
77
|
to_return.chomp
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herbgobbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|