mirror of
https://github.com/webmin/webmin.git
synced 2025-07-23 00:30:33 +00:00
Windows-1251 encoding support
This commit is contained in:
@ -28,6 +28,8 @@ while(<LANG>) {
|
||||
close(LANG);
|
||||
|
||||
# Find languages with common character sets
|
||||
@fiveone_langs = map { $_->{'lang'} }
|
||||
grep { $_->{'charset'} eq 'windows-1251' } @langs;
|
||||
@fivenine_langs = map { $_->{'lang'} }
|
||||
grep { $_->{'charset'} eq 'iso-8859-2' } @langs;
|
||||
@fifteen_langs = map { $_->{'lang'} }
|
||||
@ -53,6 +55,11 @@ foreach $m (@modules) {
|
||||
if (-r "$m/lang/ru_SU") {
|
||||
system("iconv -f KOI8-R -t UTF-8 - <$m/lang/ru_SU >$m/lang/ru.UTF-8");
|
||||
}
|
||||
foreach $l (@fiveone_langs) {
|
||||
if (-r "$m/lang/$l") {
|
||||
system("iconv -f windows-1251 -t UTF-8 - <$m/lang/$l >$m/lang/$l.UTF-8");
|
||||
}
|
||||
}
|
||||
foreach $l (@fivenine_langs) {
|
||||
if (-r "$m/lang/$l") {
|
||||
system("iconv -f iso-8859-2 -t UTF-8 - <$m/lang/$l >$m/lang/$l.UTF-8");
|
||||
@ -88,6 +95,12 @@ foreach $m (@modules) {
|
||||
if ($minfo{'desc_ru_SU'}) {
|
||||
$minfo{'desc_ru.UTF-8'} = &KOI8ToUTF8($minfo{'desc_ru_SU'});
|
||||
}
|
||||
foreach $l (@fiveone_langs) {
|
||||
if ($minfo{'desc_'.$l}) {
|
||||
$minfo{'desc_'.$l.'.UTF-8'} =
|
||||
&Windows1251ToUTF8($minfo{'desc_'.$l});
|
||||
}
|
||||
}
|
||||
foreach $l (@fivenine_langs) {
|
||||
if ($minfo{'desc_'.$l}) {
|
||||
$minfo{'desc_'.$l.'.UTF-8'} =
|
||||
@ -149,6 +162,16 @@ foreach $m (@modules) {
|
||||
}
|
||||
&write_file_diff("$m/config.info.ru.UTF-8", \%cinfo);
|
||||
}
|
||||
foreach $l (@fiveone_langs) {
|
||||
%cinfo = ( );
|
||||
if (&read_file("$m/config.info.$l", \%cinfo)) {
|
||||
local %ocinfo = %cinfo;
|
||||
foreach $k (keys %cinfo) {
|
||||
$cinfo{$k} = &Windows1251ToUTF8($cinfo{$k});
|
||||
}
|
||||
&write_file_diff("$m/config.info.$l.UTF-8", \%cinfo);
|
||||
}
|
||||
}
|
||||
foreach $l (@fivenine_langs) {
|
||||
%cinfo = ( );
|
||||
if (&read_file("$m/config.info.$l", \%cinfo)) {
|
||||
@ -229,6 +252,17 @@ foreach $m (@modules) {
|
||||
close(IN);
|
||||
}
|
||||
else {
|
||||
foreach $l (@fiveone_langs) {
|
||||
if ($h =~ /(\S+)\.$l\.html$/) {
|
||||
open(IN, "$m/help/$h");
|
||||
open(OUT, ">$m/help/$1.$l.UTF-8.html");
|
||||
while(<IN>) {
|
||||
print OUT &Windows1251ToUTF8($_);
|
||||
}
|
||||
close(OUT);
|
||||
close(IN);
|
||||
}
|
||||
}
|
||||
foreach $l (@fivenine_langs) {
|
||||
if ($h =~ /(\S+)\.$l\.html$/) {
|
||||
open(IN, "$m/help/$h");
|
||||
@ -327,6 +361,18 @@ unlink($temp);
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub Windows1251ToUTF8
|
||||
{
|
||||
local ($str) = @_;
|
||||
local $temp = "/tmp/$$.cn";
|
||||
open(TEMP, ">$temp");
|
||||
print TEMP $str;
|
||||
close(TEMP);
|
||||
local $out = `iconv -f windows-1251 -t UTF-8 - <$temp`;
|
||||
unlink($temp);
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub ISO88592ToUTF8
|
||||
{
|
||||
local ($str) = @_;
|
||||
|
Reference in New Issue
Block a user