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