Re: Native Language Dialogue boxes.

Steve Cookson - gmail <[email protected]>
Newsgroups gmane.comp.lang.perl.wxperl
Message-ID <[email protected]>
# Whoops missed off list.

Hi Johan,

Thanks for taking the trouble to do this.  It worked as advertised, but 
only for buttons.

What about this one (tt-1.pl).

Cancelar still works but what about the other attributes of the box.

Run as before and click on the font button.  I've added:

sub on_click_font{
      my ($i_frame, $event) = @_;

      my $dlg_format = Wx::RichTextFormattingDialog -> newFull 
(wxRICHTEXT_FORMAT_FONT,$i_frame,"Format Paragraph",wxID_ANY, 
wxDefaultPosition, wxDefaultSize,wxNO_BORDER); # , -1, (("Paragraph 
details"))
      $dlg_format->ShowModal();
      return;
}

Regards

Steve.



On 17-10-2014 22:47, Johan Vromans wrote:
> Steve Cookson - gmail <[email protected]> writes:
>
>> Hi Johan,
>>
>> Thanks for this.
>>
>> On 17/10/14 12:22, Johan Vromans wrote:
>>>       use Wx qw(wxLANGUAGE_DEFAULT wxLOCALE_LOAD_DEFAULT);
>>>       my $local = Wx::Locale->new(wxLOCALE_LOAD_DEFAULT,
>>> wxLOCALE_LOAD_DEFAULT );
>>>       $local->AddCatalog("app"); # replace with the appropriate catalog name
>> I'm not sure about this last line,  where do I get these catalogues
>> from?  Or is it just "pr_BR", or something?
> This is for your own, application specific catalogue with translations
> of application texts. If you are only targetting the standard dialogue
> boxes, you don't need it.
>
> Appended is a small, wxGlade generated program that shows a Cancel
> button. When run with the correct locale, the button should read
> different.
>
> For example
>
>    perl tt.pl
>
> will show [Cancel] .
>
>    env LANG=pt_PTL perl tt.pl
>
> will show [Cancelar] .
>
> HTH,
>
> -- Johan
>
tt-1.pl (application/x-perl, 1.9 KB)
#!/usr/bin/perl -w -- 
#
# generated by wxGlade acbfabfba67b+ on Fri Oct 17 23:42:56 2014
#
# To get wxPerl visit http://wxPerl.sourceforge.net/
#

use Wx 0.15 qw[:allclasses];
use strict;

package MyDialog;

use Wx qw[:everything];
use base qw(Wx::Dialog);
use strict;

use Wx::Locale gettext => '_T';
sub new {
    my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_;
    $parent = undef              unless defined $parent;
    $id     = -1                 unless defined $id;
    $title  = ""                 unless defined $title;
    $pos    = wxDefaultPosition  unless defined $pos;
    $size   = wxDefaultSize      unless defined $size;
    $name   = ""                 unless defined $name;

    $style = wxDEFAULT_DIALOG_STYLE 
        unless defined $style;

    $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name );
    $self->{button_1} = Wx::Button->new($self, wxID_ANY, _T("Font"));


    Wx::Event::EVT_BUTTON($self, $self->{button_1}, \&on_click_font);
        
    $self->SetTitle(_T("dialog_1"));
    $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL);
    $self->{sizer_1}->Add($self->{button_1}, 0, 0, 0);
    $self->SetSizer($self->{sizer_1});
    $self->{sizer_1}->Fit($self);
    $self->Layout();
    
    return $self;
}


sub on_click_font{
    my ($i_frame, $event) = @_;
    
    my $dlg_format = Wx::RichTextFormattingDialog -> newFull (wxRICHTEXT_FORMAT_FONT,$i_frame,"Format Paragraph",wxID_ANY, wxDefaultPosition, wxDefaultSize,wxNO_BORDER); # , -1, (("Paragraph details"))
    $dlg_format->ShowModal();
    return;
}

1;

package main;

use Wx qw(wxLANGUAGE_DEFAULT wxLOCALE_LOAD_DEFAULT);

unless(caller){
    my $local = Wx::Locale->new(wxLOCALE_LOAD_DEFAULT, wxLOCALE_LOAD_DEFAULT );

    local *Wx::App::OnInit = sub{1};
    my $app = Wx::App->new();
    Wx::InitAllImageHandlers();

    my $dialog_1 = MyDialog->new();

    $app->SetTopWindow($dialog_1);
    $dialog_1->Show(1);
    $app->MainLoop();
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.