import rt 3.2.2
[freeside.git] / rt / lib / RT / I18N / cs.pm
1 # {{{ BEGIN BPS TAGGED BLOCK
2
3 # COPYRIGHT:
4 #  
5 # This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
6 #                                          <jesse@bestpractical.com>
7
8 # (Except where explicitly superseded by other copyright notices)
9
10
11 # LICENSE:
12
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
16 # from www.gnu.org.
17
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 # General Public License for more details.
22
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27
28 # CONTRIBUTION SUBMISSION POLICY:
29
30 # (The following paragraph is not intended to limit the rights granted
31 # to you to modify and distribute this software under the terms of
32 # the GNU General Public License and is only of importance to you if
33 # you choose to contribute your changes and enhancements to the
34 # community by submitting them to Best Practical Solutions, LLC.)
35
36 # By intentionally submitting any modifications, corrections or
37 # derivatives to this work, or any other work intended for use with
38 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 # you are the copyright holder for those contributions and you grant
40 # Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 # royalty-free, perpetual, license to use, copy, create derivative
42 # works based on those contributions, and sublicense and distribute
43 # those contributions and any derivatives thereof.
44
45 # }}} END BPS TAGGED BLOCK
46 package RT::I18N::cs;
47
48 # # CZECH TRANSLATORS COMMENTS see Locale::Maketext::TPJ13
49 # Obecne parametry musi byt docela slozite (v pripade Slavistickych jazyku)
50 # typu pocet, slovo, pad a rod 
51 #
52 #pad 1., rod muzsky:
53 #0 krecku
54 #1 krecek
55 #2..4 krecci
56 #5.. krecku (nehodi se zde resit pravidlo mod 1,2,3,4 krom mod 11,12,13,14)
57 #
58 #0 kabatu
59 #1 kabat
60 #2..4 kabaty
61 #5 kabatu
62 #
63 # => Vyplati se udelat quant s parametry typu pocet, slovo1, slovo2..4, slovo5 a slovo0
64 #
65
66 sub quant {
67   my($handle, $num, @forms) = @_;
68
69   return $num if @forms == 0; # what should this mean?
70   return $forms[3] if @forms > 3 and $num == 0; # special zeroth case
71
72   # Normal case:
73   # Note that the formatting of $num is preserved.
74   #return( $handle->numf($num) . ' ' . $handle->numerate($num, @forms) );
75   return( $handle->numerate($num, @forms) );
76    # Most human languages put the number phrase before the qualified phrase.
77 }
78
79
80 sub numerate {
81  # return this lexical item in a form appropriate to this number
82   my($handle, $num, @forms) = @_;
83   my $s = ($num == 1);
84
85   return '' unless @forms;
86   return
87    $s ? $forms[0] :
88    ( $num > 1 && $num < 5 ) ? $forms[1] :
89    $forms[2];
90 }
91
92 #--------------------------------------------------------------------------
93
94 sub numf {
95   my($handle, $num) = @_[0,1];
96   if($num < 10_000_000_000 and $num > -10_000_000_000 and $num == int($num)) {
97     $num += 0;  # Just use normal integer stringification.
98          # Specifically, don't let %G turn ten million into 1E+007
99   } else {
100     $num = CORE::sprintf("%G", $num);
101      # "CORE::" is there to avoid confusion with the above sub sprintf.
102   }
103   while( $num =~ s/^([-+]?\d+)(\d{3})/$1,$2/s ) {1}  # right from perlfaq5
104    # The initial \d+ gobbles as many digits as it can, and then we
105    #  backtrack so it un-eats the rightmost three, and then we
106    #  insert the comma there.
107
108   $num =~ tr<.,><,.> if ref($handle) and $handle->{'numf_comma'};
109    # This is just a lame hack instead of using Number::Format
110   return $num;
111 }
112
113 1;