Began to translate the Panel project

This commit is contained in:
Pierre Pronchery 2010-04-22 11:33:53 +00:00
parent c0840ad650
commit e05d9de675
9 changed files with 235 additions and 22 deletions

View File

@ -1,6 +1,6 @@
PACKAGE = Panel
VERSION = 0.0.5
SUBDIRS = include src
SUBDIRS = include po src
RM = rm -f
LN = ln -f
TAR = tar -czvf
@ -24,6 +24,11 @@ dist:
$(PACKAGE)-$(VERSION)/include/Panel.h \
$(PACKAGE)-$(VERSION)/include/Makefile \
$(PACKAGE)-$(VERSION)/include/project.conf \
$(PACKAGE)-$(VERSION)/po/Makefile \
$(PACKAGE)-$(VERSION)/po/gettext.sh \
$(PACKAGE)-$(VERSION)/po/POTFILES \
$(PACKAGE)-$(VERSION)/po/fr.po \
$(PACKAGE)-$(VERSION)/po/project.conf \
$(PACKAGE)-$(VERSION)/src/panel.c \
$(PACKAGE)-$(VERSION)/src/main.c \
$(PACKAGE)-$(VERSION)/src/run.c \
@ -52,6 +57,7 @@ dist:
$(PACKAGE)-$(VERSION)/src/applets/project.conf \
$(PACKAGE)-$(VERSION)/Makefile \
$(PACKAGE)-$(VERSION)/config.h \
$(PACKAGE)-$(VERSION)/config.sh \
$(PACKAGE)-$(VERSION)/project.conf
$(RM) $(PACKAGE)-$(VERSION)

30
po/Makefile Normal file
View File

@ -0,0 +1,30 @@
TARGETS = Panel.pot fr.mo
PREFIX = /usr/local
DESTDIR =
RM = rm -f
LN = ln -f
MKDIR = mkdir -p
INSTALL = install
all: $(TARGETS)
Panel.pot: POTFILES
./gettext.sh "Panel.pot"
fr.mo: Panel.pot fr.po
./gettext.sh "fr.mo"
clean:
$(RM) $(Panel.pot_OBJS) $(fr.mo_OBJS)
distclean: clean
$(RM) $(TARGETS)
install: all
./gettext.sh -p "$(PREFIX)" install "fr.mo"
uninstall:
./gettext.sh -p "$(PREFIX)" uninstall "fr.mo"
.PHONY: all clean distclean install uninstall

2
po/POTFILES Normal file
View File

@ -0,0 +1,2 @@
../src/main.c
../src/panel.c

52
po/fr.po Normal file
View File

@ -0,0 +1,52 @@
# $Id$
# Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>
# This file is distributed under the same license as the Panel package.
# Pierre Pronchery <khorben@defora.org>, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Panel 0.0.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-04-22 12:53+0200\n"
"PO-Revision-Date: 2010-04-22 12:45+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: ../src/main.c:47
msgid ""
"Usage: panel [-m monitor][-sSx]\n"
" -m\tMonitor to use (default: 0)\n"
" -s\tUse icons the size of a small toolbar\n"
" -S\tUse icons the size of a large toolbar (default)\n"
" -x\tUse icons the size of menus\n"
msgstr ""
#: ../src/panel.c:312
msgid ""
"This will log you out of the current session, therefore closing any "
"application currently opened and losing any unsaved data.\n"
"Do you really want to proceed?"
msgstr ""
#: ../src/panel.c:320 ../src/panel.c:325 ../src/panel.c:333
msgid "Logout"
msgstr ""
#: ../src/panel.c:369
msgid ""
"This will shutdown your computer, therefore closing any application "
"currently opened and losing any unsaved data.\n"
"Do you really want to proceed?"
msgstr ""
#: ../src/panel.c:385 ../src/panel.c:390 ../src/panel.c:397
msgid "Shutdown"
msgstr "Arrêter"
#: ../src/panel.c:389
msgid "Reboot"
msgstr "Redémarrer"

88
po/gettext.sh Executable file
View File

@ -0,0 +1,88 @@
#!/bin/sh
#$Id$
#variables
. "../config.sh"
DEBUG="_debug"
INSTALL="install -m 0644"
LOCALEDIR="$PREFIX/share/locale"
MKDIR="mkdir -p"
MSGFMT="msgfmt"
MSGINIT="msginit"
MSGMERGE="msgmerge"
POTFILES="POTFILES"
XGETTEXT="xgettext --force-po"
#functions
#usage
_usage()
{
echo "Usage: ./gettext.sh target" 1>&2
return 1
}
#debug
_debug()
{
echo $@
$@
}
#gettext_mo
_gettext_mo()
{
package="$1"
lang="$2"
if [ -f "$lang.po" ]; then
$DEBUG $MSGMERGE -U "$lang.po" "$package.pot" || return 1
else
$DEBUG $MSGINIT -l "$lang" -o "$lang.po" -i "$package.pot" \
|| return 1
fi
$DEBUG $MSGFMT -c -v -o "$lang.mo" "$lang.po" || return 1
}
#gettext_pot
_gettext_pot()
{
package="$1"
$DEBUG $XGETTEXT -d "$package" -o "$package.pot" --keyword="_" \
--keyword="N_" -f "$POTFILES" || return 1
}
#main
if [ $# -eq 4 -a "$1" = "-p" -a "$3" = "install" ]; then
PREFIX="$2"
LOCALEDIR="$PREFIX/share/locale"
lang="${4%%.mo}"
$DEBUG $MKDIR "$LOCALEDIR/$lang/LC_MESSAGES" || exit 2
$DEBUG $INSTALL "$4" "$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|| exit 2
exit 0
fi
if [ $# -ne 1 ]; then
_usage
exit $?
fi
case "$1" in
*.mo)
_gettext_mo "$PACKAGE" "${1%%.mo}" || exit 2
;;
*.pot)
_gettext_pot "${1%%.pot}" || exit 2
;;
*)
exit 2
;;
esac
exit 0

13
po/project.conf Normal file
View File

@ -0,0 +1,13 @@
targets=Panel.pot,fr.mo
dist=Makefile,gettext.sh,POTFILES,fr.po
[Panel.pot]
type=script
script=./gettext.sh
depends=POTFILES
[fr.mo]
type=script
script=./gettext.sh
install=
depends=Panel.pot,fr.po

View File

@ -1,6 +1,6 @@
package=Panel
version=0.0.5
config=h
config=h,sh
subdirs=include,src
dist=Makefile,config.h
subdirs=include,po,src
dist=Makefile,config.h,config.sh

View File

@ -21,19 +21,34 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <locale.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include "common.h"
#include "../config.h"
#define _(string) gettext(string)
/* constants */
#ifndef PREFIX
# define PREFIX "/usr/local"
#endif
#ifndef DATADIR
# define DATADIR PREFIX "/share"
#endif
#ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale"
#endif
/* usage */
static int _usage(void)
{
fputs("Usage: " PACKAGE " [-m monitor][-sSx]\n"
fputs(_("Usage: panel [-m monitor][-sSx]\n"
" -m Monitor to use (default: 0)\n"
" -s Use icons the size of a small toolbar\n"
" -S Use icons the size of a large toolbar (default)\n"
" -x Use icons the size of menus\n", stderr);
" -x Use icons the size of menus\n"), stderr);
return 1;
}
@ -49,6 +64,9 @@ int main(int argc, char * argv[])
char * p;
struct sigaction sa;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
gtk_init(&argc, &argv);
memset(&prefs, 0, sizeof(prefs));
prefs.iconsize = PANEL_ICON_SIZE_LARGE;
@ -80,7 +98,7 @@ int main(int argc, char * argv[])
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if(sigaction(SIGCHLD, &sa, NULL) == -1)
panel_error(panel, "signal handling error", 0);
panel_error(panel, "sigaction", 0);
gtk_main();
panel_delete(panel);
return 0;

View File

@ -21,10 +21,12 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include "Panel.h"
#include "common.h"
#include "../config.h"
#define _(string) gettext(string)
/* Panel */
@ -51,10 +53,10 @@ struct _Panel
/* constants */
#ifndef PREFIX
# define PREFIX "/usr/local"
# define PREFIX "/usr/local"
#endif
#ifndef LIBDIR
# define LIBDIR PREFIX "/lib"
# define LIBDIR PREFIX "/lib"
#endif
#define PANEL_CONFIG_FILE ".panel"
@ -307,19 +309,20 @@ static int _error_text(char const * message, int ret)
static int _panel_helper_logout_dialog(void)
{
GtkWidget * dialog;
const char message[] = "This will log you out of the current session,"
" therefore closing any application currently opened and losing"
" any unsaved data.\nDo you really want to proceed?";
const char * message = _("This will log you out of the current session,"
" therefore closing any application currently opened"
" and losing any unsaved data.\n"
"Do you really want to proceed?");
GtkWidget * widget;
int res;
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO,
GTK_BUTTONS_NONE, "%s", "Logout");
GTK_BUTTONS_NONE, "%s", _("Logout"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, NULL);
widget = gtk_button_new_with_label("Logout");
widget = gtk_button_new_with_label(_("Logout"));
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name(
"gnome-logout", GTK_ICON_SIZE_BUTTON));
gtk_widget_show_all(widget);
@ -327,7 +330,7 @@ static int _panel_helper_logout_dialog(void)
GTK_RESPONSE_ACCEPT);
gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
gtk_window_set_title(GTK_WINDOW(dialog), "Logout");
gtk_window_set_title(GTK_WINDOW(dialog), _("Logout"));
res = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if(res != GTK_RESPONSE_ACCEPT)
@ -363,9 +366,10 @@ static int _panel_helper_shutdown_dialog(void)
{
GtkWidget * dialog;
GtkWidget * widget;
const char message[] = "This will shutdown your computer,"
" therefore closing any application currently opened and losing"
" any unsaved data.\nDo you really want to proceed?";
const char * message = _("This will shutdown your computer,"
" therefore closing any application currently opened"
" and losing any unsaved data.\n"
"Do you really want to proceed?");
enum { RES_CANCEL, RES_REBOOT, RES_SHUTDOWN };
int res;
char * reboot[] = { "/sbin/shutdown", "shutdown", "-r", "now", NULL };
@ -378,19 +382,19 @@ static int _panel_helper_shutdown_dialog(void)
"now", NULL };
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO,
GTK_BUTTONS_NONE, "%s", "Shutdown");
GTK_BUTTONS_NONE, "%s", _("Shutdown"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, RES_CANCEL,
"Reboot", RES_REBOOT, NULL);
widget = gtk_button_new_with_label("Shutdown");
_("Reboot"), RES_REBOOT, NULL);
widget = gtk_button_new_with_label(_("Shutdown"));
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name(
"gnome-shutdown", GTK_ICON_SIZE_BUTTON));
gtk_widget_show_all(widget);
gtk_dialog_add_action_widget(GTK_DIALOG(dialog), widget, RES_SHUTDOWN);
gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
gtk_window_set_title(GTK_WINDOW(dialog), "Shutdown");
gtk_window_set_title(GTK_WINDOW(dialog), _("Shutdown"));
res = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if(res == RES_SHUTDOWN)