Ignore:
Timestamp:
03/20/08 12:08:21 (17 years ago)
Author:
pawelk <pawelk@…>
Branches:
master, help
Children:
c8e8fa8
Parents:
20b4e44
git-author:
pawelk <pawelk@…> (03/20/08 12:08:21)
git-committer:
pawelk <pawelk@…> (03/20/08 12:08:21)
Message:

Program generujacy konfiguracje pyta sie o wybor slownika.
Dolozylem obsluge plikow tymczasowych w compiledict.
Zamienilem system na ` w perlu.

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@14 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/dist/common/utt_make_config.pl

    rd593c5e r389de9a  
    1212 
    1313prepareUttUsrHome($usr_home); 
     14conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); 
     15 
    1416conf_cor(catfile($usr_home, 'cor.conf'), $sys_home); 
    1517conf_grp(catfile($usr_home, 'grp.conf'), $sys_home); 
     
    1719conf_lem(catfile($usr_home, 'lem.conf'), $sys_home); 
    1820conf_ser(catfile($usr_home, 'ser.conf'), $sys_home); 
    19 conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); 
    2021 
    2122print "UTT user configuration created in $usr_home\n"; 
     
    2728    my $dir = shift; 
    2829 
    29         if(-d $dir) { 
    30                 print "Old configuration will be deleted!\n"; 
    31                 my $cnt = unlink <$dir/*>; 
    32                 print "$cnt files deleted.\n"; 
     30    print "Preparing user configuration.\n"; 
     31 
     32    if(-d $dir) { 
     33        print "Old configuration detected. "; 
     34        my $cnt = unlink <$dir/*>; 
     35        print "($cnt files deleted)\n"; 
     36    } 
     37    else { 
     38        print "Creating directory $dir\n"; 
     39        if(1 != mkdir $dir) { 
     40            die "Unable to create UTT user configuration!\n"; 
    3341        } 
    34         else { 
    35                 print "Creating directory $dir\n"; 
    36                 if(1 != mkdir $dir) { 
    37                   die "Unable to create UTT user configuration!\n"; 
    38                 } 
    39         } 
     42    } 
    4043} 
    4144 
     
    114117        my $utt_file = shift; 
    115118        my $utthome = shift; 
     119 
     120        my $lang = getUserLanguage(abs_path(catdir($utthome, "share/utt"))); 
     121 
    116122  open(FILE, ">$utt_file"); 
    117123 
    118124  print FILE makeConfigHeader(); 
    119   print FILE "# user locale\n"; 
    120   print FILE "language=", findLocale(), "\n"; 
     125  print FILE "# user locale (dictionary)\n"; 
     126  print FILE "language=", $lang, "\n"; 
    121127 
    122128  close FILE; 
     129} 
     130 
     131sub getUserLanguage() { 
     132    my $dict_dir = shift; 
     133 
     134    print "Setup dictionaries.\n"; 
     135     
     136    opendir(DIR, $dict_dir) || die "Install dictionary first!\n"; 
     137    @files = grep(/[^\.{1,2}]/ && -d "$dict_dir/$_", readdir(DIR)); 
     138    closedir DIR; 
     139    my $cnt = scalar @files; 
     140    print "$cnt dictionary(ies) found.\n"; 
     141    if(0 == $cnt) { 
     142        die("Install dictionary first!\n"); 
     143    } 
     144 
     145    foreach my $file (@files) { 
     146        print "Do you select dictionary $file [yes/no]? "; 
     147        my $ans = <STDIN>; 
     148        if($ans =~ /y(es)?/i) { 
     149            return $file; 
     150        } 
     151    } 
     152    die "No dictionary selected - setup failed!\n"; 
    123153} 
    124154 
Note: See TracChangeset for help on using the changeset viewer.