Re: I18n in plugin

Hi Federico and Jean,

Thanks you very much. I've tried the gi18n-lib.h trick in the anjuta
plugin, and it rocks. :)

在 2006-05-22一的 12:17 -0500,Federico Mena Quintero写道:
> On Mon, 2006-05-22 at 14:06 +0800, Yang Hong wrote:
> > There are many applications use plugin based architecture to expand it's
> > function, such as Evolution (EPlugin), Anjuta 2.x, Gedit, Gaim,
> > Xchat-gnome, etc. The problem is that if the plugins was released
> > outside of the main app, the user interface of the plugin is NOT I18n
> > able. even I added bindtextdomain(...) and bind_textdomain_codeset (...)
> > in the initialize code of the plugin.
> Plugins which are loaded in the same address space as the main process
> need to use bindtextdomain() and dgettext() instead of the plain
> textdomain() and gettext().
> bindtextdomain("my_plugin", "/usr/share/locale/myplugin/")
> dgettext ("my_plugin", "string to translate")
> This is so that the gettext machinery will know that your strings don't
> come from the domain of the main program, but from your plugin's own
> domain.
> If you #include <glib/gi18n-lib.h>, you'll get
> 	#define _(x) dgettext(GETTEXT_PACKAGE, x)
> which makes it easy to use dgettext() automatically.  Note that you of
> course have to define GETTEXT_PACKAGE elsewhere, probably in your
> Makefile:
> > Yestoday, I got a remove-duplicates plugin for evolution 2.4 from
> > #342378 [2], after some hack it for evolution 2.6, added LINGUAS suport,
> > added zh_CN translate [3], intalled it and got a untranslate menu item
> > "Remove duplicates". and then I found that there is even not point to
> > add the bindtextdomain for it, there's only one entrance for this
> > plugin's functional. how can it could be i18ned?
> I don't know about that bug, but keep the following in mind.
> Some plug-in APIs let you pass strings to the main program, and then the
> main program will call gettext() on them.  *This is wrong*, because
> gettext() will assume the domain of the program, while you almost
> certainly want the domain of your own plugin.
> In this case, the API needs to be changed to let you pass a domain along
> with the strings, or something like that:
>   plugin_handle = plugin_register (plugin_name, domain_for_plugin);
>   /* Uses domain_for_plugin (stored in plugin_handle)
>    * when calling dgettext() */
>   plugin_add_menu_item (plugin_handle, "Interesting command");
> Good luck,
>   Federico

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