Revision ffae956c
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/Presenter/Text.pm | ||
---|---|---|
5 | 5 |
use parent qw(Exporter); |
6 | 6 |
|
7 | 7 |
use Exporter qw(import); |
8 |
our @EXPORT = qw(simple_format truncate); |
|
8 |
our @EXPORT = qw(format_man_days simple_format truncate);
|
|
9 | 9 |
|
10 | 10 |
use Carp; |
11 | 11 |
|
... | ... | |
32 | 32 |
return '<p>' . $text; |
33 | 33 |
} |
34 | 34 |
|
35 |
sub format_man_days { |
|
36 |
my ($self, $value, %params) = @_; |
|
37 |
|
|
38 |
return '---' if $params{skip_zero} && !$value; |
|
39 |
|
|
40 |
return $self->escape($::locale->text('#1 h', $::form->format_amount(\%::myconfig, $value, 2))) if 8.0 > $value; |
|
41 |
|
|
42 |
$value /= 8.0; |
|
43 |
my $output = $::locale->text('#1 MD', int($value)); |
|
44 |
my $rest = ($value - int($value)) * 8.0; |
|
45 |
$output .= ' ' . $::locale->text('#1 h', $::form->format_amount(\%::myconfig, $rest)) if $rest > 0.0; |
|
46 |
|
|
47 |
return $self->escape($output); |
|
48 |
} |
|
49 |
|
|
35 | 50 |
1; |
36 | 51 |
__END__ |
37 | 52 |
|
... | ... | |
53 | 68 |
|
54 | 69 |
=over 4 |
55 | 70 |
|
71 |
=item C<format_man_days $value, [%params]> |
|
72 |
|
|
73 |
C<$value> is interpreted to mean a number of hours (for C<$value> < 8) |
|
74 |
/ man days (if >= 8). Returns a translated, human-readable version of |
|
75 |
it, e.g. C<2 PT 2 h> for the value C<18> and German. |
|
76 |
|
|
77 |
If the parameter C<skip_zero> is trueish then C<---> is returned |
|
78 |
instead of the normal formatting if C<$value> equals 0. |
|
79 |
|
|
56 | 80 |
=item C<truncate $text, [%params]> |
57 | 81 |
|
58 | 82 |
Returns the C<$text> truncated after a certain number of |
locale/de/all | ||
---|---|---|
14 | 14 |
' Part Number missing!' => ' Artikelnummer fehlt!', |
15 | 15 |
' missing!' => ' fehlt!', |
16 | 16 |
'#1 (custom variable)' => '#1 (benutzerdefinierte Variable)', |
17 |
'#1 MD' => '#1 PT', |
|
18 |
'#1 h' => '#1 h', |
|
17 | 19 |
'#1 of #2 importable objects were imported.' => '#1 von #2 importierbaren Objekten wurden importiert.', |
18 | 20 |
'#1 prices were updated.' => '#1 Preise wurden aktualisiert.', |
19 | 21 |
'* there are restrictions for the perpetual method, look at chapter "Bemerkungen zu Bestandsmethode" in' => ' für die Bestandsmethode gibt es Einschränkungen, siehe Kapitel "Bemerkungen zu Bestandsmethode" in', |
Auch abrufbar als: Unified diff
Presenter: Funktion format_man_days()