Beginning to translate the project
This commit is contained in:
parent
f66424695f
commit
e36379ce40
7
Makefile
7
Makefile
|
@ -1,6 +1,6 @@
|
||||||
PACKAGE = PDFViewer
|
PACKAGE = PDFViewer
|
||||||
VERSION = 0.0.1
|
VERSION = 0.0.1
|
||||||
SUBDIRS = data doc src
|
SUBDIRS = data doc po src
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
LN = ln -f
|
LN = ln -f
|
||||||
TAR = tar -czvf
|
TAR = tar -czvf
|
||||||
|
@ -28,6 +28,11 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/doc/docbook.sh \
|
$(PACKAGE)-$(VERSION)/doc/docbook.sh \
|
||||||
$(PACKAGE)-$(VERSION)/doc/pdfviewer.xml \
|
$(PACKAGE)-$(VERSION)/doc/pdfviewer.xml \
|
||||||
$(PACKAGE)-$(VERSION)/doc/project.conf \
|
$(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/callbacks.c \
|
$(PACKAGE)-$(VERSION)/src/callbacks.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/pdfviewer.c \
|
$(PACKAGE)-$(VERSION)/src/pdfviewer.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/main.c \
|
$(PACKAGE)-$(VERSION)/src/main.c \
|
||||||
|
|
31
po/Makefile
Normal file
31
po/Makefile
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
TARGETS = PDFViewer.pot fr.mo
|
||||||
|
PREFIX = /usr/local
|
||||||
|
DESTDIR =
|
||||||
|
RM = rm -f
|
||||||
|
LN = ln -f
|
||||||
|
MKDIR = mkdir -m 0755 -p
|
||||||
|
INSTALL = install
|
||||||
|
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
PDFViewer.pot: POTFILES
|
||||||
|
./gettext.sh -P "$(PREFIX)" -- "PDFViewer.pot"
|
||||||
|
|
||||||
|
fr.mo: PDFViewer.pot fr.po
|
||||||
|
./gettext.sh -P "$(PREFIX)" -- "fr.mo"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -- $(PDFViewer.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
|
1
po/POTFILES
Normal file
1
po/POTFILES
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../src/main.c
|
21
po/fr.po
Normal file
21
po/fr.po
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# $Id$
|
||||||
|
# Copyright (c) 2013 Pierre Pronchery <khorben@defora.org>
|
||||||
|
# This file is distributed under the same license as the PDFViewer package.
|
||||||
|
# Pierre Pronchery <khorben@defora.org>, 2013.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PDFViewer 0.0.01\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2013-10-31 00:49+0100\n"
|
||||||
|
"PO-Revision-Date: 2013-10-31 00:44+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:55
|
||||||
|
msgid "Usage: pdfviewer [file]\n"
|
||||||
|
msgstr "Usage: pdfviewer [fichier]\n"
|
169
po/gettext.sh
Executable file
169
po/gettext.sh
Executable 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
13
po/project.conf
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
targets=PDFViewer.pot,fr.mo
|
||||||
|
dist=Makefile,gettext.sh,POTFILES,fr.po
|
||||||
|
|
||||||
|
[PDFViewer.pot]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
depends=POTFILES
|
||||||
|
|
||||||
|
[fr.mo]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
install=
|
||||||
|
depends=PDFViewer.pot,fr.po
|
|
@ -2,5 +2,5 @@ package=PDFViewer
|
||||||
version=0.0.1
|
version=0.0.1
|
||||||
config=h,sh
|
config=h,sh
|
||||||
|
|
||||||
subdirs=data,doc,src
|
subdirs=data,doc,po,src
|
||||||
dist=Makefile,COPYING,config.h,config.sh
|
dist=Makefile,COPYING,config.h,config.sh
|
||||||
|
|
32
src/main.c
32
src/main.c
|
@ -1,5 +1,6 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2010 Sébastien Bocahu <zecrazytux@zecrazytux.net> */
|
/* Copyright (c) 2010 Sébastien Bocahu <zecrazytux@zecrazytux.net> */
|
||||||
|
/* Copyright (c) 2013 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* 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
|
||||||
* the Free Software Foundation, version 3 of the License.
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
@ -14,29 +15,58 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <libintl.h>
|
||||||
#include "pdfviewer.h"
|
#include "pdfviewer.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
#define _(string) gettext(string)
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
#ifndef PREFIX
|
#ifndef PREFIX
|
||||||
# define PREFIX "/usr/local"
|
# define PREFIX "/usr/local"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef DATADIR
|
||||||
|
# define DATADIR PREFIX "/share"
|
||||||
|
#endif
|
||||||
|
#ifndef LOCALEDIR
|
||||||
|
# define LOCALEDIR DATADIR "/locale"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
/* prototypes */
|
||||||
|
static int _error(char const * message, int ret);
|
||||||
|
static int _usage(void);
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
/* error */
|
||||||
|
static int _error(char const * message, int ret)
|
||||||
|
{
|
||||||
|
fputs("pdfviewer: ", stderr);
|
||||||
|
perror(message);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: pdfviewer [file]\n", stderr);
|
fputs(_("Usage: pdfviewer [file]\n"), stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* main */
|
/* main */
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int o;
|
int o;
|
||||||
PDFviewer * pdfviewer;
|
PDFviewer * pdfviewer;
|
||||||
|
|
||||||
|
if(setlocale(LC_ALL, "") == NULL)
|
||||||
|
_error("setlocale", 1);
|
||||||
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
|
textdomain(PACKAGE);
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
while((o = getopt(argc, argv, "")) != -1)
|
while((o = getopt(argc, argv, "")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user