| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Debconf::Gettext - Enables gettext for internationalization. |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
package Debconf::Gettext; |
| 10 |
use warnings; |
| 11 |
use strict; |
| 12 |
|
| 13 |
=head1 DESCRIPTION |
| 14 |
|
| 15 |
This module should be used by any part of debconf that is internationalized |
| 16 |
and uses the gettext() function to get translated text. This module will |
| 17 |
attempt to use Locale::gettext to provide the gettext() function. However, |
| 18 |
since debconf must be usable on the base system, which does not include |
| 19 |
Locale::gettext, it will detect if loading the module fails, and fall back |
| 20 |
to providing a gettext() function that only works in the C locale. |
| 21 |
|
| 22 |
This module also calls textdomain() if possible; the domain used by debconf |
| 23 |
is "debconf". |
| 24 |
|
| 25 |
=cut |
| 26 |
|
| 27 |
BEGIN { |
| 28 |
eval 'use Locale::gettext'; |
| 29 |
if ($@) { |
| 30 |
# Failed; make up and export our own stupid gettext() function. |
| 31 |
eval { |
| 32 |
sub gettext { |
| 33 |
return shift; |
| 34 |
} |
| 35 |
}; |
| 36 |
} |
| 37 |
else { |
| 38 |
# Locale::gettext initialized; proceed with setup. |
| 39 |
textdomain('debconf'); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
# Now there is a gettext symbol in our symbol table, which must be exported |
| 44 |
# to our caller. |
| 45 |
use base qw(Exporter); |
| 46 |
our @EXPORT=qw(gettext); |
| 47 |
|
| 48 |
=head1 AUTHOR |
| 49 |
|
| 50 |
Joey Hess <[email protected]> |
| 51 |
|
| 52 |
=cut |
| 53 |
|
| 54 |
1 |