Skip to content

Commit

Permalink
Work around Locale::CLDR::Locales::* loading 'bignum'
Browse files Browse the repository at this point in the history
Loading 'bignum' causes $Math::BigInt::upgrade and
$Math::BigFloat::downgrade to be overwritten. However,
we want to make sure these values stay as they are set
by LedgerSMB::PGNumber (which is: no downgrading!)

This is necessary for Perl 5.36+ compatibility.
  • Loading branch information
ehuelsmann committed Oct 6, 2023
1 parent a8dd239 commit 66845e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/LedgerSMB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ sub enabled_languages {
sub enabled_countries {
my ($self) = @_;

local $Math::BigInt::upgrade;
local $Math::BigFloat::downgrade;
my $regions = Locale::CLDR->new($self->{_user}->{language})->all_regions;
return [
map {
Expand Down
8 changes: 6 additions & 2 deletions lib/LedgerSMB/Database/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ sub charts_of_accounts {
###TODO: Define a parameter to the SQL directory!!
my $basedir = File::Spec->catfile('.', 'locale', 'coa');
my $countries = _list_directory($basedir);
my %regions = %{Locale::CLDR->new($self->language)
->all_regions};
my $cldr = do {
local $Math::BigInt::upgrade = undef;
local $Math::BigFloat::downgrade = undef;
Locale::CLDR->new($self->language);
};
my %regions = %{$cldr->all_regions};

return {
map {
Expand Down
6 changes: 5 additions & 1 deletion lib/LedgerSMB/I18N.pm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ Get a country localized list to allow user selection

sub get_country_list {
my $language = shift;
my %regions = Locale::CLDR->new($language)->all_regions->%*;
my %regions = do {
local $Math::BigInt::upgrade = undef;
local $Math::BigFloat::downgrade = undef;
Locale::CLDR->new($language)->all_regions->%*
};
return [
sort { $a->{text} cmp $b->{text} }
map { +{ value => uc($_),
Expand Down
6 changes: 5 additions & 1 deletion lib/LedgerSMB/Scripts/user.pm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ sub preference_screen {
dateformats => $dateformats,
language_codes => _language_options(
$request,
Locale::CLDR->new( $prefs->{language} )),
do {
local $Math::BigInt::upgrade = undef;
local $Math::BigFloat::downgrade = undef;
Locale::CLDR->new( $prefs->{language} );
}),
login => $login,
numberformats => $numberformats,
password_expires => {
Expand Down

0 comments on commit 66845e5

Please sign in to comment.