Hi,

OK, I'll try later. I'm not yet a Padre user and in general it can be 
quite unhelpful to have someone committing who isn't eating their own 
dog food.

It looks to me that the existing locale code is probably exactly what 
you would think is required after reading the gettext + wxWidgets docs.

When the original questions were asked on this list about locales, you 
looked to be going about it the correct way to me, so no reason to offer 
up my non-standard method.

Note: code that makes assumptions about the literal output of sprintf 
may break if a locale other than en_XX is used. Date strings for sure 
and number formatting on some Perl versions. The effect of setting the 
locale on Perl functions is inconsistent across different platforms and 
versions of Perl as I recall. Hooray!!

It would also be simple to add a menu item that allows user to change 
the 'locale' which will work fine for language translations. However, 
given the above, having Padre running in a different arbitrary locale to 
the system would just be a source of grief I expect.

Regards

Mark


On 14/02/2011 14:50, Gabor Szabo wrote:
> On Fri, Feb 4, 2011 at 5:56 PM, Mark Dootson<mark.doot...@znix.com>  wrote:
>> Hi,
>>
>> I took a look at the locale code, and assuming that what is required is
>> to load the language translations, I don't think you should be setting
>> the Locale to en_GB by default.
>>
>> The following code allows you to save .mo catalogs with names such as
>>
>> en_GB.mo
>> en_US.mo
>>
>>
>> code will load the most appropriate catalogs if they exist.
>> No need at all to change the locale of the user. If message catalogs for
>> user's locale are available, they'll get translations. If not, they'll
>> get the strings in 'en'. Of course, you don't actually need a catalog
>> for 'en' if that's what you decide represents the locale for the strings
>> in the source code.
>>
>> Hope this helps.
>>
>> #---------------------------------------------------------------------
>>
>> # Suggested alternate way to load language files for Padre
>>
>> my $langid = Wx::Locale::GetSystemLanguage;
>> my $locale = Wx::Locale->new($langid);
>>
>> # add lookup prefixes
>> my $catpathprefix = 'path to where the mo files are';
>> $locale->AddCatalogLookupPathPrefix( $catpathprefix );
>>
>> # add catalogs in order
>> my($shortfile, $longfile);
>>
>> my $langname = $locale->GetCanonicalName(); # en_GB, en_US etc.
>>
>> my $shortname = ( $langname ) ? substr($langname,0,2) : 'en';
>>
>> my $filename = qq($catpathprefix/$shortname.mo);
>> $shortfile = 1 if -f $filename;
>>
>> if($shortfile) {
>>      my $result = $locale->AddCatalog( $shortname ) ;
>>      warn (gettext('Unable to load language for locale') . ' %s',
>> $shortname) if !$result;
>> }
>>
>> $filename = qq($catpathprefix/$langname.mo);
>>
>> $longfile = 1 if -f $filename;
>> if( ($longfile)&&  ( $shortname ne $langname) ) {
>>      my $result = $locale->AddCatalog( $langname );
>>      warn(gettext('Unable to load language for locale') . ' %s',
>> $langname) if !$result;
>> }
>>
>> #----------------------------------------------------------------------
>>
>
> Mark, why don't you just join us on IRC
> http://padre.perlide.org/irc.html?channel=padre
> ask someone to give you a commit bit
> and make the changes?
>
> Then we'll have at least one committer who understand wx :)
>
> regards
>     Gabor
> _______________________________________________
> Padre-dev mailing list
> Padre-dev@perlide.org
> http://mail.perlide.org/mailman/listinfo/padre-dev

_______________________________________________
Padre-dev mailing list
Padre-dev@perlide.org
http://mail.perlide.org/mailman/listinfo/padre-dev

Reply via email to