Hi Nick.
Nick Treleaven wrote:
On Thu, 03 Sep 2009 12:10:21 +0400 Eugene Arshinov earshinov@gmail.com wrote:
The trouble: in plugin manager plugin name (and also its description) is not localized until plugin is activated. The cause (probably): main_locale_init(LOCALEDIR, GETTEXT_PACKAGE) is called only in plugin_init(), and plugin_set_info() is obviously called before that.
...
I see two ways to fix this problem. The first way is very ugly and limitating: just call main_locale_init() from plugin_set_info(), and recompile all plugins. The second way is to add new function to be implemented in plugins (say, "plugin_loaded") and call that before anything else (particularly, before plugin_set_info()).
So, the question is how to solve this problem.
I would prefer calling main_locale_init() from plugin_set_info(), but would that have much of a performance impact for the plugin manager dialog? I guess it's probably necessary though.
It's hard to guess for me whether the slowdown would be large. I tried to measure execution time of main_locale_init() in addons plugin, but it returned 0 msec...
clock_t t = clock(); main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); g_debug("Function main_locale_init() took %f msec.", (double)(clock() - t) * 1000 / CLOCKS_PER_SEC);
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); \ info->name = (p_name); \ info->description = (p_description); \ info->version = (p_version); \ info->author = (p_author); \ }
Best regards, Eugene.