Hi all.
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 discovered that when using geany-plugins and Russian localization. I looked for any mentions of this problem in bug tracker and mailing list, but did not find anything.
This does not happen with plugins supplied with Geany (i.e., shift column plugin). I think, the reason is that their GETTEXT_PACKAGE is the same as the one of geany itself, and geany performs necessary gettext initialization in its main().
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.
Best regards, Eugene.
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.
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.
Regards, Nick
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.
On Thu, 03 Sep 2009 22:44:07 +0400 Eugene Arshinov earshinov@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? And it surely wouldn't work for plugins with no translation setup (e.g. plugins just starting to be developed).
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).
Regards, Nick
On Fri, 4 Sep 2009 12:06:56 +0100, Nick wrote:
On Thu, 03 Sep 2009 22:44:07 +0400 Eugene Arshinov earshinov@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? And it surely wouldn't work for plugins with no translation setup (e.g. plugins just starting to be developed).
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?
I'm not sure all this is necessary. I spent quite some time on this issue when we started implementing the plugin manager dialog and this issue came up the first time. I didn't find an easy solution at the that time. Then I or we (don't remember exactly but we talked about it) decided that it is not such an important issue and just left it out. It's all about only the description and the author field of the plugins in the plugin manager dialog. I personally just don't care so much about these little information. And it all works once the plugin is loaded.
Regards, Enrico
В Sun, 6 Sep 2009 14:41:35 +0200 Enrico Tröger enrico.troeger@uvena.de пишет:
On Fri, 4 Sep 2009 12:06:56 +0100, Nick wrote:
On Thu, 03 Sep 2009 22:44:07 +0400 Eugene Arshinov earshinov@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? And it surely wouldn't work for plugins with no translation setup (e.g. plugins just starting to be developed).
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?
I'm not sure all this is necessary. I spent quite some time on this issue when we started implementing the plugin manager dialog and this issue came up the first time. I didn't find an easy solution at the that time. Then I or we (don't remember exactly but we talked about it) decided that it is not such an important issue and just left it out. It's all about only the description and the author field of the plugins in the plugin manager dialog. I personally just don't care so much about these little information. And it all works once the plugin is loaded.
Great, I won't care of it then :-) Thanks for explanation.
Just to say, I discovered this issue when debugging modified addons plugin. I wondered why it disappeared from the list after I activated and deactivated it. After an hour of thinking and debugging I noticed that its name was localized and it moved to the end of plugin list :-)
Regards, Enrico
On Sun, 6 Sep 2009 17:34:41 +0400, Eugene wrote:
В Sun, 6 Sep 2009 14:41:35 +0200 Enrico Tröger enrico.troeger@uvena.de пишет:
On Fri, 4 Sep 2009 12:06:56 +0100, Nick wrote:
On Thu, 03 Sep 2009 22:44:07 +0400 Eugene Arshinov earshinov@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? And it surely wouldn't work for plugins with no translation setup (e.g. plugins just starting to be developed).
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?
I'm not sure all this is necessary. I spent quite some time on this issue when we started implementing the plugin manager dialog and this issue came up the first time. I didn't find an easy solution at the that time. Then I or we (don't remember exactly but we talked about it) decided that it is not such an important issue and just left it out. It's all about only the description and the author field of the plugins in the plugin manager dialog. I personally just don't care so much about these little information. And it all works once the plugin is loaded.
Great, I won't care of it then :-) Thanks for explanation.
Just to say, I discovered this issue when debugging modified addons plugin. I wondered why it disappeared from the list after I activated and deactivated it. After an hour of thinking and debugging I noticed that its name was localized and it moved to the end of plugin list :-)
Ok, in the case that the plugin name is that different in the translation, it might be weird. Not sure whether this should be considered a bug in the translation or in Geany (as we are talking about his). The easiest thing would be to argument that the plugin name shouldn't be translated as it is a name. On the hand, some plugin names are more like descriptions than real, plain names and so translating them makes sense. But this is just the easy was, not necessarily the correct one :).
Regards, Enrico
Hi,
If you can access the untranslated name why not sort on that and show the translated name, then things won't move.
Cheers Lex
2009/9/6 Enrico Tröger enrico.troeger@uvena.de:
On Sun, 6 Sep 2009 17:34:41 +0400, Eugene wrote:
В Sun, 6 Sep 2009 14:41:35 +0200 Enrico Tröger enrico.troeger@uvena.de пишет:
On Fri, 4 Sep 2009 12:06:56 +0100, Nick wrote:
On Thu, 03 Sep 2009 22:44:07 +0400 Eugene Arshinov earshinov@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? And it surely wouldn't work for plugins with no translation setup (e.g. plugins just starting to be developed).
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?
I'm not sure all this is necessary. I spent quite some time on this issue when we started implementing the plugin manager dialog and this issue came up the first time. I didn't find an easy solution at the that time. Then I or we (don't remember exactly but we talked about it) decided that it is not such an important issue and just left it out. It's all about only the description and the author field of the plugins in the plugin manager dialog. I personally just don't care so much about these little information. And it all works once the plugin is loaded.
Great, I won't care of it then :-) Thanks for explanation.
Just to say, I discovered this issue when debugging modified addons plugin. I wondered why it disappeared from the list after I activated and deactivated it. After an hour of thinking and debugging I noticed that its name was localized and it moved to the end of plugin list :-)
Ok, in the case that the plugin name is that different in the translation, it might be weird. Not sure whether this should be considered a bug in the translation or in Geany (as we are talking about his). The easiest thing would be to argument that the plugin name shouldn't be translated as it is a name. On the hand, some plugin names are more like descriptions than real, plain names and so translating them makes sense. But this is just the easy was, not necessarily the correct one :).
Regards, Enrico
-- Get my GPG key from http://www.uvena.de/pub.asc
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Mon, 7 Sep 2009 07:58:18 +1000, Lex wrote:
Hi,
If you can access the untranslated name why not sort on that and show the translated name, then things won't move.
This could be at least a workaround. I don't know by heart whether we can access the untranslated string but maybe with a little trick it might be possible. Though, I doubt I have time to look into this during the next two weeks, so if anyone wants to go for it or for a real solution like Eugene suggested earlier (which I kind of rejected but now that I realise there is indeed some kind of problem...) that would be appreciated.
Regards, Enrico
On Sun, 6 Sep 2009 15:49:03 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
Just to say, I discovered this issue when debugging modified addons plugin. I wondered why it disappeared from the list after I activated and deactivated it. After an hour of thinking and debugging I noticed that its name was localized and it moved to the end of plugin list :-)
Ok, in the case that the plugin name is that different in the translation, it might be weird. Not sure whether this should be considered a bug in the translation or in Geany (as we are talking about his). The easiest thing would be to argument that the plugin name shouldn't be translated as it is a name. On the hand, some plugin names are more like descriptions than real, plain names and so translating them makes sense. But this is just the easy was, not necessarily the correct one :).
Well, then the description also would not be translated. It would be best to translate name and description, but I'm not happy that just by showing the plugin manager every translated string then stays in memory until Geany is quit, for every single plugin on the system. Some plugins like geanylua have a lot of translated strings (probably too many).
Anyway, this may be the best overall solution. Perhaps I'm worrying about memory use too much, I don't have any figures on the actual number of KiB used.
Regards, Nick
On Fri, 4 Sep 2009 12:06:56 +0100 Nick Treleaven wrote:
On Thu, 03 Sep 2009 22:44:07 +0400 Eugene Arshinov earshinov@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@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel