Re: simple internalisation



Am 12.01.2010 14:31, schrieb Pavel A. da Mek:
For example, having "File" stock item doesn't make much
sense, since files usually carry their own name and this is what
should be displayed.

Most programs have the "File" menu item in the tool bar.
To create menu items from stock items is a simple way to present
translated labels for all languages supported by gtk at least for the
frquently used items,  without need to manage translations to all those
languages for the application.

What I am doing is this:

GtkWidget* menu_item_new_from_stock (const gchar *stock_id) {
GtkStockItem item;

if (gtk_stock_lookup (stock_id, &item)) {
 return gtk_menu_item_new_with_mnemonic (item.label);
}
return gtk_menu_item_new_with_mnemonic (stock_id);
}

...
// *** menu items in menu bar
editMBMenuItem = menu_item_new_from_stock (GTK_STOCK_EDIT);
preferencesMBMenuItem = menu_item_new_from_stock (GTK_STOCK_PREFERENCES);
helpMBMenuItem = menu_item_new_from_stock (GTK_STOCK_HELP);
...

People usualy don'T use stockitems for the menubar, just for the menu items. I
never saw a app with icons in the menu bar. The whole stock business is kind of
obsolete anyway, as the the images are not shown anymore by default in latest
gnome :/

Stefan


But because this does not work for GTK_STOCK_FILE,
I am using this:

#include <libintl.h>
#define T_(String) dgettext ("gtk20", String)
...
fileMBMenuItem = gtk_menu_item_new_with_mnemonic (T_("_Files"));
...

Other frequently used words are available too, for example

searchMBMenuItem = gtk_menu_item_new_with_mnemonic (T_("Search"));

Some other words are translated for gtk properties and for glib,
so I am using also this:

#define L_(String) dgettext ("glib20", String)
#define P_(String) dgettext ("gtk20-properties", String)

for example:

settingsMBMenuItem = gtk_menu_item_new_with_mnemonic (P_("Settings"));

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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