From 020b1338a6dbd1d90d1cc8eb50c08074777d8d1f Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 24 Feb 2013 04:44:38 +0100 Subject: [PATCH] Translated to French --- Makefile | 7 +- po/Makefile | 31 +++++++++ po/POTFILES | 2 + po/fr.po | 77 ++++++++++++++++++++++ po/gettext.sh | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ po/project.conf | 13 ++++ project.conf | 2 +- src/main.c | 30 ++++++++- src/terminal.c | 49 +++++++++----- 9 files changed, 361 insertions(+), 19 deletions(-) create mode 100644 po/Makefile create mode 100644 po/POTFILES create mode 100644 po/fr.po create mode 100755 po/gettext.sh create mode 100644 po/project.conf diff --git a/Makefile b/Makefile index 9f86abc..2f0f0fd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PACKAGE = Terminal VERSION = 0.0.0 -SUBDIRS = data doc src +SUBDIRS = data doc po src RM = rm -f LN = ln -f TAR = tar -czvf @@ -29,6 +29,11 @@ dist: $(PACKAGE)-$(VERSION)/doc/docbook.sh \ $(PACKAGE)-$(VERSION)/doc/terminal.xml \ $(PACKAGE)-$(VERSION)/doc/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/terminal.c \ $(PACKAGE)-$(VERSION)/src/main.c \ $(PACKAGE)-$(VERSION)/src/Makefile \ diff --git a/po/Makefile b/po/Makefile new file mode 100644 index 0000000..774acee --- /dev/null +++ b/po/Makefile @@ -0,0 +1,31 @@ +TARGETS = Terminal.pot fr.mo +PREFIX = /usr/local +DESTDIR = +RM = rm -f +LN = ln -f +MKDIR = mkdir -m 0755 -p +INSTALL = install + + +all: $(TARGETS) + +Terminal.pot: POTFILES + ./gettext.sh -P "$(PREFIX)" -- "Terminal.pot" + +fr.mo: Terminal.pot fr.po + ./gettext.sh -P "$(PREFIX)" -- "fr.mo" + +clean: + $(RM) -- $(Terminal.pot_OBJS) $(fr.mo_OBJS) + ./gettext.sh -c -P "$(PREFIX)" -- "fr.mo" + +distclean: clean + $(RM) -- $(TARGETS) + +install: $(TARGETS) + ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "fr.mo" + +uninstall: + ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -u -- "fr.mo" + +.PHONY: all clean distclean install uninstall diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 0000000..1152907 --- /dev/null +++ b/po/POTFILES @@ -0,0 +1,2 @@ +../src/main.c +../src/terminal.c diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 0000000..7f70455 --- /dev/null +++ b/po/fr.po @@ -0,0 +1,77 @@ +# $Id$ +# Copyright (c) 2013 Pierre Pronchery +# This file is distributed under the same license as the Terminal package. +# Pierre Pronchery , 2013. +# +msgid "" +msgstr "" +"Project-Id-Version: Terminal 0.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-24 04:38+0100\n" +"PO-Revision-Date: 2013-02-24 04:26+0100\n" +"Last-Translator: Pierre Pronchery \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:74 +msgid "Usage: terminal\n" +msgstr "Usage: terminal\n" + +#: ../src/terminal.c:109 +msgid "New _tab" +msgstr "Nouvelle _tab" + +#: ../src/terminal.c:111 +msgid "_New window" +msgstr "_Nouvelle fenêtre" + +#: ../src/terminal.c:114 +msgid "Close all tabs" +msgstr "Fermer toutes les tabs" + +#: ../src/terminal.c:116 +msgid "_Close" +msgstr "_Fermer" + +#: ../src/terminal.c:123 +msgid "_Contents" +msgstr "_Sommaire" + +#: ../src/terminal.c:126 ../src/terminal.c:129 +msgid "_About" +msgstr "À _propos" + +#: ../src/terminal.c:136 +msgid "_File" +msgstr "_Fichier" + +#: ../src/terminal.c:137 +msgid "_Help" +msgstr "_Aide" + +#: ../src/terminal.c:144 +msgid "New tab" +msgstr "Nouvelle tab" + +#: ../src/terminal.c:146 +msgid "New window" +msgstr "Nouvelle fenêtre" + +#: ../src/terminal.c:175 +msgid "Terminal" +msgstr "Terminal" + +#: ../src/terminal.c:333 +msgid "xterm exited with status " +msgstr "xterm a quitté avec le code d'erreur " + +#: ../src/terminal.c:340 +msgid "xterm exited with signal " +msgstr "xterm a quitté avec le signal " + +#: ../src/terminal.c:450 +msgid "Terminal for the DeforaOS desktop" +msgstr "Émulateur de terminal pour l'environnement DeforaOS" diff --git a/po/gettext.sh b/po/gettext.sh new file mode 100755 index 0000000..4286018 --- /dev/null +++ b/po/gettext.sh @@ -0,0 +1,169 @@ +#!/bin/sh +#$Id$ +#Copyright (c) 2010-2013 Pierre Pronchery +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +#variables +PREFIX="/usr/local" +. "../config.sh" +LOCALEDIR="$PREFIX/share/locale" +POTFILES="POTFILES" +#executables +DEBUG="_debug" +INSTALL="install -m 0644" +MKDIR="mkdir -p" +MSGFMT="msgfmt" +MSGINIT="msginit" +MSGMERGE="msgmerge" +RM="rm -f" +XGETTEXT="xgettext --force-po" + + +#functions +#debug +_debug() +{ + echo "$@" 1>&2 + "$@" +} + + +#usage +_usage() +{ + echo "Usage: gettext.sh [-c|-i|-u][-P prefix] target..." 1>&2 + return 1 +} + + +#gettext_mo +_gettext_mo() +{ + package="$1" + lang="$2" + + _gettext_po "$package" "$lang" || return 1 + $DEBUG $MSGFMT -c -v -o "$lang.mo" "$lang.po" || return 1 +} + + +#gettext_po +_gettext_po() +{ + 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 +} + + +#gettext_pot +_gettext_pot() +{ + package="$1" + + $DEBUG $XGETTEXT -d "$package" -o "$package.pot" --keyword="_" \ + --keyword="N_" -f "$POTFILES" || return 1 +} + + +#main +clean=0 +install=0 +uninstall=0 +while getopts "ciuP:" name; do + case "$name" in + c) + clean=1 + ;; + i) + uninstall=0 + install=1 + ;; + u) + install=0 + uninstall=1 + ;; + P) + PREFIX="$2" + ;; + ?) + _usage + exit $? + ;; + esac +done +shift $(($OPTIND - 1)) +if [ $# -eq 0 ]; then + _usage + exit $? +fi + +LOCALEDIR="$PREFIX/share/locale" +while [ $# -gt 0 ]; do + target="$1" + lang="${target%%.mo}" + lang="${lang%%.po}" + shift + + #clean + [ "$clean" -ne 0 ] && continue + + #uninstall + if [ "$uninstall" -eq 1 ]; then + $DEBUG $RM "$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \ + || exit 2 + continue + fi + + #install + if [ "$install" -eq 1 ]; then + $DEBUG $MKDIR "$LOCALEDIR/$lang/LC_MESSAGES" || exit 2 + $DEBUG $INSTALL "$target" \ + "$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \ + || exit 2 + continue + fi + + #create + case "$target" in + *.mo) + _gettext_mo "$PACKAGE" "$lang" || exit 2 + ;; + *.po) + _gettext_po "$PACKAGE" "$lang" || exit 2 + ;; + *.pot) + _gettext_pot "${target%%.pot}" || exit 2 + ;; + *) + exit 2 + ;; + esac +done diff --git a/po/project.conf b/po/project.conf new file mode 100644 index 0000000..b217a45 --- /dev/null +++ b/po/project.conf @@ -0,0 +1,13 @@ +targets=Terminal.pot,fr.mo +dist=Makefile,gettext.sh,POTFILES,fr.po + +[Terminal.pot] +type=script +script=./gettext.sh +depends=POTFILES + +[fr.mo] +type=script +script=./gettext.sh +install= +depends=Terminal.pot,fr.po diff --git a/project.conf b/project.conf index 042f19c..d8deca0 100644 --- a/project.conf +++ b/project.conf @@ -2,5 +2,5 @@ package=Terminal version=0.0.0 config=h,sh -subdirs=data,doc,src +subdirs=data,doc,po,src dist=Makefile,config.h,config.sh diff --git a/src/main.c b/src/main.c index 6e80984..0a5680c 100644 --- a/src/main.c +++ b/src/main.c @@ -17,16 +17,31 @@ #include #include +#include +#include #include #include #include "terminal.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 /* private */ /* prototypes */ static int _terminal(void); +static int _error(char const * message, int ret); static int _usage(void); @@ -44,10 +59,19 @@ static int _terminal(void) } +/* error */ +static int _error(char const * message, int ret) +{ + fputs("terminal: ", stderr); + perror(message); + return ret; +} + + /* usage */ static int _usage(void) { - fputs("Usage: terminal\n", stderr); + fputs(_("Usage: terminal\n"), stderr); return 1; } @@ -59,6 +83,10 @@ int main(int argc, char * argv[]) { int o; + if(setlocale(LC_ALL, "") == NULL) + _error("setlocale", 1); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); gtk_init(&argc, &argv); while((o = getopt(argc, argv, "")) != -1) switch(o) diff --git a/src/terminal.c b/src/terminal.c index 913d5c9..969159c 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -23,12 +23,15 @@ char const _license[] = #include #include #include +#include #include #include #include #include #include "terminal.h" #include "../config.h" +#define _(string) gettext(string) +#define N_(string) (string) /* constants */ #ifndef PREFIX @@ -90,6 +93,7 @@ static void _terminal_on_tab_close(GtkWidget * widget, gpointer data); #ifndef EMBEDDED static void _terminal_on_file_close(gpointer data); +static void _terminal_on_file_close_all(gpointer data); static void _terminal_on_file_new_tab(gpointer data); static void _terminal_on_file_new_window(gpointer data); static void _terminal_on_help_about(gpointer data); @@ -102,42 +106,45 @@ static void _terminal_on_help_contents(gpointer data); /* menubar */ static const DesktopMenu _terminal_file_menu[] = { - { "New _tab", G_CALLBACK(_terminal_on_file_new_tab), "tab-new", + { N_("New _tab"), G_CALLBACK(_terminal_on_file_new_tab), "tab-new", GDK_CONTROL_MASK, GDK_KEY_T }, - { "_New window", G_CALLBACK(_terminal_on_file_new_window), "window-new", - GDK_CONTROL_MASK, GDK_KEY_N }, + { N_("_New window"), G_CALLBACK(_terminal_on_file_new_window), + "window-new", GDK_CONTROL_MASK, GDK_KEY_N }, { "", NULL, NULL, 0, 0 }, - { "_Close", G_CALLBACK(_terminal_on_file_close), GTK_STOCK_CLOSE, + { N_("Close all tabs"), G_CALLBACK(_terminal_on_file_close_all), NULL, + 0, 0 }, + { N_("_Close"), G_CALLBACK(_terminal_on_file_close), GTK_STOCK_CLOSE, GDK_CONTROL_MASK, GDK_KEY_W }, { NULL, NULL, NULL, 0, 0 } }; static const DesktopMenu _terminal_help_menu[] = { - { "_Contents", G_CALLBACK(_terminal_on_help_contents), "help-contents", - 0, GDK_KEY_F1 }, + { N_("_Contents"), G_CALLBACK(_terminal_on_help_contents), + "help-contents", 0, GDK_KEY_F1 }, #if GTK_CHECK_VERSION(2, 6, 0) - { "_About", G_CALLBACK(_terminal_on_help_about), GTK_STOCK_ABOUT, 0, + { N_("_About"), G_CALLBACK(_terminal_on_help_about), GTK_STOCK_ABOUT, 0, 0 }, #else - { "_About", G_CALLBACK(_terminal_on_help_about), NULL, 0, 0 }, + { N_("_About"), G_CALLBACK(_terminal_on_help_about), NULL, 0, 0 }, #endif { NULL, NULL, NULL, 0, 0 } }; static const DesktopMenubar _terminal_menubar[] = { - { "_File", _terminal_file_menu }, - { "_Help", _terminal_help_menu }, + { N_("_File"), _terminal_file_menu }, + { N_("_Help"), _terminal_help_menu }, { NULL, NULL } }; #endif static DesktopToolbar _terminal_toolbar[] = { - { "New tab", G_CALLBACK(_terminal_on_new_tab), "tab-new", 0, 0, NULL }, - { "New window", G_CALLBACK(_terminal_on_new_window), "window-new", 0, 0, + { N_("New tab"), G_CALLBACK(_terminal_on_new_tab), "tab-new", 0, 0, NULL }, + { N_("New window"), G_CALLBACK(_terminal_on_new_window), "window-new", + 0, 0, NULL }, { NULL, NULL, NULL, 0, 0, NULL } }; @@ -165,7 +172,7 @@ Terminal * terminal_new(void) #if GTK_CHECK_VERSION(2, 6, 0) gtk_window_set_icon_name(GTK_WINDOW(terminal->window), "terminal"); #endif - gtk_window_set_title(GTK_WINDOW(terminal->window), "Terminal"); + gtk_window_set_title(GTK_WINDOW(terminal->window), _("Terminal")); g_signal_connect_swapped(terminal->window, "delete-event", G_CALLBACK( _terminal_on_closex), terminal); vbox = gtk_vbox_new(FALSE, 0); @@ -323,14 +330,15 @@ static void _terminal_on_child_watch(GPid pid, gint status, gpointer data) { if(WEXITSTATUS(status) != 0) fprintf(stderr, "%s: %s%u\n", "Terminal", - "xterm exited with status ", + _("xterm exited with status "), WEXITSTATUS(status)); _terminal_close_tab(terminal, i); } else if(WIFSIGNALED(status)) { fprintf(stderr, "%s: %s%u\n", "Terminal", - "xterm exited with signal ", WTERMSIG(status)); + _("xterm exited with signal "), + WTERMSIG(status)); _terminal_close_tab(terminal, i); } } @@ -401,6 +409,15 @@ static void _terminal_on_file_close(gpointer data) } +/* terminal_on_file_close_all */ +static void _terminal_on_file_close_all(gpointer data) +{ + Terminal * terminal = data; + + _terminal_on_close(terminal); +} + + /* terminal_on_file_new_tab */ static void _terminal_on_file_new_tab(gpointer data) { @@ -430,7 +447,7 @@ static void _terminal_on_help_about(gpointer data) GTK_WINDOW(terminal->window)); desktop_about_dialog_set_authors(dialog, _authors); desktop_about_dialog_set_comments(dialog, - "Terminal for the DeforaOS desktop"); + _("Terminal for the DeforaOS desktop")); desktop_about_dialog_set_copyright(dialog, _copyright); desktop_about_dialog_set_license(dialog, _license); desktop_about_dialog_set_logo_icon_name(dialog, "terminal");