import of rt 3.0.9
[freeside.git] / rt / lib / RT / I18N / cs.pm
1 # BEGIN LICENSE BLOCK
2
3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4
5 # (Except where explictly superceded by other copyright notices)
6
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
10 # from www.gnu.org.
11
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
21
22
23 # END LICENSE BLOCK
24 package RT::I18N::cs;
25
26 # # CZECH TRANSLATORS COMMENTS see Locale::Maketext::TPJ13
27 # Obecne parametry musi byt docela slozite (v pripade Slavistickych jazyku)
28 # typu pocet, slovo, pad a rod 
29 #
30 #pad 1., rod muzsky:
31 #0 krecku
32 #1 krecek
33 #2..4 krecci
34 #5.. krecku (nehodi se zde resit pravidlo mod 1,2,3,4 krom mod 11,12,13,14)
35 #
36 #0 kabatu
37 #1 kabat
38 #2..4 kabaty
39 #5 kabatu
40 #
41 # => Vyplati se udelat quant s parametry typu pocet, slovo1, slovo2..4, slovo5 a slovo0
42 #
43
44 sub quant {
45   my($handle, $num, @forms) = @_;
46
47   return $num if @forms == 0; # what should this mean?
48   return $forms[3] if @forms > 3 and $num == 0; # special zeroth case
49
50   # Normal case:
51   # Note that the formatting of $num is preserved.
52   #return( $handle->numf($num) . ' ' . $handle->numerate($num, @forms) );
53   return( $handle->numerate($num, @forms) );
54    # Most human languages put the number phrase before the qualified phrase.
55 }
56
57
58 sub numerate {
59  # return this lexical item in a form appropriate to this number
60   my($handle, $num, @forms) = @_;
61   my $s = ($num == 1);
62
63   return '' unless @forms;
64   return
65    $s ? $forms[0] :
66    ( $num > 1 && $num < 5 ) ? $forms[1] :
67    $forms[2];
68 }
69
70 #--------------------------------------------------------------------------
71
72 sub numf {
73   my($handle, $num) = @_[0,1];
74   if($num < 10_000_000_000 and $num > -10_000_000_000 and $num == int($num)) {
75     $num += 0;  # Just use normal integer stringification.
76          # Specifically, don't let %G turn ten million into 1E+007
77   } else {
78     $num = CORE::sprintf("%G", $num);
79      # "CORE::" is there to avoid confusion with the above sub sprintf.
80   }
81   while( $num =~ s/^([-+]?\d+)(\d{3})/$1,$2/s ) {1}  # right from perlfaq5
82    # The initial \d+ gobbles as many digits as it can, and then we
83    #  backtrack so it un-eats the rightmost three, and then we
84    #  insert the comma there.
85
86   $num =~ tr<.,><,.> if ref($handle) and $handle->{'numf_comma'};
87    # This is just a lame hack instead of using Number::Format
88   return $num;
89 }
90
91 1;