Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Gtk stock button translation

by syphilis (Chancellor)
on Mar 08, 2018 at 00:38 UTC ( #1210494=note: print w/replies, xml ) Need Help??


in reply to Gtk stock button translation

Unfortunately, the documentation (or I should say the absence of documentation) has left me clueless

Did you grab the demo program from the page you linked to ?

The relevant part is:
#create a vbox that will contain all the stock buttons my $vbox_stock = Gtk2::VBox->new(FALSE,5); foreach my $val(sort Gtk2::Stock->list_ids){ my $btn_stock = Gtk2::Button->new_from_stock($val); $vbox_stock->pack_start($btn_stock,FALSE,FALSE,4); }
I changed that to:
#create a vbox that will contain all the stock buttons my $vbox_stock = Gtk2::VBox->new(FALSE,5); foreach my $val(sort Gtk2::Stock->list_ids){ print "$val\n"; # List available stock buttons if($val eq 'gtk-add' || $val eq 'gtk-cancel') { my $btn_stock = Gtk2::Button->new_from_stock($val); $vbox_stock->pack_start($btn_stock,FALSE,FALSE,4); } }
On perl-5.26.0, for me that modification behaves as expected and creates only the "Add" and "Cancel" buttons (with labels).
My understanding is that those labels will be written in the language that the computer's locale setting specifies.

Hopefully you can utilise that demo program to help achieve your desired result.
If not, you could try the gtk-perl mailing list if you can't get good help here.

For me, on an older version of perl (5.16.0) the same demo (both original and modified) provided the buttons with labels only (no icons).
Same versions of Gtk and Gtk2 modules. Either a difference in perl itself, or something different in the environments.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Gtk stock button translation
by mtl3 (Novice) on Mar 08, 2018 at 19:07 UTC
    Thank you Rob.

    Yes, the demo "works" on my machine to (also running perl 5.26) in that sense that both icons and labels are displayed. The point of my question was to have the labelled translated (in my case in French). Interestingly, you mention that the translation should happen automatically based on the computer's local settings. If you can confirm that, this would mean that I may need to investigate my gtk install rather than my perl code, which was actually an alternative I had in mind too.

    So could you please confirm that the translation should be triggered automatically via the computer settings (have you observed it)? This would help me moving forward.

    Cheers
      So could you please confirm that the translation should be triggered automatically via the computer settings (have you observed it)?

      I haven't observed it - it's just that, in relation to Gtk2::Stock buttons, the documentation says "the label changes according to your language settings, making internationalization easier".
      However, thinking about that a bit more, it doesn't necessarily mean that changing those labels to French (on your computer) is as easy as changing your computer's language setting to French.
      Having reset your computer's language to French, you might also have to reinstall your gtk libraries and/or rebuild Gtk2. I don't know.

      But I do think the documentation is telling us that, if you run that demo script on a computer whose language setting has always been French, then the labels will be in French.

      More authoritative information can probably be obtained from the gtk-perl mailing list.

      Cheers,
      Rob
        I also spot this sentence in the documentation although I was not 100% sure how to interprete it (i.e. whether the settings were the ones of the computer or shall be programatically defined). Anyway, both my perl and gtk install were done as my computer was set to French and the labels are still displayed in English. I'll check the gtk-perl mailing list as you suggest to help me sort this out. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210494]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2018-07-19 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (411 votes). Check out past polls.

    Notices?