@@ -9,11 +9,13 @@ module Fastlane
9
9
module Helper
10
10
module Android
11
11
module LocalizeHelper
12
+ LIB_SOURCE_XML_ATTR = 'a8c-src-lib' . freeze
13
+
12
14
# Checks if string_line has the content_override flag set
13
15
def self . skip_string_by_tag ( string_line )
14
16
skip = string_line . attr ( 'content_override' ) == 'true' unless string_line . attr ( 'content_override' ) . nil?
15
17
if skip
16
- puts " - Skipping #{ string_line . attr ( 'name' ) } string"
18
+ UI . message " - Skipping #{ string_line . attr ( 'name' ) } string"
17
19
return true
18
20
end
19
21
@@ -22,11 +24,11 @@ def self.skip_string_by_tag(string_line)
22
24
23
25
# Checks if string_name is in the excluesion list
24
26
def self . skip_string_by_exclusion_list ( library , string_name )
25
- return false unless library . key? ( :exclusions )
27
+ return false if library [ :exclusions ] . nil?
26
28
27
29
skip = library [ :exclusions ] . include? ( string_name )
28
30
if skip
29
- puts " - Skipping #{ string_name } string"
31
+ UI . message " - Skipping #{ string_name } string"
30
32
return true
31
33
end
32
34
end
@@ -35,6 +37,7 @@ def self.skip_string_by_exclusion_list(library, string_name)
35
37
def self . merge_string ( main_strings , library , string_line )
36
38
string_name = string_line . attr ( 'name' )
37
39
string_content = string_line . content
40
+ lib_src_id = library [ :source_id ]
38
41
39
42
# Skip strings in the exclusions list
40
43
return :skipped if skip_string_by_exclusion_list ( library , string_name )
@@ -58,12 +61,14 @@ def self.merge_string(main_strings, library, string_line)
58
61
else
59
62
# It has the tools:ignore flag, so update the content without touching the other attributes
60
63
this_string . content = string_content
64
+ this_string [ LIB_SOURCE_XML_ATTR ] = lib_src_id unless lib_src_id . nil?
61
65
return result
62
66
end
63
67
end
64
68
end
65
69
66
70
# String not found, or removed because needing update and not in the exclusion list: add to the main file
71
+ string_line [ LIB_SOURCE_XML_ATTR ] = lib_src_id unless lib_src_id . nil?
67
72
main_strings . xpath ( '//string' ) . last ( ) . add_next_sibling ( "\n #{ ' ' * 4 } #{ string_line . to_xml ( ) . strip } " )
68
73
return result
69
74
end
@@ -113,12 +118,12 @@ def self.merge_lib(main, library)
113
118
res = merge_string ( main_strings , library , string_line )
114
119
case res
115
120
when :updated
116
- puts "#{ string_line . attr ( 'name' ) } updated."
121
+ UI . verbose "#{ string_line . attr ( 'name' ) } updated."
117
122
updated_count = updated_count + 1
118
123
when :found
119
124
untouched_count = untouched_count + 1
120
125
when :added
121
- puts "#{ string_line . attr ( 'name' ) } added."
126
+ UI . verbose "#{ string_line . attr ( 'name' ) } added."
122
127
added_count = added_count + 1
123
128
when :skipped
124
129
skipped_count = skipped_count + 1
0 commit comments