[Geany-devel] Localization of plugin names in plugin manager

Eugene Arshinov earshinov at xxxxx
Sun Sep 6 13:01:01 UTC 2009


On Fri, 4 Sep 2009 12:06:56 +0100
Nick Treleaven wrote:

> On Thu, 03 Sep 2009 22:44:07 +0400
> Eugene Arshinov <earshinov at gmail.com> wrote:
> 
> > > The other question is how to implement this with the
> > > PLUGIN_SET_INFO macro so main_locale_init() is called correctly
> > > (and only when necessary?) for all plugins.
> > >   
> > 
> > Function plugin_set_info() is called exactly once after a plugin is 
> > loaded. Function main_locale_init() should be called at least once
> > (the less calls the better) after a plugin is loaded, as far as I
> > understand what this call does (I had very little experience with
> > gettext). So why not just put a single call into PLUGIN_SET_INFO?
> > 
> > void plugin_set_info(PluginInfo* info) \
> >     { \
> >         main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); \
> 
> But does this work for Geany's core plugins?

Nothing harmless except insignificant slowdown. For core plugins it will just call bindtextdomain and friends once more with same arguments. Of course, it's better to omit main_locale_init() call in core plugins. 

> And it surely wouldn't
> work for plugins with no translation setup (e.g. plugins just starting
> to be developed).

Yes, that's why I called this method limitating. But plugin's author can code plugin_set_info himself, without using PLUGIN_SET_INFO macro, right? Then he is able to call or not to call main_locale_init() there. Or use another ugly hack:

#if defined(LOCALEDIR) && defined(GETTEXT_PACKAGE)
  main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
#endif

> 
> I don't know much about gettext code, what happens after a plugin is
> unloaded? It wouldn't be good if the translations remained in memory.
> Is there a function to call to 'unload' them when a plugin is
> unloaded?
>
> (ATM it's not much of a problem because any plugins not enabled don't
> have their translations loaded).

I could not find such a function. Translations will most likely remain in memory…

By the way, when I was looking for information about how gettext works, I found http://www.gnu.org/software/gettext/manual/gettext.html#Libraries . We should not call setlocale() and textdomain() (through main_locale_init()) in plugins, and use dgettext() there instead of gettext(). No mention of unloading translations there…

> 
> Regards,
> Nick
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel




More information about the Devel mailing list