Re: Internationalizing a simple Gnome Panel Applet .........? the solution



Christophe Combelles a écrit :

I could easily i12ize a simple GTK hello world application,
but I can't do the same for a panel applet.



OK, autoconf gave me the hint : I just forgot -DENABLE_NLS

So I summarize the minimum internationalized hello world gnome panel
applet:
=====================================================
ExampleApplet.c:
=====================================================
#include <string.h>
#include <panel-applet.h>
#include <gtk/gtklabel.h>

#define GETTEXT_PACKAGE "ExampleApplet"
#define GNOMELOCALEDIR "/usr/share/locale"

static gboolean
myexample_applet_fill (PanelApplet * applet, const gchar * iid,
gpointer data)
{
  GtkWidget *label;

  if (strcmp (iid, "OAFIID:ExampleApplet") != 0)
    return FALSE;

  label = gtk_label_new (_("Hello"));
  gtk_container_add (GTK_CONTAINER (applet), label);

  gtk_widget_show_all (GTK_WIDGET (applet));

  return TRUE;
}

PANEL_APPLET_BONOBO_FACTORY ("OAFIID:ExampleApplet_Factory",
                             PANEL_TYPE_APPLET,
                             "ExampleApplet",
                             "0", myexample_applet_fill, NULL);
=====================================================
ExampleApplet.server:
=====================================================
<oaf_info>
<oaf_server iid="OAFIID:ExampleApplet_Factory" type="exe"
            location="/usr/lib/gnome-panel/ExampleApplet">

        <oaf_attribute name="repo_ids" type="stringv">
                <item value="IDL:Bonobo/GenericFactory:1.0"/>
                <item value="IDL:Bonobo/Unknown:1.0"/>
        </oaf_attribute>
        <oaf_attribute name="name" type="string" value="Example Applet
Factory"/>
        <oaf_attribute name="description" type="string" value="Factory
to create the example applet"/>
</oaf_server>

<oaf_server iid="OAFIID:ExampleApplet" type="factory"
            location="OAFIID:ExampleApplet_Factory">

        <oaf_attribute name="repo_ids" type="stringv">
                <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
                <item value="IDL:Bonobo/Control:1.0"/>
                <item value="IDL:Bonobo/Unknown:1.0"/>
        </oaf_attribute>
        <oaf_attribute name="name" type="string" value="Example Applet"/>
        <oaf_attribute name="description" type="string" value="An
example applet"/>
        <oaf_attribute name="panel:category" type="string"
value="Amusements"/>
        <oaf_attribute name="panel:icon" type="string"
value="myicon.png"/>
</oaf_server>
</oaf_info>
==========================================================


Then to compile and create the mo file:

xgettext --keyword=_ ExampleApplet.c -o ExampleApplet.pot
msginit -l fr_FR -i ExampleApplet.pot -o ExampleApplet.po
vi ExampleApplet.po     (then translate "Hello")
msgfmt -c -v ExampleApplet.po -o ExampleApplet.mo
cp -f ExampleApplet.mo /usr/share/locale/fr/LC_MESSAGES/

gcc $(pkg-config --cflags --libs libpanelapplet-2.0) \
      -DENABLE_NLS -o ExampleApplet ExampleApplet.c

cp -f ExampleApplet /usr/lib/gnome-panel/
cp -f ExampleApplet.server /usr/lib/bonobo/servers/







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