@@ -113,11 +113,13 @@ def remove_repeat_extracted_from_tl(tl_dir, is_py2):
113113 lines1 = get_remove_consecutive_empty_lines (lines1 )
114114 f .writelines (lines1 )
115115 f .close ()
116+ remove_repeat_for_file (p1 )
116117 if is_modified2 :
117118 f = io .open (p2 , 'w' , encoding = 'utf-8' )
118119 lines2 = get_remove_consecutive_empty_lines (lines2 )
119120 f .writelines (lines2 )
120121 f .close ()
122+ remove_repeat_for_file (p2 )
121123 i = i + 1
122124
123125
@@ -141,17 +143,33 @@ def remove_repeat_for_file(p):
141143 f .close ()
142144 exist_set = set ()
143145 is_removed = False
146+ is_empty_translate = True
147+ start_translate_block_line = - 1
144148 for index , line in enumerate (lines ):
145149 line = line .rstrip ('\n ' )
150+ if line .startswith ('translate ' ) and line .endswith ('strings:' ):
151+ if start_translate_block_line != - 1 :
152+ if is_empty_translate :
153+ is_removed = True
154+ for idx in range (start_translate_block_line , index - 1 ):
155+ lines [idx ] = ''
156+ is_empty_translate = True
157+ start_translate_block_line = index
158+ continue
146159 if len (line ) <= 4 :
147160 continue
161+ if not line .startswith (' old "old:' ) and not line .startswith (
162+ ' new "new:' ) and not line .lstrip ().startswith ('#' ):
163+ is_empty_translate = False
148164 if line not in exist_set :
149165 exist_set .add (line )
150166 else :
151167 if line .startswith (' old ' ):
152168 if (index + 1 ) <= len (lines ):
153169 new_line = lines [index + 1 ]
154170 if new_line .startswith (' new ' ):
171+ if line .startswith (' old ' ) and index > 0 and lines [index - 1 ].lstrip ().startswith ('#' ):
172+ lines [index - 1 ] = ''
155173 # log_print('Remove Repeat in ' + p + ' ' + str(index) + ' : \n' + lines[index].rstrip(
156174 # "\n") + '\n' + new_line.rstrip("\n"))
157175 lines [index ] = ''
@@ -195,6 +213,7 @@ def run(self):
195213 log_print (self .p + ' begin extract!' )
196214 ExtractWriteFile (self .p , self .tl_name , self .is_open_filter , self .filter_length , self .is_gen_empty ,
197215 set (), self .is_skip_underline )
216+ remove_repeat_for_file (self .p )
198217 if self .dirs is not None :
199218 global_e = set ()
200219 for _dir in self .dirs :
@@ -209,6 +228,7 @@ def run(self):
209228 continue
210229 ret_e = ExtractWriteFile (i , self .tl_name , self .is_open_filter , self .filter_length ,
211230 self .is_gen_empty , global_e , self .is_skip_underline )
231+ remove_repeat_for_file (i )
212232 global_e = global_e | ret_e
213233
214234 except Exception as e :
0 commit comments