Remove all trailing whitespaces

This commit is contained in:
Sébastien Lucas 2015-11-03 14:38:21 +01:00
parent 449b6bda01
commit d901887288

View file

@ -1,6 +1,6 @@
#!/usr/bin/perl #!/usr/bin/perl
# Program : COPS localization string generator # Program : COPS localization string generator
# Version : 0.0.1 # Version : 0.0.1
# #
# Author : Sébastien Lucas # Author : Sébastien Lucas
@ -20,16 +20,16 @@ for (readdir ($dirhandle)) {
next if (-d $_ ); # skip directories next if (-d $_ ); # skip directories
next if (/^[.]/); # skip dot-files next if (/^[.]/); # skip dot-files
next if not (/(.+)[.]php$/); next if not (/(.+)[.]php$/);
my $file = "../" . $_; my $file = "../" . $_;
debug ("text file: " . $_ . "\n"); debug ("text file: " . $_ . "\n");
my $content = loadFile ($file); my $content = loadFile ($file);
while ($content =~ /localize\s*\("([\w\.]*?)"\)/igs) { while ($content =~ /localize\s*\("([\w\.]*?)"\)/igs) {
$allstrings{$1} = ""; $allstrings{$1} = "";
debug (" * $1 \n"); debug (" * $1 \n");
} }
while ($content =~ /localize\s*\("([\w\.]*?)"\s*,/igs) { while ($content =~ /localize\s*\("([\w\.]*?)"\s*,/igs) {
$allstrings{$1 . ".none"} = ""; $allstrings{$1 . ".none"} = "";
$allstrings{$1 . ".one"} = ""; $allstrings{$1 . ".one"} = "";
@ -51,7 +51,7 @@ for (readdir ($dirhandle)) {
next if (/^[.]/); # skip dot-files next if (/^[.]/); # skip dot-files
next if not (/(.+)[.]json$/); next if not (/(.+)[.]json$/);
next if (/en\.json$/); next if (/en\.json$/);
handleLanguageFile ($_); handleLanguageFile ($_);
} }
closedir $dirhandle; closedir $dirhandle;
@ -59,14 +59,14 @@ closedir $dirhandle;
sub handleLanguageFile { sub handleLanguageFile {
my ($file) = @_; my ($file) = @_;
(my $lang = $file) =~ s/Localization_(\w\w)\.json/$1/; (my $lang = $file) =~ s/Localization_(\w\w)\.json/$1/;
my $file = "../lang/" . $file; my $file = "../lang/" . $file;
my $total = 0; my $total = 0;
my $translated = 0; my $translated = 0;
debug ("language file: $file / $lang \n"); debug ("language file: $file / $lang \n");
my $content = loadFile ($file); my $content = loadFile ($file);
while ($content =~ /"(.*?)"\:\s*"(.*?)",/igs) { while ($content =~ /"(.*?)"\:\s*"(.*?)",/igs) {
my $key = $1; my $key = $1;
my $value = $2; my $value = $2;
@ -77,9 +77,9 @@ sub handleLanguageFile {
$values{$lang}{$key} = $value; $values{$lang}{$key} = $value;
#debug (" * $1 \n"); #debug (" * $1 \n");
} }
open OUTPUT, ">$file"; open OUTPUT, ">$file";
print OUTPUT "{\n"; print OUTPUT "{\n";
foreach my $name (@strings) { foreach my $name (@strings) {
$total++ if ($name !~ /^languages\.\w{3}$/); $total++ if ($name !~ /^languages\.\w{3}$/);
@ -94,7 +94,7 @@ sub handleLanguageFile {
debug (" $translated / $total ($percentage %) \n"); debug (" $translated / $total ($percentage %) \n");
print OUTPUT "\"DO_NOT_TRANSLATE\":\"end\"\n"; print OUTPUT "\"DO_NOT_TRANSLATE\":\"end\"\n";
print OUTPUT "}\n"; print OUTPUT "}\n";
close OUTPUT; close OUTPUT;
} }
@ -102,13 +102,13 @@ sub loadFile {
my ($file) = @_; my ($file) = @_;
my $save = $/; my $save = $/;
$/ = undef; $/ = undef;
open INPUT, "<$file"; open INPUT, "<$file";
my $content = <INPUT>; my $content = <INPUT>;
close INPUT; close INPUT;
$/ = $save; $/ = $save;
return $content; return $content;
} }