import of rt 3.0.4
[freeside.git] / rt / lib / RT / I18N / cs.pm
1 package RT::I18N::cs;
2
3 # # CZECH TRANSLATORS COMMENTS see Locale::Maketext::TPJ13
4 # Obecne parametry musi byt docela slozite (v pripade Slavistickych jazyku)
5 # typu pocet, slovo, pad a rod 
6 #
7 #pad 1., rod muzsky:
8 #0 krecku
9 #1 krecek
10 #2..4 krecci
11 #5.. krecku (nehodi se zde resit pravidlo mod 1,2,3,4 krom mod 11,12,13,14)
12 #
13 #0 kabatu
14 #1 kabat
15 #2..4 kabaty
16 #5 kabatu
17 #
18 # => Vyplati se udelat quant s parametry typu pocet, slovo1, slovo2..4, slovo5 a slovo0
19 #
20
21 sub quant {
22   my($handle, $num, @forms) = @_;
23
24   return $num if @forms == 0; # what should this mean?
25   return $forms[3] if @forms > 3 and $num == 0; # special zeroth case
26
27   # Normal case:
28   # Note that the formatting of $num is preserved.
29   #return( $handle->numf($num) . ' ' . $handle->numerate($num, @forms) );
30   return( $handle->numerate($num, @forms) );
31    # Most human languages put the number phrase before the qualified phrase.
32 }
33
34
35 sub numerate {
36  # return this lexical item in a form appropriate to this number
37   my($handle, $num, @forms) = @_;
38   my $s = ($num == 1);
39
40   return '' unless @forms;
41   return
42    $s ? $forms[0] :
43    ( $num > 1 && $num < 5 ) ? $forms[1] :
44    $forms[2];
45 }
46
47 #--------------------------------------------------------------------------
48
49 sub numf {
50   my($handle, $num) = @_[0,1];
51   if($num < 10_000_000_000 and $num > -10_000_000_000 and $num == int($num)) {
52     $num += 0;  # Just use normal integer stringification.
53          # Specifically, don't let %G turn ten million into 1E+007
54   } else {
55     $num = CORE::sprintf("%G", $num);
56      # "CORE::" is there to avoid confusion with the above sub sprintf.
57   }
58   while( $num =~ s/^([-+]?\d+)(\d{3})/$1,$2/s ) {1}  # right from perlfaq5
59    # The initial \d+ gobbles as many digits as it can, and then we
60    #  backtrack so it un-eats the rightmost three, and then we
61    #  insert the comma there.
62
63   $num =~ tr<.,><,.> if ref($handle) and $handle->{'numf_comma'};
64    # This is just a lame hack instead of using Number::Format
65   return $num;
66 }
67
68 1;