[25ae32e] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use Cwd 'abs_path'; |
---|
| 4 | use File::Basename; |
---|
| 5 | use POSIX; |
---|
| 6 | |
---|
| 7 | my $cur_dir = dirname(abs_path($0)); |
---|
| 8 | |
---|
| 9 | open(FILE, ">$cur_dir/conf/utt.conf"); |
---|
| 10 | |
---|
| 11 | # we put some description into utt.conf file |
---|
| 12 | print FILE "# ************************************************************\n"; |
---|
| 13 | print FILE "# * This file was created automatically during installation. *\n"; |
---|
| 14 | print FILE "# * If you don't need do not change it. *\n"; |
---|
| 15 | print FILE "# * *\n"; |
---|
| 16 | print FILE "# * UAM Text Tools *\n"; |
---|
| 17 | print FILE "# * Adam Mickiewicz University, Poland *\n"; |
---|
| 18 | print FILE "# * http://utt.amu.edu.pl *\n"; |
---|
| 19 | print FILE "# ************************************************************\n"; |
---|
| 20 | print FILE "\n\n"; |
---|
| 21 | |
---|
| 22 | # we need utt home directory |
---|
| 23 | print FILE "# absolute path to utt directory\n"; |
---|
| 24 | print FILE "UTT_HOME=$cur_dir\n\n"; |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | # we need user default locale |
---|
| 28 | $best_locale = findLocale(); |
---|
| 29 | print FILE "# user locale\n"; |
---|
| 30 | print FILE "UTT_LOCALE=$best_locale\n"; |
---|
| 31 | print FILE "\n"; |
---|
| 32 | |
---|
| 33 | close FILE; |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | sub findLocale() { |
---|
| 38 | $cur_locale = setlocale(LC_CTYPE); |
---|
| 39 | |
---|
| 40 | # we replace Latinx to ISO-8859-x |
---|
| 41 | $cur_locale =~ s/(.+?)Latin(.+?)/$1ISO\-8859\-$2/g; |
---|
| 42 | |
---|
| 43 | if($cur_locale =~ /\w+_\w+\.\S+/) { |
---|
| 44 | $best_locale = $cur_locale; |
---|
| 45 | } |
---|
| 46 | elsif($cur_locale =~ /\w+_\w+/) { |
---|
| 47 | $best_locale = $cur_locale.".UTF-8"; |
---|
| 48 | } |
---|
| 49 | else { |
---|
| 50 | $best_locale = toupper($cur_locale).'_'.tolower($cur_locale).'.UTF-8'; |
---|
| 51 | } |
---|
| 52 | return $best_locale; |
---|
| 53 | } |
---|