From: Takao Fujiwara Date: Sun, 7 Sep 2008 05:54:20 +0000 (+1000) Subject: Add localization support to avahi-ui and avahi-discover X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=4e0e2fd598d2d155a55e58b024de5b58592bec0e;p=catta Add localization support to avahi-ui and avahi-discover Closes #122 Signed-off-by: Ted Percival Signed-off-by: Lennart Poettering --- diff --git a/avahi-python/avahi-discover/Makefile.am b/avahi-python/avahi-discover/Makefile.am index c1d6cab..e9c5583 100644 --- a/avahi-python/avahi-discover/Makefile.am +++ b/avahi-python/avahi-discover/Makefile.am @@ -23,7 +23,7 @@ EXTRA_DIST = \ __init__.py \ SimpleGladeApp.py \ avahi-discover.in \ - avahi-discover.desktop.in + avahi-discover.desktop.in.in if HAVE_PYTHON if HAVE_PYTHON_DBUS @@ -41,6 +41,7 @@ if HAVE_GDBM pythonscripts += \ avahi-discover desktop_DATA += avahi-discover.desktop +@INTLTOOL_DESKTOP_RULE@ avahi_discover_PYTHON += __init__.py SimpleGladeApp.py endif @@ -48,14 +49,17 @@ if HAVE_DBM pythonscripts += \ avahi-discover desktop_DATA += avahi-discover.desktop +@INTLTOOL_DESKTOP_RULE@ avahi_discover_PYTHON += __init__.py SimpleGladeApp.py endif -avahi-discover.desktop: avahi-discover.desktop.in +avahi-discover.desktop.in: avahi-discover.desktop.in.in sed -e 's,@bindir\@,$(bindir),g' $< > $@ avahi-discover: avahi-discover.in sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@GETTEXT_PACKAGE\@,"$(GETTEXT_PACKAGE)",g' \ + -e 's,@LOCALEDIR\@,"$(datadir)/locale",g' \ -e 's,@interfacesdir\@,$(interfacesdir),g' $< > $@ chmod +x $@ diff --git a/avahi-python/avahi-discover/avahi-discover.desktop.in b/avahi-python/avahi-discover/avahi-discover.desktop.in deleted file mode 100644 index e896192..0000000 --- a/avahi-python/avahi-discover/avahi-discover.desktop.in +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Version=1.0 -Encoding=UTF-8 -Name=Avahi Zeroconf Browser -Comment=Browse for Zeroconf services available on your network -Exec=@bindir@/avahi-discover -Terminal=false -Type=Application -Icon=network-wired -Categories=GNOME;Application;System; -StartupNotify=false -GenericName= diff --git a/avahi-python/avahi-discover/avahi-discover.desktop.in.in b/avahi-python/avahi-discover/avahi-discover.desktop.in.in new file mode 100644 index 0000000..031024c --- /dev/null +++ b/avahi-python/avahi-discover/avahi-discover.desktop.in.in @@ -0,0 +1,12 @@ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +_Name=Avahi Zeroconf Browser +_Comment=Browse for Zeroconf services available on your network +Exec=@bindir@/avahi-discover +Terminal=false +Type=Application +Icon=network-wired +Categories=GNOME;Application;System; +StartupNotify=false +GenericName= diff --git a/avahi-python/avahi-discover/avahi-discover.in b/avahi-python/avahi-discover/avahi-discover.in index be8c08b..0558424 100755 --- a/avahi-python/avahi-discover/avahi-discover.in +++ b/avahi-python/avahi-discover/avahi-discover.in @@ -22,8 +22,11 @@ import os, sys try: - import avahi, gtk, gobject, dbus, avahi.ServiceTypeDatabase + import avahi, gettext, gtk, gobject, dbus, avahi.ServiceTypeDatabase from avahi_discover.SimpleGladeApp import SimpleGladeApp + gtk.glade.bindtextdomain(@GETTEXT_PACKAGE@, @LOCALEDIR@) + gtk.glade.textdomain(@GETTEXT_PACKAGE@) + _ = gettext.gettext except ImportError, e: print "Sorry, to use this tool you need to install Avahi, pygtk and python-dbus.\n Error: %s" % e sys.exit(1) diff --git a/avahi-ui/Makefile.am b/avahi-ui/Makefile.am index 910dc6b..6dbbd24 100644 --- a/avahi-ui/Makefile.am +++ b/avahi-ui/Makefile.am @@ -29,8 +29,8 @@ desktop_DATA_in_in = bssh.desktop.in.in bvnc.desktop.in.in EXTRA_DIST = $(desktop_DATA_in_in) - if HAVE_GTK +AM_CFLAGS += -DGNOMELOCALEDIR=\"$(datadir)/locale\" if HAVE_DBUS if HAVE_GLIB @@ -61,6 +61,7 @@ endif bin_PROGRAMS = bssh desktop_DATA += bssh.desktop bvnc.desktop +@INTLTOOL_DESKTOP_RULE@ bssh_SOURCES = bssh.c bssh_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS) diff --git a/avahi-ui/avahi-ui.c b/avahi-ui/avahi-ui.c index a54cbe9..bd2b3cc 100644 --- a/avahi-ui/avahi-ui.c +++ b/avahi-ui/avahi-ui.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -184,64 +185,64 @@ static void aui_service_dialog_class_init(AuiServiceDialogClass *klass) { g_object_class_install_property( object_class, PROP_BROWSE_SERVICE_TYPES, - g_param_spec_pointer("browse_service_types", "Browse Service Types", "A NULL terminated list of service types to browse for", + g_param_spec_pointer("browse_service_types", _("Browse Service Types"), _("A NULL terminated list of service types to browse for"), G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property( object_class, PROP_DOMAIN, - g_param_spec_string("domain", "Domain", "The domain to browse in, or NULL for the default domain", + g_param_spec_string("domain", _("Domain"), _("The domain to browse in, or NULL for the default domain"), NULL, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property( object_class, PROP_SERVICE_TYPE, - g_param_spec_string("service_type", "Service Type", "The service type of the selected service", + g_param_spec_string("service_type", _("Service Type"), _("The service type of the selected service"), NULL, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property( object_class, PROP_SERVICE_NAME, - g_param_spec_string("service_name", "Service Name", "The service name of the selected service", + g_param_spec_string("service_name", _("Service Name"), _("The service name of the selected service"), NULL, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property( object_class, PROP_ADDRESS, - g_param_spec_pointer("address", "Address", "The address of the resolved service", + g_param_spec_pointer("address", _("Address"), _("The address of the resolved service"), G_PARAM_READABLE)); g_object_class_install_property( object_class, PROP_PORT, - g_param_spec_uint("port", "Port", "The IP port number of the resolved service", + g_param_spec_uint("port", _("Port"), _("The IP port number of the resolved service"), 0, 0xFFFF, 0, G_PARAM_READABLE)); g_object_class_install_property( object_class, PROP_HOST_NAME, - g_param_spec_string("host_name", "Host Name", "The host name of the resolved service", + g_param_spec_string("host_name", _("Host Name"), _("The host name of the resolved service"), NULL, G_PARAM_READABLE)); g_object_class_install_property( object_class, PROP_TXT_DATA, - g_param_spec_pointer("txt_data", "TXT Data", "The TXT data of the resolved service", + g_param_spec_pointer("txt_data", _("TXT Data"), _("The TXT data of the resolved service"), G_PARAM_READABLE)); g_object_class_install_property( object_class, PROP_RESOLVE_SERVICE, - g_param_spec_boolean("resolve_service", "Resolve service", "Resolve service", + g_param_spec_boolean("resolve_service", _("Resolve service"), _("Resolve service"), TRUE, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property( object_class, PROP_RESOLVE_HOST_NAME, - g_param_spec_boolean("resolve_host_name", "Resolve service host name", "Resolve service host name", + g_param_spec_boolean("resolve_host_name", _("Resolve service host name"), _("Resolve service host name"), TRUE, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property( object_class, PROP_ADDRESS_FAMILY, - g_param_spec_int("address_family", "Address family", "The address family for host name resolution", + g_param_spec_int("address_family", _("Address family"), _("The address family for host name resolution"), AVAHI_PROTO_UNSPEC, AVAHI_PROTO_INET6, AVAHI_PROTO_UNSPEC, G_PARAM_READABLE | G_PARAM_WRITABLE)); } @@ -703,7 +704,7 @@ static gboolean start_callback(gpointer data) { d->priv->start_idle = 0; if (!d->priv->browse_service_types || !*d->priv->browse_service_types) { - g_warning("Browse service type list is empty!"); + g_warning(_("Browse service type list is empty!")); return FALSE; } @@ -1026,7 +1027,7 @@ static void domain_button_clicked(GtkButton *button G_GNUC_UNUSED, gpointer user gtk_container_add(GTK_CONTAINER(scrolled_window), p->domain_tree_view); p->domain_progress_bar = gtk_progress_bar_new(); - gtk_progress_bar_set_text(GTK_PROGRESS_BAR(p->domain_progress_bar), _("Browsing ...")); + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(p->domain_progress_bar), _("Browsing...")); gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(p->domain_progress_bar), 0.1); gtk_box_pack_end(GTK_BOX(vbox2), p->domain_progress_bar, FALSE, FALSE, 0); @@ -1139,17 +1140,17 @@ static void aui_service_dialog_init(AuiServiceDialog *d) { g_signal_connect(selection, "changed", G_CALLBACK(service_selection_changed_callback), d); renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes("Location", renderer, "text", SERVICE_COLUMN_PRETTY_IFACE, NULL); + column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", SERVICE_COLUMN_PRETTY_IFACE, NULL); gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_append_column(GTK_TREE_VIEW(p->service_tree_view), column); renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", SERVICE_COLUMN_NAME, NULL); + column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "text", SERVICE_COLUMN_NAME, NULL); gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(p->service_tree_view), column); renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes("Type", renderer, "text", SERVICE_COLUMN_PRETTY_TYPE, NULL); + column = gtk_tree_view_column_new_with_attributes(_("Type"), renderer, "text", SERVICE_COLUMN_PRETTY_TYPE, NULL); gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_append_column(GTK_TREE_VIEW(p->service_tree_view), column); @@ -1157,7 +1158,7 @@ static void aui_service_dialog_init(AuiServiceDialog *d) { gtk_container_add(GTK_CONTAINER(scrolled_window), p->service_tree_view); p->service_progress_bar = gtk_progress_bar_new(); - gtk_progress_bar_set_text(GTK_PROGRESS_BAR(p->service_progress_bar), _("Browsing ...")); + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(p->service_progress_bar), _("Browsing...")); gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(p->service_progress_bar), 0.1); gtk_box_pack_end(GTK_BOX(vbox2), p->service_progress_bar, FALSE, FALSE, 0); diff --git a/avahi-ui/bssh.c b/avahi-ui/bssh.c index fea1071..e4a190b 100644 --- a/avahi-ui/bssh.c +++ b/avahi-ui/bssh.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -135,6 +136,10 @@ int main(int argc, char*argv[]) { return 1; } + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + gtk_init(&argc, &argv); switch (config.command) { diff --git a/po/POTFILES.in b/po/POTFILES.in index 80b5a29..f3e48de 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,7 @@ # List of source files which contain translatable strings. avahi-common/error.c +avahi-discover-standalone/avahi-discover.glade +avahi-python/avahi-discover/avahi-discover.desktop.in.in avahi-ui/avahi-ui.c avahi-ui/bssh.c avahi-ui/bssh.desktop.in.in @@ -8,4 +10,3 @@ avahi-utils/avahi-browse.c avahi-utils/avahi-publish.c avahi-utils/avahi-resolve.c avahi-utils/avahi-set-host-name.c -