File Coverage

blib/lib/Log/Funlog/Lang.pm
Criterion Covered Total %
statement 20 24 83.3
branch 3 8 37.5
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 28 38 73.6


line stmt bran cond sub pod time code
1             package Log::Funlog::Lang;
2              
3             =head1 NAME
4              
5             Log::Funlog::Lang - Language pack for Log::Funlog
6              
7             =head1 SYNOPSIS
8              
9             use Log::Funlog::Lang;
10             my @res=Log::Funlog::Lang->new( language );
11             my @texts=@{ $res[1] };
12             my $language_given=$res[0];
13              
14             =head1 DESCRIPTION
15              
16             This is a perl module used by B to obtain a list of funny things in the language of the user.
17              
18             =head1 OPTIONS
19              
20             B try to determinate the language of the user by parsing LC_MESSAGES and LANG. If it doesn't find any infos in these environment variable, it use 'en'
21              
22             If it occurs, you must specify the language by the widely used two letters (fr, en, ...)
23              
24             =over
25              
26             =item B
27              
28             Two-letters code specifying language to use.
29              
30             Available languages are: fr, en
31              
32             Default to 'en'.
33              
34             =back
35              
36             =head1 AUTHOR
37              
38             Gabriel Guillon, from Chashew team
39              
40             korsani-spam@free-spam.fr-spam
41              
42             (remove you-know-what :)
43              
44             =head1 LICENCE
45              
46             As Perl itself.
47              
48             Let me know if you have added some features, or removed some bugs ;)
49              
50             =cut
51              
52             BEGIN {
53 1     1   48502 use Exporter;
  1         2  
  1         83  
54 1     1   16 @ISA=qw(Exporter);
55 1         2 @EXPORT=qw();
56 1         21 $VERSION='0.3';
57             }
58 1     1   6 use strict;
  1         5  
  1         39  
59 1     1   6 use Carp;
  1         1  
  1         451  
60             my @fun;
61             my %fun=(
62             'fr' => ["-- this line will never be written --",
63             "Pfiou... marre de logger, moi",
64             "J'ai faim!",
65             "Je veux faire pipi!",
66             "Dis, t'as pensé à manger?",
67             "Fait froid dans ce process, non?",
68             "Fait quel temps, dehors?",
69             "Aller, pastis time!",
70             "Je crois que je suis malade...",
71             "Dis, tu peux me choper un sandwich?",
72             "On se fait une toile?",
73             "Aller, décolle un peu de l'écran",
74             "Tu fais quoi ce soir, toi?",
75             "On va en boîte?",
76             "Pousse-toi un peu, je vois rien",
77             "Vivement les vacances...",
78             "Mince, j'ai pas prévenu ma femme que je finissais tard...",
79             "Il est chouette ton projet?",
80             "Bon, il est bientôt fini, ce process??",
81             "Je m'ennuie...",
82             "Tu peux me mettre la télé?",
83             "Y a quoi ce soir?",
84             "J'irais bien faire un tour à Pigalle, moi.",
85             "Et si je formattais le disque?",
86             "J'me ferais bien le tour du monde...",
87             "Je crois que je suis homosexuel...",
88             "Bon, je m'en vais, j'ai des choses à faire.",
89             "Et si je changeais de taf? OS, c'est mieux que script, non?",
90             "J'ai froid!",
91             "J'ai chaud!",
92             "Tu me prend un café?",
93             "T'es plutôt chien ou chat, toi?",
94             "Je crois que je vais aller voir un psy...",
95             "Tiens, 'longtemps que j'ai pas eu de news de ma soeur!",
96             "Comment vont tes parents?",
97             "Comment va Arthur, ton poisson rouge?",
98             "Ton chien a fini de bouffer les rideaux?",
99             "Ton chat pisse encore partout?",
100             "Tu sais ce que fait ta fille, là?",
101             "T'as pas encore claqué ton chef?",
102             "Toi, tu t'es engueulé avec ta femme, ce matin...",
103             "T'as les yeux en forme de contener. Soucis?",
104             "Et si je partais en boucle infinie?",
105             "T'es venu à pied?",
106             "Et si je veux pas exécuter la prochaine commande?",
107             "Tiens, je vais me transformer en virus...",
108             "Ca t'en bouche un coin, un script qui parle, hein?",
109             "Ah m...., j'ai oublié les clés à l'intérieur de la voiture...",
110             "T'as pas autre chose à faire, là?",
111             "Ca devient relou...",
112             "T'as pensé à aller voir un psy?",
113             "Toi, tu pense à changer de job..."
114             ],
115             'en' => ["-- this line will never be written --",
116             "(scratch scratch ...)",
117             "TOOOOO!!!! A DONUT !!!"],
118             );
119             sub new {
120 2     2 0 812 shift;
121 2         7 my $LC_MESSAGES=lc(shift);
122 2 50       7 if (! $LC_MESSAGES) {
123 0 0       0 if (exists $ENV{'LC_MESSAGES'}) {
    0          
124 0         0 $LC_MESSAGES=substr($ENV{'LC_MESSAGES'},0,2);
125             } elsif (exists $ENV{'LANG'}) {
126 0         0 $LC_MESSAGES=substr($ENV{'LANG'},0,2);
127             } else {
128 0         0 $LC_MESSAGES='en';
129             }
130             }
131 2         4 $LC_MESSAGES=lc($LC_MESSAGES);
132 2 100       9 if (! exists $fun{$LC_MESSAGES}) {
133             # carp("You specified a not implemented language: $LC_MESSAGES\nDefaulting to 'en'");
134 1         3 $LC_MESSAGES='en';
135             }
136 2         3 return ($LC_MESSAGES,\@{ $fun{$LC_MESSAGES} });
  2         10  
137             };
138             1;