mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	A perl script to check format strings in translations
This script can be called on translations files, e.g. > scripts/checktranslation.pl translations/*ts and will report if the number of % signs in source and translation differ. It finds quite a few issues that need to be investigated. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									9e10900e72
								
							
						
					
					
						commit
						16a36a117d
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		
							
								
								
									
										20
									
								
								scripts/checktranslation.pl
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								scripts/checktranslation.pl
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
#!/usr/bin/perl -CS
 | 
			
		||||
 | 
			
		||||
use strict;
 | 
			
		||||
use utf8;
 | 
			
		||||
use XML::TreeBuilder;
 | 
			
		||||
 | 
			
		||||
foreach my $file_name (@ARGV) {
 | 
			
		||||
	my $tree = XML::TreeBuilder->new({'NoExpand' => 0, 'ErrorContext' => 0});
 | 
			
		||||
	$tree->parse_file($file_name, ProtocolEncoding => 'UTF-8');
 | 
			
		||||
	foreach my $string ($tree->find_by_tag_name('message')) {
 | 
			
		||||
		my $source = $string->find_by_tag_name('source')->as_text;
 | 
			
		||||
		my $translation = $string->find_by_tag_name('translation')->as_text;
 | 
			
		||||
		next unless $translation =~ /\S/;
 | 
			
		||||
		my @source_args = ($source =~ /\%([^\s\-\(\)])/g);
 | 
			
		||||
		my @translation_args = ($translation =~ /\%([^\s\-\(\)])/g);
 | 
			
		||||
		if (scalar(@source_args) != scalar(@translation_args)) {
 | 
			
		||||
			print "$file_name:\n$source\n->\n$translation\n\n";
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue