File tree 4 files changed +17
-5
lines changed
4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 6
6
/pkg /
7
7
/spec /reports /
8
8
/tmp /
9
+ /.idea /
9
10
spec /.examples.txt
10
11
Gemfile.lock
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ def on_dstr(node)
53
53
else
54
54
inner_source = i . children [ 0 ] . loc . expression . source . gsub ( /^#\{ |}$/ , '' )
55
55
interpolate_key = ExtractI18n . key ( inner_source )
56
- out_string += "%{#{ interpolate_key } }"
56
+ # because we're using ICU, interpolation happens just with curly braces, no %
57
+ out_string += "{#{ interpolate_key } }"
57
58
interpolate_arguments [ interpolate_key ] = inner_source
58
59
end
59
60
end
@@ -77,7 +78,8 @@ def on_str(node)
77
78
78
79
def ask_and_continue ( i18n_key :, i18n_string :, interpolate_arguments : { } , node :)
79
80
change = ExtractI18n ::SourceChange . new (
80
- i18n_key : "#{ @file_key } .#{ i18n_key } " ,
81
+ # we want the key to be the string itself so that we can extract it later
82
+ i18n_key : "#{ i18n_string } " ,
81
83
i18n_string : i18n_string ,
82
84
interpolate_arguments : interpolate_arguments ,
83
85
source_line : node . location . expression . source_line ,
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ def run
26
26
puts Diffy ::Diff . new ( original_content , result , context : 1 ) . to_s ( :color )
27
27
if PROMPT . yes? ( "Save changes?" )
28
28
File . write ( @file_path , result )
29
- update_i18n_yml_file
29
+ # We are using a text extraction pipeline, so don't need this file
30
+ # update_i18n_yml_file
30
31
puts PASTEL . green ( "Saved #{ @file_path } " )
31
32
end
32
33
end
Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ def initialize(
28
28
interpolate_arguments :,
29
29
source_line :,
30
30
remove :,
31
- t_template : %{I18n.t("%s"%s)} ,
31
+ # we are using our own _t method by default
32
+ t_template : %{_t("%s"%s)} ,
32
33
interpolation_type : :ruby
33
34
)
34
35
@i18n_string = i18n_string
@@ -56,7 +57,8 @@ def format
56
57
unless @source_line . include? ( "\n " )
57
58
s += "\n "
58
59
end
59
- s += PASTEL . cyan ( "add i18n: " ) + PASTEL . blue ( "#{ @key } : #{ @i18n_string } " )
60
+ # We are using a text extraction pipeline, so we don't need this line
61
+ # s += PASTEL.cyan("add i18n: ") + PASTEL.yellow("#{@key}: #{@i18n_string}")
60
62
s
61
63
end
62
64
@@ -66,6 +68,12 @@ def i18n_t(relative: false)
66
68
else
67
69
key
68
70
end
71
+ # let's not have dangling commas for strings with no arguments
72
+ @t_template = if i18n_arguments_string . length > 0
73
+ %{_t("%s"%s)}
74
+ else
75
+ %{_t("%s")}
76
+ end
69
77
sprintf ( @t_template , i18n_key , i18n_arguments_string )
70
78
end
71
79
You can’t perform that action at this time.
0 commit comments