simple internalisation (was: Nobody ever used GTK_STOCK_FILE?)



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);
...

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"));




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