haml-i18n-extractor 0.5.8 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +93 -52
- data/lib/haml-i18n-extractor/extraction/finder/exception_finder.rb +23 -5
- data/lib/haml-i18n-extractor/extraction/finder/text_finder.rb +1 -1
- data/lib/haml-i18n-extractor/helpers.rb +0 -12
- data/lib/haml-i18n-extractor/version.rb +1 -1
- data/test/exception_finder_test.rb +2 -1
- data/test/support/ex2.output.haml +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -40,70 +40,111 @@ This should be a before and after picture of using this lib, whether using the n
|
|
40
40
|
- Before running (old haml):
|
41
41
|
|
42
42
|
<pre>
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
43
|
+
|
44
|
+
shai@comp $ cat /tmp/foo.haml
|
45
|
+
|
46
|
+
= render :partial => "layouts/adminnav", :locals => {:account => nil }
|
47
|
+
.row
|
48
|
+
.admin.span12
|
49
|
+
%h1
|
50
|
+
Billing Month
|
51
|
+
= @billing_month.display_name
|
52
|
+
|
53
|
+
%h3
|
54
|
+
All Invoices Billable?
|
55
|
+
%span{:style => (@billable_invoices == @active_invoices) ? "color: #090" : "color: #900"}
|
56
|
+
= "#{@billable_invoices} out of #{@active_invoices}"
|
57
|
+
%h3
|
58
|
+
24 hours past end of billing month?
|
59
|
+
%span{:style => (@billing_month.past_cutoff) ? "color: #090" : "color: #900"}
|
60
|
+
= @billing_month.past_cutoff
|
61
|
+
|
62
|
+
- if @billing_month.open?
|
63
|
+
- if @billing_month.past_cutoff && (@billable_invoices == @active_invoices)
|
64
|
+
= form_for @billing_month, :url => close_admin_billing_month_url(@billing_month), :method => "POST" do |f|
|
65
|
+
= f.submit "Close This Month (cannot be undone)", :class => 'btn btn-primary'
|
66
|
+
- else
|
67
|
+
%p
|
68
|
+
Billing Month cannot be closed yet.
|
69
|
+
%p
|
70
|
+
Closing the billing month will mark all the invoices as "Posted".
|
71
|
+
%p
|
72
|
+
After closing you will need to do a payment run to charge all the affected customers for the amounts due in posted invoices.
|
73
|
+
- elsif @billing_month.closing?
|
74
|
+
Month is currently closing (reload to check if it's done)
|
75
|
+
- elsif @billing_month.closed?
|
76
|
+
Month is closed
|
63
77
|
</pre>
|
64
78
|
|
65
79
|
- After running (new haml, new yaml):
|
66
80
|
|
67
|
-
|
81
|
+
running this:
|
68
82
|
|
69
|
-
|
83
|
+
`shai@comp /tmp $ haml-i18n-extractor foo.haml -n -y en.yml`
|
84
|
+
|
85
|
+
Should give you the below...
|
86
|
+
|
87
|
+
Note how some of the strings are replaced, and the ones that shouldn't, aren't. Yup. Beautiful, for 2 and half seconds of work, right?
|
70
88
|
|
71
89
|
<pre>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
shai@comp $ cat /tmp/foo.haml
|
92
|
+
|
93
|
+
= render :partial => "layouts/adminnav", :locals => {:account => nil }
|
94
|
+
.row
|
95
|
+
.admin.span12
|
96
|
+
%h1
|
97
|
+
= t('.billing_month')
|
98
|
+
= @billing_month.display_name
|
99
|
+
|
100
|
+
%h3
|
101
|
+
= t('.all_invoices_billable')
|
102
|
+
%span{:style => (@billable_invoices == @active_invoices) ? "color: #090" : "color: #900"}
|
103
|
+
=t('.billable_invoices_out_of_activ', :billable_invoices => (@billable_invoices), :active_invoices => (@active_invoices))
|
104
|
+
%h3
|
105
|
+
= t('.24_hours_past_end_of_billing_m')
|
106
|
+
%span{:style => (@billing_month.past_cutoff) ? "color: #090" : "color: #900"}
|
107
|
+
= @billing_month.past_cutoff
|
108
|
+
|
109
|
+
- if @billing_month.open?
|
110
|
+
- if @billing_month.past_cutoff && (@billable_invoices == @active_invoices)
|
111
|
+
= form_for @billing_month, :url => close_admin_billing_month_url(@billing_month), :method => "POST" do |f|
|
112
|
+
= f.submit "Close This Month (cannot be undone)", :class => 'btn btn-primary'
|
113
|
+
- else
|
114
|
+
%p
|
115
|
+
= t('.billing_month_cannot_be_closed')
|
116
|
+
%p
|
117
|
+
= t('.closing_the_billing_month_will')
|
118
|
+
%p
|
119
|
+
= t('.after_closing_you_will_need_to')
|
120
|
+
- elsif @billing_month.closing?
|
121
|
+
= t('.month_is_currently_closing_rel')
|
122
|
+
- elsif @billing_month.closed?
|
123
|
+
= t('.month_is_closed')
|
92
124
|
</pre>
|
93
125
|
|
94
126
|
Yaml:
|
95
127
|
|
96
128
|
<pre>
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
129
|
+
|
130
|
+
shai@comp $ cat /tmp/en.yml
|
131
|
+
|
132
|
+
---
|
133
|
+
en:
|
134
|
+
tmp:
|
135
|
+
foo:
|
136
|
+
billing_month: Billing Month
|
137
|
+
all_invoices_billable: All Invoices Billable?
|
138
|
+
billable_invoices_out_of_activ: ! ' "%{billable_invoices} out of %{active_invoices}"'
|
139
|
+
24_hours_past_end_of_billing_m: 24 hours past end of billing month?
|
140
|
+
billing_month_cannot_be_closed: Billing Month cannot be closed yet.
|
141
|
+
closing_the_billing_month_will: Closing the billing month will mark all the
|
142
|
+
invoices as "Posted".
|
143
|
+
after_closing_you_will_need_to: After closing you will need to do a payment
|
144
|
+
run to charge all the affected customers for the amounts due in posted invoices.
|
145
|
+
month_is_currently_closing_rel: Month is currently closing (reload to check
|
146
|
+
if it's done)
|
147
|
+
month_is_closed: Month is closed
|
107
148
|
</pre>
|
108
149
|
|
109
150
|
|
@@ -3,20 +3,38 @@ module Haml
|
|
3
3
|
class Extractor
|
4
4
|
class ExceptionFinder
|
5
5
|
|
6
|
-
def initialize(text)
|
7
|
-
@text = text
|
8
|
-
end
|
9
|
-
|
10
6
|
LINK_TO_REGEX_DOUBLE_Q = /link_to\s*\(?\s*["](.*?)["]\s*,\s*(.*)\)?/
|
11
7
|
LINK_TO_REGEX_SINGLE_Q = /link_to\s*\(?\s*['](.*?)[']\s*,\s*(.*)\)?/
|
12
8
|
LINK_TO_BLOCK_FORM_SINGLE_Q = /link_to\s*\(?['](.*?)[']\)?.*\sdo\s*$/
|
13
9
|
LINK_TO_BLOCK_FORM_DOUBLE_Q = /link_to\s*\(?["](.*?)["]\)?.*\sdo\s*$/
|
14
10
|
LINK_TO_NO_QUOTES = /link_to\s*\(?([^'"]*?)\)?.*/
|
15
11
|
|
12
|
+
FORM_SUBMIT_BUTTON_SINGLE_Q = /[a-z]\.submit\s?['](.*?)['].*$/
|
13
|
+
FORM_SUBMIT_BUTTON_DOUBLE_Q = /[a-z]\.submit\s?["](.*?)["].*$/
|
14
|
+
|
16
15
|
# this class simply returns text except for anything that matches these regexes.
|
17
16
|
# returns first match.
|
18
17
|
EXCEPTION_MATCHES = [ LINK_TO_BLOCK_FORM_DOUBLE_Q, LINK_TO_BLOCK_FORM_SINGLE_Q,
|
19
|
-
LINK_TO_REGEX_DOUBLE_Q, LINK_TO_REGEX_SINGLE_Q , LINK_TO_NO_QUOTES
|
18
|
+
LINK_TO_REGEX_DOUBLE_Q, LINK_TO_REGEX_SINGLE_Q , LINK_TO_NO_QUOTES,
|
19
|
+
FORM_SUBMIT_BUTTON_SINGLE_Q, FORM_SUBMIT_BUTTON_DOUBLE_Q]
|
20
|
+
|
21
|
+
|
22
|
+
def initialize(text)
|
23
|
+
@text = text
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.could_match_script?(txt)
|
27
|
+
# want to match:
|
28
|
+
# = 'foo'
|
29
|
+
# = "foo"
|
30
|
+
# = link_to 'bla'
|
31
|
+
#
|
32
|
+
# but not match:
|
33
|
+
# = ruby_var = 2
|
34
|
+
scanner = StringScanner.new(txt)
|
35
|
+
scanner.scan(/\s+/)
|
36
|
+
scanner.scan(/['"]/) || EXCEPTION_MATCHES.any? {|regex| txt.match(regex) }
|
37
|
+
end
|
20
38
|
|
21
39
|
def find
|
22
40
|
ret = @text
|
@@ -49,18 +49,6 @@ module Haml
|
|
49
49
|
txt.match(/link_to/) || txt.match(/^\s*['"]/) # %element= 'foo'
|
50
50
|
end
|
51
51
|
|
52
|
-
def could_match_script?(txt)
|
53
|
-
# want to match:
|
54
|
-
# = 'foo'
|
55
|
-
# = "foo"
|
56
|
-
# = link_to 'bla'
|
57
|
-
#
|
58
|
-
# but not match:
|
59
|
-
# = ruby_var = 2
|
60
|
-
scanner = StringScanner.new(txt)
|
61
|
-
scanner.scan(/\s+/)
|
62
|
-
scanner.scan(/['"]/) || scanner.scan(/link_to/)
|
63
|
-
end
|
64
52
|
end
|
65
53
|
|
66
54
|
module Highline
|
@@ -19,7 +19,8 @@ module Haml
|
|
19
19
|
%{link_to("TEXT"), role: 'button', data: {toggle: 'dropdown'} do} => "TEXT",
|
20
20
|
%{link_to "TEXT", role: 'button', data: {toggle: 'dropdown'} do} => "TEXT",
|
21
21
|
%{link_to pending_account_invoices_path(account) do} => "",
|
22
|
-
%{link_to(pending_account_invoices_path(account),"http://random")} => ""
|
22
|
+
%{link_to(pending_account_invoices_path(account),"http://random")} => "",
|
23
|
+
%{f.submit "Close This Month (cannot be undone)", :class => 'btn btn-primary'} => "Close This Month (cannot be undone)"
|
23
24
|
}
|
24
25
|
|
25
26
|
def test_it_finds_text_pretty_simply
|
@@ -17,7 +17,7 @@
|
|
17
17
|
- if @billing_month.open?
|
18
18
|
- if @billing_month.past_cutoff && (@billable_invoices == @active_invoices)
|
19
19
|
= form_for @billing_month, :url => close_admin_billing_month_url(@billing_month), :method => "POST" do |f|
|
20
|
-
= f.submit
|
20
|
+
= f.submit t('.close_this_month_cannot_be_und'), :class => 'btn btn-primary'
|
21
21
|
- else
|
22
22
|
%p
|
23
23
|
= t('.billing_month_cannot_be_closed')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-i18n-extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 9
|
10
|
+
version: 0.5.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shai Rosenfeld
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-09-
|
18
|
+
date: 2013-09-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: tilt
|