#!/usr/bin/perl
use vars qw( %langs );
%langs = (
'ar' => "utf-8",
'bn' => "utf-8",
'cs' => "windows-1250",
'cy' => "iso-8859-1",
'da' => "iso-8859-1",
'de' => "iso-8859-1",
'el' => "iso-8859-7",
'en' => "iso-8859-1",
'es' => "iso-8859-1",
'eu' => "iso-8859-1",
'fa' => "utf-8",
'fi' => "iso-8859-1",
'fr' => "iso-8859-1",
'he' => "utf-8",
'hu' => "utf-8",
'id' => "iso-8859-1",
'it' => "iso-8859-15",
'ja' => "utf-8",
'ko' => "euc-kr",
'lv' => "windows-1257",
'nb' => "iso-8859-1",
'nl' => "iso-8859-1",
'pl' => "iso-8859-2",
'pt-br' => "iso-8859-1",
'pt' => "iso-8859-1",
'ro' => "iso-8859-2",
'ru' => "windows-1251",
'sl' => "windows-1250",
#'sr' => "iso-8859-2",
'sr' => "windows-1251",
'sv' => "iso-8859-1",
'th' => "utf-8",
'tr' => "utf-8",
'tw' => "utf-8",
'uk' => "windows-1251",
'vi' => "utf-8",
'zh' => "utf-8"
);
my $langpath = '../modules/faqweb/www/lang';
convertFaqwebLang($langpath, 'utf-8');
sub convertFaqwebLang {
my ($sourceDir,$toCode) = @_;
my $langname;
my $charset;
my $nativeFile;
my $utfFile;
my $fromCode;
print "##############################\n";
print " convert for $sourceDir\n";
print "##############################\n";
foreach my $langname(keys %langs) {
$charset = $langs{$langname};
$fromCode = uc($charset);
if ($charset eq $toCode) {
next;
}
$nativeFile = sprintf("%s/language_%s.php",$sourceDir,$langname);
$utfFile = sprintf("%s/language_%s.php.%s",$sourceDir,$langname,$toCode);
if (!-f $nativeFile) {
next;
}
my $cmd = sprintf('iconv -c --from-code=%s --to-code=%s %s > %s', $fromCode,uc($toCode),$nativeFile,$utfFile);
exeCmd($cmd);
if ($langname eq 'sr') {
$charset = 'iso-8859-2';
}
$cmd = sprintf("replace %s %s -- %s",
$charset,
$toCode,
$utfFile);
exeCmd($cmd);
$cmd = sprintf('"mv" %s %s', $utfFile, $nativeFile);
exeCmd($cmd);
}
}
sub exeCmd {
my $cmd = $_[0];
my $debug = 0;
print ("$cmd \n");
if (!$debug) {
system($cmd);
}
}
Copyright 2K16 - 2K18 Indonesian Hacker Rulez