Began the French translation

This commit is contained in:
Pierre Pronchery 2013-01-18 22:42:01 +01:00
parent 3e7b4af348
commit bc490523d1
9 changed files with 278 additions and 12 deletions

View File

@ -1,6 +1,6 @@
PACKAGE = Camera
VERSION = 0.0.0
SUBDIRS = data src tools
SUBDIRS = data po src tools
RM = rm -f
LN = ln -f
TAR = tar -czvf
@ -25,6 +25,11 @@ dist:
$(PACKAGE)-$(VERSION)/data/camera.desktop \
$(PACKAGE)-$(VERSION)/data/gallery.desktop \
$(PACKAGE)-$(VERSION)/data/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/camera.c \
$(PACKAGE)-$(VERSION)/src/main.c \
$(PACKAGE)-$(VERSION)/src/Makefile \

31
po/Makefile Normal file
View File

@ -0,0 +1,31 @@
TARGETS = Camera.pot fr.mo
PREFIX = /usr/local
DESTDIR =
RM = rm -f
LN = ln -f
MKDIR = mkdir -p
INSTALL = install
all: $(TARGETS)
Camera.pot: POTFILES
./gettext.sh -P "$(PREFIX)" -- "Camera.pot"
fr.mo: Camera.pot fr.po
./gettext.sh -P "$(PREFIX)" -- "fr.mo"
clean:
$(RM) -- $(Camera.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

2
po/POTFILES Normal file
View File

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

25
po/fr.po Normal file
View File

@ -0,0 +1,25 @@
# $Id$
# Copyright (c) 2013 Pierre Pronchery <khorben@defora.org>
# This file is distributed under the same license as the Camera package.
# Pierre Pronchery <khorben@defora.org>, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: Camera 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-01-18 22:35+0100\n"
"PO-Revision-Date: 2013-01-18 22:31+0100\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:65
msgid ""
"Usage: camera [-d device]\n"
" -d\tVideo device to open\n"
msgstr ""
"Usage: camera [-d périphérique]\n"
" -d\tPériphérique video à ouvrir\n"

169
po/gettext.sh Executable file
View File

@ -0,0 +1,169 @@
#!/bin/sh
#$Id$
#Copyright (c) 2010-2013 Pierre Pronchery <khorben@defora.org>
#
#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

13
po/project.conf Normal file
View File

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

View File

@ -1,6 +1,6 @@
package=Camera
version=0.0.0
subdirs=data,src,tools
config=h
subdirs=data,po,src,tools
config=h,sh
dist=Makefile,config.h

View File

@ -31,12 +31,15 @@ static char const _license[] =
#endif
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <System.h>
#include <Desktop.h>
#include "camera.h"
#include "../config.h"
#define _(string) gettext(string)
#define N_(string) (string)
/* Camera */
@ -345,11 +348,11 @@ static int _snapshot_dcim(Camera * camera, char const * homedir,
char * path;
if((path = g_build_filename(homedir, dcim, NULL)) == NULL)
return -_camera_error(camera, "Could not save picture", 1);
return -_camera_error(camera, _("Could not save picture"), 1);
if(mkdir(path, 0777) != 0 && errno != EEXIST)
{
error_set_code(1, "%s: %s: %s", "Could not save picture", path,
strerror(errno));
error_set_code(1, "%s: %s: %s", _("Could not save picture"),
path, strerror(errno));
free(path);
return -_camera_error(camera, error_get(), 1);
}
@ -368,7 +371,7 @@ static char * _snapshot_path(Camera * camera, char const * homedir,
if(gettimeofday(&tv, NULL) != 0 || gmtime_r(&tv.tv_sec, &tm) == NULL)
{
error_set_code(1, "%s: %s", "Could not save picture",
error_set_code(1, "%s: %s", _("Could not save picture"),
strerror(errno));
_camera_error(camera, error_get(), 1);
return NULL;
@ -387,7 +390,7 @@ static char * _snapshot_path(Camera * camera, char const * homedir,
g_free(filename);
if(path == NULL)
{
_camera_error(camera, "Could not save picture", 1);
_camera_error(camera, _("Could not save picture"), 1);
return NULL;
}
#ifdef DEBUG
@ -411,12 +414,12 @@ static int _snapshot_save(Camera * camera, char const * path)
GDK_COLORSPACE_RGB, FALSE, 8,
pix->width, pix->height, pix->width * 3,
NULL, NULL)) == NULL)
return -_camera_error(camera, "Could not save picture", 1);
return -_camera_error(camera, _("Could not save picture"), 1);
res = gdk_pixbuf_save(pixbuf, path, "png", &error, NULL);
g_object_unref(pixbuf);
if(res != TRUE)
{
error_set_code(1, "%s: %s", "Could not save picture",
error_set_code(1, "%s: %s", _("Could not save picture"),
error->message);
g_error_free(error);
return -_camera_error(camera, error_get(), 1);

View File

@ -17,10 +17,25 @@
#include <unistd.h>
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include <System.h>
#include "camera.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 */
@ -47,8 +62,8 @@ static int _camera(char const * device)
/* usage */
static int _usage(void)
{
fputs("Usage: camera [-d device]\n"
" -d Video device to open\n", stderr);
fputs(_("Usage: camera [-d device]\n"
" -d Video device to open\n"), stderr);
return 1;
}
@ -61,6 +76,9 @@ int main(int argc, char * argv[])
int o;
char const * device = NULL;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
gtk_init(&argc, &argv);
while((o = getopt(argc, argv, "d:")) != -1)
switch(o)