Changeset 5484 for trunk/gsdl


Ignore:
Timestamp:
2003-09-10T13:24:11+12:00 (21 years ago)
Author:
mdewsnip
Message:

Tidied up some of the nasty special-case code for Russian, Kazakh, Ukrainian and Thai.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/translate.pl

    r4231 r5484  
    186186
    187187    my $origtext = $text;
     188
    188189    $text =~ s/&(\d{3,4});/chr($1)/ge;
    189190    $text =~ s/&([^;]*);/$rmap{$1}/g;
    190191
    191     # special case for russian images - fonts expect text to be koi8-r encoded
    192     if ($language_symbol eq "ru") {
     192    # Default font is set by the individual scripts (flash_button-1.2.pl etc), usually lucida
     193    my $fontchoice = "";
     194
     195    # special case for Kazakh images (can also handle Russian) - encode to match Kazakh font
     196    if ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     197    $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "kazakh");
     198    $fontchoice = " -foundry 2rebels -fontname \"helv kaz\"";
     199    }
     200    # special case for Russian images - font is koi8-r encoded
     201    elsif ($language_symbol eq "ru") {
    193202    $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "koi8_r");
    194     }
    195     # special case for Kazakh images (can also handle Russian) - encode to match Kazakh font
    196     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    197     $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "kazakh");
    198     }
     203    $fontchoice = " -foundry cronyx -fontname helvetica";
     204    }
     205    # special case for Ukrainian images - font is windows_1251 encoded
     206    elsif ($language_symbol eq "uk") {
     207    $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "windows_1251");
     208    $fontchoice = " -foundry rfx -fontname serene";
     209    }
     210    # special case for Thai images
     211    # elsif ($language_symbol eq "th") {
     212    # $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "thai");
     213    # }
    199214
    200215    # edit image macros
     
    202217
    203218    if ($image_type eq "top_nav_button") {
    204    
     219
    205220    # generate images
    206     my $options = "-text \"$text\" -filenamestem $image_name";
    207     # special case for russian images
    208     if ($language_symbol eq "ru") {
    209         $options .= " -fontsize 10 -height 20 -whitespace -image_dir $image_dir";
    210         $options .= " -foundry cronyx -fontname helvetica -fontweight bold";
    211     }
     221    my $options = "-text \"$text\" -filenamestem $image_name -image_dir $image_dir";
     222    $options .= " -height 20 -whitespace";
     223    $options .= $fontchoice;
     224
    212225    # special case for Kazakh images (can also handle Russian)
    213     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    214         $options .= " -fontsize 10 -height 20 -whitespace -image_dir $image_dir";
    215         $options .= " -foundry 2rebels -fontname \"helv kaz\" -fontweight bold";
    216     }
     226    if ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     227        $options .= " -fontsize 10 -fontweight bold";
     228    }
     229    # special case for Russian images
     230    elsif ($language_symbol eq "ru") {
     231        $options .= " -fontsize 10 -fontweight bold";
     232    }
     233    # special case for Ukrainian images
     234    elsif ($language_symbol eq "uk") {
     235        $options .= " -fontsize 10";
     236    }
     237    # elsif ($language_symbol eq "th") {
     238        # $options .= " -fontsize 30 -fontweight bold";
     239        # $options .= " -foundry 2rebels -fontname \"DB ThaiText\"";
     240        # $options .= " -fontsize 24";
     241        # $options .= " -foundry monotype -fontname \"Courier ProportionalThai\"";
     242    # }
    217243    else {
    218         $options .= " -fontsize 12 -height 20 -whitespace -image_dir $image_dir";
     244        $options .= " -fontsize 12";
    219245    }
    220246    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
     
    227253   
    228254    # generate on and off images
    229     my $options = "-text \"$text\" -filenamestem $image_name";
    230     $options .= " -fontsize 17 -height 17 -fixed_width -width 87";
    231     $options .= " -image_dir $image_dir";
    232     # special case for russian images
    233     if ($language_symbol eq "ru") {
    234         $options .= " -foundry cronyx -fontname helvetica";
    235     }
    236     # special case for Kazakh images (can also handle Russian)
    237     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    238         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    239     }
     255    my $options = "-text \"$text\" -filenamestem $image_name -image_dir $image_dir";
     256    $options .= " -height 17 -fixed_width -width 87";
     257    $options .= $fontchoice;
     258
     259    # special case for Thai images
     260    if ($language_symbol eq "th") {
     261        # $options .= " -fontsize 30";
     262        # $options .= " -foundry 2rebels -fontname \"DB ThaiText\" -fontweight bold";
     263        # $options .= " -fontsize 24";
     264        # $options .= " -foundry monotype -fontname \"Courier ProportionalThai\"";
     265    }
     266    else {
     267        $options .= " -fontsize 17";
     268    }
     269
    240270    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    241271
    242272    # generate green image
    243     $options = "-text \"$text\" -filename ${image_name}gr.gif";
    244     $options .= " -image_dir $image_dir";
    245     # special case for russian images
    246     if ($language_symbol eq "ru") {
    247             $options .= " -foundry cronyx -fontname helvetica";
    248     }
    249     # special case for Kazakh images (can also handle Russian)
    250     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    251         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    252     }
     273    $options = "-text \"$text\" -filename ${image_name}gr.gif -image_dir $image_dir";
     274    $options .= $fontchoice;
     275
    253276    `$ENV{'GSDLHOME'}/bin/script/gimp/green_bar-1.2.pl $options`;
    254277
     
    260283
    261284    # generate on and off images
    262     my $options = "-text \"$text\" -filenamestem $image_name";
    263     $options .= " -fixed_width -whitespace -image_dir $image_dir";
    264     # special case for russian images
    265     if ($language_symbol eq "ru") {
    266         $options .= " -fontsize 8 -foundry cronyx -fontname helvetica";
    267     }
     285    my $options = "-text \"$text\" -filenamestem $image_name -image_dir $image_dir";
     286    $options .= " -fixed_width -whitespace";
     287    $options .= $fontchoice;
     288
    268289    # special case for Kazakh images (can also handle Russian)
    269     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    270         $options .= " -fontsize 8 -foundry 2rebels -fontname \"helv kaz\"";
     290    if ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     291        $options .= " -fontsize 8";
     292    }
     293    # special case for Russian images
     294    elsif ($language_symbol eq "ru") {
     295        $options .= " -fontsize 8";
     296    }
     297    # special case for Ukrainian images
     298    elsif ($language_symbol eq "uk") {
     299        $options .= " -fontsize 8";
    271300    }
    272301    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
     
    300329    my $options = "-text \"$text\" -filenamestem yc$image_name -image_dir $image_dir";
    301330    $options .= " -width 77 -height 26 -fixed_width -whitespace -fontsize 13";
    302     # special case for russian images
    303     if ($language_symbol eq "ru") {
    304         $options .= " -foundry cronyx -fontname helvetica";
    305     }
    306     # special case for Kazakh images (can also handle Russian)
    307     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    308         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    309     }
     331    $options .= $fontchoice;
     332
    310333    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    311334
     
    314337    $options .= " -width 77 -height 26 -fixed_width -whitespace -fontsize 13";
    315338    $options .= " -bgcolor \"#96c19b\"";
    316     # special case for russian images
    317     if ($language_symbol eq "ru") {
    318         $options .= " -foundry cronyx -fontname helvetica";
    319     }
    320     # special case for Kazakh images (can also handle Russian)
    321     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    322         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    323     }
     339    $options .= $fontchoice;
     340
    324341    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    325342
     
    328345    $options .= " -width 77 -height 26 -fixed_width -whitespace -fontsize 13";
    329346    $options .= " -bgcolor \"#7E7E7E\" -fontcolor \"#a0a0a0\"";
    330     # special case for russian images
    331     if ($language_symbol eq "ru") {
    332         $options .= " -foundry cronyx -fontname helvetica";
    333     }
    334     # special case for Kazakh images (can also handle Russian)
    335     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    336         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    337     }
    338     `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
     347    $options .= $fontchoice;
     348
     349    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
     350
    339351    # delete the unused dark image
    340352    unlink(util::filename_cat($image_dir, "nc$image_name" . "on.gif"));
     
    344356    # generate green bar image (we're assuming these bars are always 537
    345357    # pixels and are never stretched by excess text
    346     my $options = "-text \"$text\" -filename ${image_name}.gif -dont_center";
    347     $options .= " -width 537 -width_space 15 -image_dir $image_dir";
    348     # special case for russian images
    349     if ($language_symbol eq "ru") {
    350         $options .= " -foundry cronyx -fontname helvetica";
    351     }
    352     # special case for Kazakh images (can also handle Russian)
    353     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    354         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    355     }
     358    my $options = "-text \"$text\" -filename ${image_name}.gif -image_dir $image_dir";
     359    $options .= " -dont_center -width 537 -width_space 15";
     360    $options .= $fontchoice;
     361
    356362    `$ENV{'GSDLHOME'}/bin/script/gimp/green_bar-1.2.pl $options`;
    357363
    358364    } elsif ($image_type eq "green_title") {
    359 
     365   
    360366    # read the width if it is specified in $image_macros
    361367        my ($width) = $image_macros =~ /_width${image_name}x?_\s*[^\{]*\{(\d+)\}/;
     
    366372    $options .= " -width $width -height 57 -stripe_alignment right -text_alignment right";
    367373    $options .= " -fontsize 26 -fontweight bold";
    368     # special case for russian images
    369     if ($language_symbol eq "ru") {
    370         $options .= " -foundry cronyx -fontname helvetica";
    371     }
    372     # special case for Kazakh images (can also handle Russian)
    373     elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
    374         $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    375     }
     374        $options .= $fontchoice;
     375
    376376    `$ENV{'GSDLHOME'}/bin/script/gimp/title_icon-1.2.pl $options`;
    377377
Note: See TracChangeset for help on using the changeset viewer.