Re: How to translate text strings of GtkUIManager file.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le Mon, 30 Mar 2009 16:04:05 +0200,
Osmo Maatta <osmoma@xxxxxxxxx> a écrit :

> Hello,
> 
> I have a question about how to get text strings translated when I use 
> GtkUIManager to build a GUI (menu and toolbar).
> 
> This example is from my Gscreendump (screenshot taking...)
> application.
> 
> I have a XML syntax for the GUI in:  
> http://code.google.com/p/gscreendump/source/browse/trunk/src/sd_menu_ui.h
> 
> Then in the c code:
> 
> #include "sd_menu_ui.h"
> 
> static GtkActionEntry open_entries[] =
> {
>   { "FileNewMenuAction", GTK_STOCK_NEW,
>     "_New Capture", ""}, <--- HOW TO GET THIS TRANSLATED?
>    
>   { "FileNewWindowAction", NULL,
>     "_Window", "<control>1",
>     "Take a screenshot of a selected window.", <--- HOW TO GET THIS 
> TRANSLATED etc. ?
>     G_CALLBACK(on_m_new_window_activate_cb)},
> 
>   { "FileNewSelectionAction", NULL,
>     "_Selection", "<control>2",
>     "Take a screenshot of a selected area of the desktop.",
>     G_CALLBACK(on_m_new_select_activate_cb)},
> 
>   { "FileNewDesktopAction", NULL,
>     "_Desktop", "<control>3",
>     "Take a screenshot of the entire desktop.",
>     G_CALLBACK(on_m_new_desktop_activate_cb)},
> 
>    ...
> };
> 
> 
> /* Then load the UI for menu and toolbar */
> GError *error = NULL;
> gtk_ui_manager_add_ui_from_string(g_ui_manager, ui_xml, -1, &error);
> ...
> 
> ---------------------------
> 
> All strings of the the c-code are automatically collected because 
> strings are confined by translation macro  _("some text"). But I
> cannot use _("xxxx") in the GtkActionEntry entries (e.g
> open_entries[] list).

Yes, you have to use N_() which marks the string as translatable, but
doesn't return the translated string. You will then have to use
_(open_entries->label) to print manually the translated string, or not
if this may be done automatically.

See the GLib Utilities -> Internationalization entry of the GLib
reference manual.

Mike

> So do you know how to automatically collect and output strings from
> all the GtkActionEntry lists to ./po/gscreendump.pot file.
> The .pot is the message/text file that already contains all strings
> from _("xxxxx"). It is then translated to other languages.
> 
> But my problem is the text strings in all GtkActionEntry structures.
> ---------------------------
> 
> I have added gtk_action_group_set_translation_domain() lines to my
> code, but I cannot see how it works.
> 
> GtkActionGroup *open_action_group = 
> gtk_action_group_new("AlwaysOpenActions");
> gtk_action_group_add_actions(open_action_group, open_entries, 
> n_open_entries, NULL);
> gtk_ui_manager_insert_action_group(g_ui_manager, open_action_group,
> 0); gtk_action_group_set_translation_domain(open_action_group,
> GETTEXT_PACKAGE); -----------------------------
> 
> Sorry for possibly bad explanation, but this is my reality now.
> 
> The entire Gscreendump code is available from: 
> http://code.google.com/p/gscreendump (study the amazing pictures ;-)
> And the latest source code:  
> http://code.google.com/p/gscreendump/source/browse/#svn/trunk/src/
> ----------------------------
> 
> 
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux