Changeset 512


Ignore:
Timestamp:
08/07/08 13:10:40 (5 years ago)
Author:
bruno
Message:

Transport pb_display functions using gettext from Base into a separate module to allow Base to have only basic perl deps only abd be used in setupvm easily.

Location:
devel
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r503 r512  
    2121use English; 
    2222use locale; 
    23 use Locale::gettext; 
    2423use POSIX qw(setlocale); 
    2524 
     
    3938 
    4039our @ISA = qw(Exporter); 
    41 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_display pb_display_init pb_get_uri pb_get_content pb_display_file pb_syntax_init pb_syntax pb_temp_init $pbdebug $pbLOG $pbdisplaytype $pblocale); 
     40our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_display_file pb_syntax_init pb_syntax pb_temp_init $pbdebug $pbLOG $pbdisplaytype $pblocale); 
    4241 
    4342=pod 
     
    8584  pb_log_init(2,\*STDOUT); 
    8685  pb_log(1,"Message to print\n"); 
    87  
    88   # 
    89   # Manages prints of the program 
    90   # 
    91   pb_display_init("text","fr_FR:UTF-8"); 
    92   pb_display("Message to print\n"); 
    9386 
    9487  # 
     
    271264 
    272265 
    273 =item B<pb_display_init> 
    274  
    275 This function initializes the environment used by the pb_display function. 
    276  
    277 The first parameter is the type of display which will be used. Could be "text", "web", "newt",... 
    278 The second parameter is the loacle to be used. 
    279  
    280 The call to B<pb_display_init> is typically done after getting a parameter on the CLI indicating the locale used or the type of interface to report messages to. 
    281  
    282 =cut 
    283  
    284 sub pb_display_init { 
    285  
    286 $pbdisplaytype = shift || "text"; 
    287 $pblocale = shift || "C"; 
    288  
    289 setlocale(LC_ALL, $pblocale); 
    290 pb_log(1,"Using $pbdisplaytype interface with $pblocale locale\n"); 
    291  
    292 if ($pbdisplaytype =~ /text/) { 
    293 } elsif ($pbdisplaytype = /newt/) { 
    294 } else { 
    295     die "display system $pbdisplaytype unsupported"; 
    296 } 
    297 } 
    298  
    299 =item B<pb_display> 
    300  
    301 This function prints the messages passed as parameter using the configuration set up with the B<pb_display_init> function. 
    302  
    303 Here is a usage example: 
    304  
    305   pb_display_init("text","fr_FR.UTF-8"); 
    306   pb_display("Hello World\n"); 
    307  
    308   will print: 
    309    
    310   Bonjour Monde 
    311  
    312 =cut  
    313  
    314 sub pb_display { 
    315  
    316 my $msg = shift; 
    317  
    318 if ($pbdisplaytype =~ /text/) { 
    319     print STDOUT gettext($msg); 
    320     } 
    321 } 
    322  
    323266=item B<pb_display_file> 
    324267 
  • devel/pb/bin/pb

    r507 r512  
    2222use ProjectBuilder::Version; 
    2323use ProjectBuilder::Base; 
     24use ProjectBuilder::Display; 
    2425use ProjectBuilder::Conf; 
    2526use ProjectBuilder::Distribution; 
Note: See TracChangeset for help on using the changeset viewer.