Translating the messaging tool

This commit is contained in:
Pierre Pronchery 2013-11-21 02:30:01 +01:00
parent 2527e2d1c7
commit 0cecb4055e
2 changed files with 29 additions and 7 deletions

View File

@ -24,5 +24,6 @@
../src/panelctl.c ../src/panelctl.c
../src/run.c ../src/run.c
../src/window.c ../src/window.c
../tools/message.c
../tools/notify.c ../tools/notify.c
../tools/test.c ../tools/test.c

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012-2013 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Panel */ /* This file is part of DeforaOS Desktop Panel */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,8 +19,26 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <locale.h>
#include <libintl.h>
#include <Desktop.h> #include <Desktop.h>
#include "../include/Panel.h" #include "../include/Panel.h"
#include "../config.h"
#define _(string) gettext(string)
/* constants */
#ifndef PROGNAME
# define PROGNAME "panel-message"
#endif
#ifndef PREFIX
# define PREFIX "/usr/local"
#endif
#ifndef DATADIR
# define DATADIR PREFIX "/share"
#endif
#ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale"
#endif
/* private */ /* private */
@ -55,23 +73,23 @@ static int _message(unsigned int timeout, GtkMessageType type,
case GTK_MESSAGE_ERROR: case GTK_MESSAGE_ERROR:
stock = GTK_STOCK_DIALOG_ERROR; stock = GTK_STOCK_DIALOG_ERROR;
if(title == NULL) if(title == NULL)
title = "Error"; title = _("Error");
break; break;
case GTK_MESSAGE_QUESTION: case GTK_MESSAGE_QUESTION:
stock = GTK_STOCK_DIALOG_QUESTION; stock = GTK_STOCK_DIALOG_QUESTION;
if(title == NULL) if(title == NULL)
title = "Question"; title = _("Question");
break; break;
case GTK_MESSAGE_WARNING: case GTK_MESSAGE_WARNING:
stock = GTK_STOCK_DIALOG_WARNING; stock = GTK_STOCK_DIALOG_WARNING;
if(title == NULL) if(title == NULL)
title = "Warning"; title = _("Warning");
break; break;
case GTK_MESSAGE_INFO: case GTK_MESSAGE_INFO:
default: default:
stock = GTK_STOCK_DIALOG_INFO; stock = GTK_STOCK_DIALOG_INFO;
if(title == NULL) if(title == NULL)
title = "Information"; title = _("Information");
break; break;
} }
plug = gtk_plug_new(0); plug = gtk_plug_new(0);
@ -123,8 +141,8 @@ static gboolean _message_on_timeout(gpointer data)
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fputs("Usage: panel-message [-EIQW][-T title][-t timeout] message\n", fprintf(stderr, _("Usage: %s [-EIQW][-T title][-t timeout] message\n"),
stderr); PROGNAME);
return 1; return 1;
} }
@ -140,6 +158,9 @@ int main(int argc, char * argv[])
int o; int o;
char * p; char * p;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
while((o = getopt(argc, argv, "EIQT:Wt:")) != -1) while((o = getopt(argc, argv, "EIQT:Wt:")) != -1)
switch(o) switch(o)