Better way of getting rid from undesirable spaces in parentheses

This commit is contained in:
Ilia Rostovtsev
2020-03-06 01:49:58 +03:00
parent cdfd246a00
commit a9b004bbfc

View File

@@ -508,14 +508,14 @@ sub translated_substitute
$translated =~ s/(^[ ]+\$)/\$/gi;
# Get rid from undesirable spaces in parentheses
$translated =~ s/\([ ]+\$(\d+.*?)\)/(\$@{[trim($1)]})/gi;
$translated =~ s/([ ]+\))/)/gi;
$translated =~ s/([ ]+\)//gi;
$translated =~ s/(\([ ]+)/(/gi;
$translated =~ s/(\[ ]+)//gi;
# Print actual values with percent sign
$translated =~ s/\([ ]+\$(\d+)[ ]*%\)/(\$$1 %)/gi;
# There are different types of parentheses in eastern languages
$translated =~ s/\[ ]+\$(\d+)[ ]*\/\$$1/gi;
# The following, is abnormal way to make things work, around of the bugs produced by Google Translate API for (bg).
if ($code eq 'bg') {
if ($original =~ /\$(\d+)/ && $translated !~ /\$(\d+)/) {