diff options
Diffstat (limited to 'perl-install/common.pm')
| -rw-r--r-- | perl-install/common.pm | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index 508e6b31f..23ae4ea6f 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -7,10 +7,11 @@ BEGIN { eval { require Locale::gettext } } #- allow common.pm to be used in drak use log; use run_program; +use POSIX qw(locale_h); use Exporter; our @ISA = qw(Exporter); -our @EXPORT = qw($SECTORSIZE N P N_ check_for_xserver files_exist formatTime MB formatXiB get_libdir get_parent_uid is_running is_uefi kernel_uefi_type makedev mageia_release mageia_release_info mount_efivars removeXiBSuffix require_root_capability setVirtual set_alternative set_l10n_sort set_permissions to_utf8 translate uefi_type unmakedev); +our @EXPORT = qw($SECTORSIZE N P N_ check_for_xserver files_exist formatTime MB formatXiB get_libdir get_parent_uid init_setlocale is_running is_uefi kernel_uefi_type makedev mageia_release mageia_release_info mount_efivars removeXiBSuffix require_root_capability setVirtual set_alternative set_l10n_sort set_permissions to_utf8 translate uefi_type unmakedev); # perl_checker: RE-EXPORT-ALL push @EXPORT, @MDK::Common::EXPORT; @@ -34,6 +35,20 @@ our $SECTORSIZE = 512; =over +=item init_setlocale() + +Initialise all locale categories. Set LC_NUMERIC to 'C' (otherwise eval "1.5" returns 1 +in fr_FR for example). Set all other categories according to the current value of the +LC_ALL environment variable, or if that is undefined, the LANG environment variable, or +if that is undefined, the system default. + +=cut + +sub init_setlocale() { + setlocale(LC_ALL, ''); + setlocale(LC_NUMERIC, 'C'); +} + =item N($format, ...) translate a message by calling gettext(). eg: @@ -171,8 +186,8 @@ only LC_COLLATE will have no effect. sub set_l10n_sort() { my $collation_locale = $ENV{LC_ALL}; if (!$collation_locale) { - $collation_locale = c::setlocale(c::LC_COLLATE()); - $collation_locale =~ /UTF-8/ or c::setlocale(c::LC_COLLATE(), "$collation_locale.UTF-8"); + $collation_locale = setlocale(LC_COLLATE); + $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8"); } } |
