develooper Front page | perl.wxperl.users | Postings from March 2012

Re: New release of Wx / Alien::wxWidgets

Thread Previous | Thread Next
From:
Mark Dootson
Date:
March 3, 2012 17:34
Subject:
Re: New release of Wx / Alien::wxWidgets
Message ID:
4F52C67F.5000705@znix.com
Hi,

On 29/02/2012 15:22, Breno de Oliveira wrote:

> Wx.pm... not so much. It's the same as before, where it passes all tests except one:
>
> #   Failed test 'GetLanguageInfo isa Wx::LanguageInfo'
> #   at t/21_locale.t line 9.
> #     GetLanguageInfo isn't defined
> Can't call method "GetCanonicalName" on an undefined value at t/21_locale.t line 11.
> # Looks like you planned 4 tests but ran 1.
> # Looks like you failed 1 test of 1 run.
> # Looks like your test exited with 255 just after 1.
> t/21_locale.t .........
> Dubious, test returned 255 (wstat 65280, 0xff00)
> Failed 4/4 subtests

It seems this is a wxWidgets issue:

http://trac.wxwidgets.org/ticket/14039

Wx can return an undefined value for
Wx::Locale::GetLanguageInfo(wxLANGUAGE_DEFAULT);

if it cannot determine default language.

Apparently, MacOSX system calls will return strings like 'en_CH' if 
during installation a user selects, say, a language of English and a 
location of Switzerland.

A simple workaround until the next wxWidgets release is to default to 
English if the system fails to find a default language

my $langinfo = Wx::Locale::GetLanguageInfo(wxLANGUAGE_DEFAULT);
$langinfo = Wx::Locale::GetLanguageInfo(wxLANGUAGE_ENGLISH) if 
!defined($langinfo);

Fix for t/21_locale.t now in SVN

Note: obviously the  thing to do if you encounter 'aa_BB' and you don't 
support 'aa_BB' is to default to the short part 'aa'. However, we don't 
have access to that from wxWidgets in current interface.

If it is important to you in real code you could get it by doing

my $locstring = qx(defaults read NSGlobalDomain AppleLocale);

armed with that:

my $langinfo = Wx::Locale::GetLanguageInfo(wxLANGUAGE_DEFAULT);
if(!defined($langinfo)) {
   my $locstring = qx(defaults read NSGlobalDomain AppleLocale);
   my ($short, $discard) = split(/_/,  $locstring);
   $langinfo = Wx::Locale::FindLanguageInfo( $short );
}
die 'Blechh' if !defined($langinfo);


Hope it helps.


Mark

















Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About