* maybe use network-idle -> network-transmit ->
* network-receive -> network-transmit-receive */
+#include <locale.h>
#include <stdlib.h>
#include <string.h>
showip = TRUE;
showssid = FALSE;
if (if_up(ifm))
- reason = "Acquired address";
+ reason = N_("Acquired address");
else {
if (g_strcmp0(ifm->reason, "EXPIRE") == 0)
- reason = "Failed to renew";
+ reason = N_("Failed to renew");
else if (g_strcmp0(ifm->reason, "CARRIER") == 0) {
if (ifm->wireless) {
- reason = "Asssociated with";
+ reason = N_("Asssociated with");
if (ifm->ssid != NULL)
showssid = TRUE;
} else
- reason = "Cable plugged in";
+ reason = N_("Cable plugged in");
showip = FALSE;
} else if (g_strcmp0(ifm->reason, "NOCARRIER") == 0) {
if (ifm->wireless) {
if (ifm->ssid != NULL || ifm->ip.s_addr != 0) {
- reason = "Lost association with";
+ reason = N_("Lost association with");
showssid = TRUE;
} else
- reason = "Not associated";
+ reason = N_("Not associated");
} else
- reason = "Cable unplugged";
+ reason = N_("Cable unplugged");
showip = FALSE;
}
}
msg = print_if_msg(ifm);
title = NULL;
if (if_up(ifm))
- act = "Connected to ";
+ act = N_("Connected to ");
else
act = NULL;
for (r = down_reasons; *r; r++) {
if (g_strcmp0(*r, ifm->reason) == 0) {
- act = "Disconnected from ";
+ act = N_("Disconnected from ");
break;
}
}
if (act && ifm->ip.s_addr) {
ipn = htonl(ifm->ip.s_addr);
if (IN_LINKLOCAL(ipn))
- net = "private network";
+ net = N_("private network");
else if (IN_PRIVATE(ipn))
- net = "LAN";
+ net = N_("LAN");
else
- net = "internet";
+ net = N_("internet");
title = g_strconcat(act, net, NULL);
}
g_list_free(interfaces);
interfaces = NULL;
update_online(NULL);
- msg = last? "Connection to dhcpcd lost" : "dhcpcd not running";
+ msg = N_(last? "Connection to dhcpcd lost" : "dhcpcd not running");
gtk_status_icon_set_tooltip(status_icon, msg);
- notify("No network", msg, GTK_STOCK_NETWORK);
+ notify(_("No network"), msg, GTK_STOCK_NETWORK);
}
refresh = FALSE;
if (!dbus_g_proxy_call(dbus, "GetDhcpcdVersion", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &version, G_TYPE_INVALID))
- error_exit("GetDhcpcdVersion", error);
- g_message("Connected to dhcpcd-%s", version);
+ error_exit(_("GetDhcpcdVersion"), error);
+ g_message(_("Connected to %s-%s"), "dhcpcd", version);
g_free(version);
dhcpcd_get_interfaces();
}
char *version = NULL;
GType otype;
int tries = 5;
-
+
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, NULL);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+ textdomain(PACKAGE);
+
gtk_init(&argc, &argv);
g_set_application_name("dhcpcd Monitor");
status_icon = gtk_status_icon_new_from_icon_name("network-offline");
if (status_icon == NULL)
status_icon = gtk_status_icon_new_from_stock(GTK_STOCK_DISCONNECT);
- gtk_status_icon_set_tooltip(status_icon, "Connecting to dhcpcd ...");
+ gtk_status_icon_set_tooltip(status_icon, _("Connecting to dhcpcd ..."));
gtk_status_icon_set_visible(status_icon, TRUE);
notify_init(PACKAGE);
- g_message("Connecting to dbus ...");
+ g_message(_("Connecting to dbus ..."));
bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (bus == NULL || error != NULL)
- error_exit("Could not connect to system bus", error);
+ error_exit(_("Could not connect to system bus"), error);
dbus = dbus_g_proxy_new_for_name(bus,
DHCPCD_SERVICE,
DHCPCD_PATH,
DHCPCD_SERVICE);
- g_message("Connecting to dhcpcd-dbus ...");
+ g_message(_("Connecting to dhcpcd-dbus ..."));
while (--tries > 0) {
g_clear_error(&error);
if (dbus_g_proxy_call_with_timeout(dbus,
break;
}
if (tries == 0)
- error_exit("GetVersion", error);
- g_message("Connected to dhcpcd-dbus-%s", version);
+ error_exit(_("GetVersion"), error);
+ g_message(_("Connected to %s-%s"), "dhcpcd-dbus", version);
g_free(version);
- gtk_status_icon_set_tooltip(status_icon, "Triggering dhcpcd ...");
+ gtk_status_icon_set_tooltip(status_icon, _("Triggering dhcpcd ..."));
online = FALSE;
menu_init(status_icon);
if (!dbus_g_proxy_call(dbus, "GetStatus", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &version, G_TYPE_INVALID))
- error_exit("GetStatus", error);
+ error_exit(_("GetStatus"), error);
check_status(version);
g_free(version);
"Roy Marples <roy@marples.name>",
NULL
};
-static const char *license =
- "Licensed under the 2 clause BSD license.\n"
- "\n"
+static const char *license[] = {
+ "Licensed under the 2 clause BSD license.\n",
"Redistribution and use in source and binary forms, with or without\n"
"modification, are permitted provided that the following conditions\n"
- "are met:\n"
+ "are met:\n",
"1. Redistributions of source code must retain the above copyright\n"
- " notice, this list of conditions and the following disclaimer.\n"
+ " notice, this list of conditions and the following disclaimer.\n",
"2. Redistributions in binary form must reproduce the above copyright\n"
" notice, this list of conditions and the following disclaimer in the\n"
- " documentation and/or other materials provided with the distribution.\n"
- "\n"
+ " documentation and/or other materials provided with the distribution.\n",
"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n"
"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n"
"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n"
"HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n"
"LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n"
"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"
- "SUCH DAMAGE.";
+ "SUCH DAMAGE.",
+ NULL
+};
static void
on_quit(_unused GtkMenuItem *item, _unused gpointer data)
static void
on_about(_unused GtkMenuItem *item, _unused gpointer data)
{
+ char *l;
+
+ l = g_strconcat(_(license[0]), "\n",
+ _(license[1]), "\n",
+ _(license[2]), "\n",
+ _(license[3]), "\n",
+ _(license[4]), "\n",
+ NULL);
gtk_window_set_default_icon_name(GTK_STOCK_NETWORK);
gtk_about_dialog_set_email_hook(email_hook, NULL, NULL);
gtk_about_dialog_set_url_hook(url_hook, NULL, NULL);
gtk_show_about_dialog(NULL,
"version", VERSION,
"copyright", copyright,
- "license", license,
+ "license", l,
"website-label", "dhcpcd Website",
"website", "http://roy.marples.name/projects/dhcpcd",
"authors", authors,
- "wrap-license", TRUE,
"logo-icon-name", GTK_STOCK_NETWORK,
NULL);
+ g_free(l);
}
static void
menu = (GtkMenu *)gtk_menu_new();
- item = gtk_image_menu_item_new_with_mnemonic("_Quit");
+ item = gtk_image_menu_item_new_with_mnemonic(_("_Quit"));
image = gtk_image_new_from_icon_name(GTK_STOCK_QUIT,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
item = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- item = gtk_image_menu_item_new_with_mnemonic("_Help");
+ item = gtk_image_menu_item_new_with_mnemonic(_("_Help"));
image = gtk_image_new_from_icon_name(GTK_STOCK_HELP,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
G_CALLBACK(on_help), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- item = gtk_image_menu_item_new_with_mnemonic("_About");
+ item = gtk_image_menu_item_new_with_mnemonic(_("_About"));
image = gtk_image_new_from_icon_name(GTK_STOCK_ABOUT,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);