Changeset 513 in ProjectBuilder for 0.9.3/pb-modules


Ignore:
Timestamp:
Aug 7, 2008, 1:12:44 PM (16 years ago)
Author:
Bruno Cornec
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. (retrofiy in 0.9.3 to allow for setupvm to work)

File:
1 edited

Legend:

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

    r503 r513  
    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
Note: See TracChangeset for help on using the changeset viewer.