Hi,

I've followed this up because I'm currently working on ways to internationalize 
without using gettext (at least not creating my own catalogs) and menu labels 
are a difficulty.

I've had a look at the wxWidgets source and the parsing of the menu label wraps 
'ctrl', 'alt' and 'shift' in the wxTRANSLATE macro - which means - to get 
translations you need to have a gettext catalog for the current locale with 
translations for 'ctrl', 'alt' and 'shift', and the labels would have to be set 
using appropriate text for current locale.

In the wxWidgets source, there are gettext catalogs under the 'locale' 
directory.
I edited de.po from

#: ../src/common/menucmn.cpp:197
msgid "ctrl"
msgstr "ctrl"

to

#: ../src/common/menucmn.cpp:197
msgid "ctrl"
msgstr "strg"

then compiled with
make de.mo

(actually mingw32-make as I'm on Windows)

The attached code now does exactly what you want in the correct way. Looks like 
I'll have to learn to love gettext :-(

Regards

Mark


Mark Dootson wrote:
Hi,

I think you have to use Wx::AcceleratorTable

Attached is minimal script I used to check suggestion.

Regards

Mark

herbert breunung wrote:
thanks  i already tried something similiar ugly but i didnt know
that the object that making this is Wx::AcceleratorTable.
i will try to delete it or override it, since i capture key events anyway.
tanks a lot for that tip

thanks
herbert


use strict;
package MyApp;
use Wx qw(wxLANGUAGE_GERMAN);
use base qw( Wx::App );

sub OnInit {
    my $self = shift;
    
    my $locale = Wx::Locale->new(wxLANGUAGE_GERMAN);
    $locale->AddCatalogLookupPathPrefix('c:\pathtolangdir');
    $locale->AddCatalog('de');
    my $mwin = MyFrame->new();
    $self->SetTopWindow($mwin);
    $mwin->Show(1);
    return 1;
}


package MyFrame;
use Wx qw( :id :misc wxACCEL_CTRL );
use Wx::Event qw( EVT_MENU );
use base qw( Wx::Frame );


sub new {
    my $class = shift;
    my $self = $class->SUPER::new( 
        undef, 
        wxID_ANY, 
        'Test App',
        wxDefaultPosition,
        wxDefaultSize
        );
    
    
    $self->{menu} = Wx::Menu->new();
    my $id1 = $self->{menu}->Append(wxID_ANY, "First &Task\tStrg+T")->GetId();
    my $id2 = $self->{menu}->Append(wxID_ANY, "Some &Other 
Task\tStrg+O")->GetId();
    my $menubar = Wx::MenuBar->new();
    $menubar->Append($self->{menu}, '&File');
    $self->SetMenuBar($menubar);
    
    
    EVT_MENU($self, $id1, \&on_event_task);
    EVT_MENU($self, $id2, \&on_event_task);
    
    $self->Centre;
    return $self;
}

sub on_event_task {
    my($self, $event) = @_;
    my $labeltext = $self->{menu}->GetLabelText($event->GetId);
    Wx::LogMessage('Event "%s"', $labeltext);
}


package main;

my $app = MyApp->new();
$app->MainLoop;

1;


    

Reply via email to