home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / perl5 / Debconf / Element / Select.pm < prev   
Encoding:
Perl POD Document  |  2006-07-24  |  1.9 KB  |  79 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Select;
  6. use strict;
  7. use Debconf::Log ':all';
  8. use Debconf::Gettext;
  9. use base qw(Debconf::Element);
  10. use Debconf::Encoding qw(to_Unicode);
  11.  
  12.  
  13. sub visible {
  14.     my $this=shift;
  15.     
  16.     my @choices=$this->question->choices_split;
  17.  
  18.     if (@choices > 1) {
  19.         return 1;
  20.     }
  21.     else {
  22.         debug 'developer' => 'Not displaying select list '.
  23.                              $this->question->name.' with '.
  24.                      (@choices+0).' choice'.((@choices == 0) ? 's' : '');
  25.         return 0;
  26.     }
  27. }
  28.  
  29.  
  30. sub translate_default {
  31.     my $this=shift;
  32.  
  33.     my @choices=$this->question->choices_split;
  34.     $this->question->template->i18n('');
  35.     my @choices_c=$this->question->choices_split;
  36.     $this->question->template->i18n(1);
  37.  
  38.     my $c_default='';
  39.     $c_default=$this->question->value if defined $this->question->value;
  40.     foreach (my $x=0; $x <= $#choices; $x++) {
  41.         return $choices[$x] if $choices_c[$x] eq $c_default;
  42.     }
  43.     return '';
  44. }
  45.  
  46.  
  47. sub translate_to_C {
  48.     my $this=shift;
  49.     my $value=shift;
  50.  
  51.     my @choices=$this->question->choices_split;
  52.     $this->question->template->i18n('');
  53.     my @choices_c=$this->question->choices_split;
  54.     $this->question->template->i18n(1);
  55.     
  56.     for (my $x=0; $x <= $#choices; $x++) {
  57.         return $choices_c[$x] if $choices[$x] eq $value;
  58.     }
  59.     debug developer => sprintf(gettext("Input value, \"%s\" not found in C choices! This should never happen. Perhaps the templates were incorrectly localized."), $value);
  60.     return '';
  61. }
  62.  
  63. sub translate_to_C_uni {
  64.     my $this=shift;
  65.     my $value=shift;
  66.     my @choices=$this->question->choices_split;
  67.     $this->question->template->i18n('');
  68.     my @choices_c=$this->question->choices_split;
  69.     $this->question->template->i18n(1);
  70.  
  71.     for (my $x=0; $x <= $#choices; $x++) {
  72.         return $choices_c[$x] if to_Unicode($choices[$x]) eq $value;
  73.     }
  74.     debug developer => sprintf(gettext("Input value, \"%s\" not found in C choices! This should never happen. Perhaps the templates were incorrectly localized."), $value);
  75.     return '';
  76. }
  77.  
  78. 1
  79.