Menu

#503 add optional gettext_package to plugin descriptor for plugin i18n

-
closed-accepted
None
5
2016-10-24
2015-01-30
Hanno Zulla
No

Hi there,

this is a patch against the lxpanel-0.8.0.tar.xz tarball.

This patch allows plugin developers to define an optional value for GETTEXT_PACKAGE in the LXPanelPluginInit struct.

Why is this useful?

This makes it possible to package plugin binaries and their gettext translations outside of the lxpanel distribution package.

See discussion in [1].

What is the problem being solved?

Currently, the plugin "name" and "description" are translated through gettext _() calls from within lxpanel itself.

The unwanted side effect is that the gettext call will then use the GETTEXT_PACKAGE "lxpanel" and look for translated strings in /usr/share/locale/<LOCALE>/LC_MESSAGES/lxpanel.mo

This requires all translations to reside in lxpanel.po. Or in other words, only lxpanel plugins that are part of the lxpanel tarball can offer translated messages.

Attached is a modified example plugin, based on [2].

Note that it doesn't use gi18n.h as described in [2], but

#define GETTEXT_PACKAGE "lxpanel-testplugin"
#include <glib/gi18n-lib.h>

instead and then finally sets the corresponding value in the plugin descriptor:

/* Plugin descriptor. */
LXPanelPluginInit fm_module_init_lxpanel_gtk = {
    .name = N_("TestPlugin"),
    .description = N_("Run a test plugin."),
    .gettext_package = GETTEXT_PACKAGE,
    .new_instance = test_constructor
};

As a result, if this variable is set, all gettext calls in lxpanel will use this gettext package and translation strings are being found.

[1] http://sourceforge.net/p/lxde/mailman/lxde-i18n/thread/54CA35AD.5000600%40hanno.de/

[2] http://wiki.lxde.org/en/How_to_write_plugins_for_LXPanel

1 Attachments

Discussion

  • Hanno Zulla

    Hanno Zulla - 2015-02-11

    Bump.

    Requesting a brief review of / an opinion about this patch.

    Thanks!

     
  • Lonely Stranger

    Lonely Stranger - 2016-03-17
    • status: open --> open-accepted
    • assigned_to: Lonely Stranger
     
  • Lonely Stranger

    Lonely Stranger - 2016-03-17

    Thank you very much. Accepted your patch into LXPanel sources, with some changes, that were required.

     
  • Lonely Stranger

    Lonely Stranger - 2016-10-24
    • status: open-accepted --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.