mirror of
https://github.com/webmin/webmin.git
synced 2025-07-23 00:30:33 +00:00
Fix language manager to correctly handle Farsi
* Something has changed on Google Translator side or maybe even a bug
This commit is contained in:
@ -6,10 +6,11 @@ use warnings;
|
|||||||
|
|
||||||
use 5.014;
|
use 5.014;
|
||||||
|
|
||||||
|
no warnings 'utf8';
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use JSON::PP;
|
use JSON::XS;
|
||||||
use HTTP::Tiny;
|
use HTTP::Tiny;
|
||||||
eval "use HTML::Entities";
|
eval "use HTML::Entities";
|
||||||
use List::MoreUtils qw(any uniq);
|
use List::MoreUtils qw(any uniq);
|
||||||
@ -940,7 +941,11 @@ sub translate
|
|||||||
|
|
||||||
# Extract translation on success
|
# Extract translation on success
|
||||||
if ($ts) {
|
if ($ts) {
|
||||||
$tr = JSON::PP->new->decode($rs->{'content'});
|
# Fix Farsi
|
||||||
|
if ($target eq 'fa') {
|
||||||
|
$rs->{'content'} = decode('utf-8', $rs->{'content'});
|
||||||
|
}
|
||||||
|
$tr = JSON::XS->new->decode($rs->{'content'});
|
||||||
$tr = $tr->{'data'}->{'translations'}[0]->{'translatedText'};
|
$tr = $tr->{'data'}->{'translations'}[0]->{'translatedText'};
|
||||||
return $tr;
|
return $tr;
|
||||||
}
|
}
|
||||||
@ -1641,6 +1646,10 @@ sub go
|
|||||||
}
|
}
|
||||||
my $file = $mpath . "/$code";
|
my $file = $mpath . "/$code";
|
||||||
my $file_auto = $mpath . "/$code.$language_suffix";
|
my $file_auto = $mpath . "/$code.$language_suffix";
|
||||||
|
local $SIG{__WARN__} = sub {
|
||||||
|
my $warning = shift;
|
||||||
|
warn $warning unless $warning =~ /Wide character/;
|
||||||
|
};
|
||||||
if (%language) {
|
if (%language) {
|
||||||
write_file($file, \%language);
|
write_file($file, \%language);
|
||||||
sort_file_by($file, $mfile);
|
sort_file_by($file, $mfile);
|
||||||
|
Reference in New Issue
Block a user