mirror of
				https://github.com/oxen-io/session-android.git
				synced 2025-10-30 23:09:20 +00:00 
			
		
		
		
	Exclude non-translatable multiline blocks.
This commit is contained in:
		 Alan Evans
					Alan Evans
				
			
				
					committed by
					
						 Greyson Parrelli
						Greyson Parrelli
					
				
			
			
				
	
			
			
			 Greyson Parrelli
						Greyson Parrelli
					
				
			
						parent
						
							d53fd6a109
						
					
				
				
					commit
					b5656aa5dd
				
			| @@ -79,18 +79,39 @@ task excludeNonTranslatables { | ||||
|                 .toSet() | ||||
|         def all = english.collect { it['@name'] }.toSet() | ||||
|         def translatable = all - nonTranslatable | ||||
|         def inMultiline = false | ||||
|         def endBlockName = "" | ||||
|  | ||||
|         allStringsResourceFiles { f -> | ||||
|             if (f != englishFile) { | ||||
|                 def newLines = f.readLines() | ||||
|                         .collect { line -> | ||||
|                             def matcher = line =~ /name="([^"]*)".*<\// | ||||
|                             if (matcher.find()) { | ||||
|                                 def name = matcher.group(1) | ||||
|                                 if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) { | ||||
|                                     return "  <!-- Removed by excludeNonTranslatables ${line.trim()} -->" | ||||
|                             if (!inMultiline) { | ||||
|                                 def singleLineMatcher = line =~ /name="([^"]*)".*<\// | ||||
|                                 if (singleLineMatcher.find()) { | ||||
|                                     def name = singleLineMatcher.group(1) | ||||
|                                     if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) { | ||||
|                                         return "  <!-- Removed by excludeNonTranslatables ${line.trim()} -->" | ||||
|                                     } | ||||
|                                 } else { | ||||
|                                     def multilineStartMatcher = line =~ /<(.*) .?name="([^"]*)".*/ | ||||
|                                     if (multilineStartMatcher.find()) { | ||||
|                                         endBlockName = multilineStartMatcher.group(1) | ||||
|                                         def name = multilineStartMatcher.group(2) | ||||
|                                         if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) { | ||||
|                                             inMultiline = true; | ||||
|                                             return "  <!-- Removed by excludeNonTranslatables ${line.trim()}" | ||||
|                                         } | ||||
|                                     } | ||||
|                                 } | ||||
|                             } else { | ||||
|                                 def multilineEndMatcher = line =~ /<\/${endBlockName}/ | ||||
|                                 if (multilineEndMatcher.find()) { | ||||
|                                     inMultiline = false | ||||
|                                     return "${line} -->" | ||||
|                                 } | ||||
|                             } | ||||
|  | ||||
|                             return line | ||||
|                         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user