Translating the Surfer
This commit is contained in:
parent
7861cab135
commit
1990c058b4
10
Makefile
10
Makefile
|
@ -1,6 +1,6 @@
|
||||||
PACKAGE = Surfer
|
PACKAGE = Surfer
|
||||||
VERSION = 0.1.0
|
VERSION = 0.1.0
|
||||||
SUBDIRS = data src
|
SUBDIRS = data po src
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
LN = ln -f
|
LN = ln -f
|
||||||
TAR = tar -czvf
|
TAR = tar -czvf
|
||||||
|
@ -24,6 +24,13 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/data/Makefile \
|
$(PACKAGE)-$(VERSION)/data/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/data/surfer.desktop \
|
$(PACKAGE)-$(VERSION)/data/surfer.desktop \
|
||||||
$(PACKAGE)-$(VERSION)/data/project.conf \
|
$(PACKAGE)-$(VERSION)/data/project.conf \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/Makefile \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/gettext.sh \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/POTFILES \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/de.po \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/es.po \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/fr.po \
|
||||||
|
$(PACKAGE)-$(VERSION)/po/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/src/download.c \
|
$(PACKAGE)-$(VERSION)/src/download.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/surfer.c \
|
$(PACKAGE)-$(VERSION)/src/surfer.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/ghtml.c \
|
$(PACKAGE)-$(VERSION)/src/ghtml.c \
|
||||||
|
@ -47,6 +54,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/Makefile \
|
$(PACKAGE)-$(VERSION)/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/COPYING \
|
$(PACKAGE)-$(VERSION)/COPYING \
|
||||||
$(PACKAGE)-$(VERSION)/config.h \
|
$(PACKAGE)-$(VERSION)/config.h \
|
||||||
|
$(PACKAGE)-$(VERSION)/config.sh \
|
||||||
$(PACKAGE)-$(VERSION)/project.conf
|
$(PACKAGE)-$(VERSION)/project.conf
|
||||||
$(RM) $(PACKAGE)-$(VERSION)
|
$(RM) $(PACKAGE)-$(VERSION)
|
||||||
|
|
||||||
|
|
5
config.sh
Normal file
5
config.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
PACKAGE="Surfer"
|
||||||
|
VERSION="0.1.0"
|
||||||
|
|
||||||
|
PREFIX="/usr/local"
|
||||||
|
LIBDIR="${PREFIX}/lib"
|
47
po/Makefile
Normal file
47
po/Makefile
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
TARGETS = Surfer.pot de.po de.mo es.po es.mo fr.po fr.mo
|
||||||
|
RM = rm -f
|
||||||
|
LN = ln -f
|
||||||
|
MKDIR = mkdir -p
|
||||||
|
INSTALL = install
|
||||||
|
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
Surfer.pot: POTFILES
|
||||||
|
./gettext.sh "Surfer.pot"
|
||||||
|
|
||||||
|
de.po: Surfer.pot
|
||||||
|
./gettext.sh "de.po"
|
||||||
|
|
||||||
|
de.mo: de.po
|
||||||
|
./gettext.sh "de.mo"
|
||||||
|
|
||||||
|
es.po: Surfer.pot
|
||||||
|
./gettext.sh "es.po"
|
||||||
|
|
||||||
|
es.mo: es.po
|
||||||
|
./gettext.sh "es.mo"
|
||||||
|
|
||||||
|
fr.po: Surfer.pot
|
||||||
|
./gettext.sh "fr.po"
|
||||||
|
|
||||||
|
fr.mo: fr.po
|
||||||
|
./gettext.sh "fr.mo"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(Surfer.pot_OBJS) $(de.po_OBJS) $(de.mo_OBJS) $(es.po_OBJS) $(es.mo_OBJS) $(fr.po_OBJS) $(fr.mo_OBJS)
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
$(RM) $(TARGETS)
|
||||||
|
|
||||||
|
install: all
|
||||||
|
./gettext.sh -p "$(PREFIX)" install "de.mo"
|
||||||
|
./gettext.sh -p "$(PREFIX)" install "es.mo"
|
||||||
|
./gettext.sh -p "$(PREFIX)" install "fr.mo"
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
./gettext.sh -p "$(PREFIX)" uninstall "de.mo"
|
||||||
|
./gettext.sh -p "$(PREFIX)" uninstall "es.mo"
|
||||||
|
./gettext.sh -p "$(PREFIX)" uninstall "fr.mo"
|
||||||
|
|
||||||
|
.PHONY: all clean distclean install uninstall
|
2
po/POTFILES
Normal file
2
po/POTFILES
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
../src/main.c
|
||||||
|
../src/surfer.c
|
77
po/de.po
Normal file
77
po/de.po
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# German translations for Surfer package.
|
||||||
|
# Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>
|
||||||
|
# This file is distributed under the same license as the Surfer package.
|
||||||
|
# Pierre Pronchery <khorben@defora.org>, 2010.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Surfer 0.1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2010-04-01 20:00+0200\n"
|
||||||
|
"PO-Revision-Date: 2010-04-01 19:40+0200\n"
|
||||||
|
"Last-Translator: Pierre Pronchery <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: German\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=ISO-8859-15\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
|
#: ../src/main.c:42
|
||||||
|
msgid "Usage: surfer [URL]\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:230
|
||||||
|
msgid " Location: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:252
|
||||||
|
msgid "Could not initialize HTML renderer"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:453 ../src/surfer.c:456
|
||||||
|
msgid "Question"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:473 ../src/surfer.c:707
|
||||||
|
msgid "Save file as..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:504 ../src/surfer.c:507
|
||||||
|
msgid "Error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:506
|
||||||
|
msgid "Unknown error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:527
|
||||||
|
msgid "Find text"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:534
|
||||||
|
msgid "Text:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:543
|
||||||
|
msgid "Case-sensitive"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:546
|
||||||
|
msgid "Wrap"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:574
|
||||||
|
msgid "Text not found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:648
|
||||||
|
msgid "Open file..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:831
|
||||||
|
msgid "Web surfer - Source of "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:873 ../src/surfer.c:876
|
||||||
|
msgid "Warning"
|
||||||
|
msgstr ""
|
77
po/es.po
Normal file
77
po/es.po
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# Spanish translations for Surfer package.
|
||||||
|
# Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>
|
||||||
|
# This file is distributed under the same license as the Surfer package.
|
||||||
|
# Pierre Pronchery <khorben@defora.org>, 2010.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Surfer 0.1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2010-04-01 20:00+0200\n"
|
||||||
|
"PO-Revision-Date: 2010-04-01 19:40+0200\n"
|
||||||
|
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||||
|
"Language-Team: Spanish\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=ISO-8859-15\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
|
#: ../src/main.c:42
|
||||||
|
msgid "Usage: surfer [URL]\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:230
|
||||||
|
msgid " Location: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:252
|
||||||
|
msgid "Could not initialize HTML renderer"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:453 ../src/surfer.c:456
|
||||||
|
msgid "Question"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:473 ../src/surfer.c:707
|
||||||
|
msgid "Save file as..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:504 ../src/surfer.c:507
|
||||||
|
msgid "Error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:506
|
||||||
|
msgid "Unknown error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:527
|
||||||
|
msgid "Find text"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:534
|
||||||
|
msgid "Text:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:543
|
||||||
|
msgid "Case-sensitive"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:546
|
||||||
|
msgid "Wrap"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:574
|
||||||
|
msgid "Text not found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:648
|
||||||
|
msgid "Open file..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:831
|
||||||
|
msgid "Web surfer - Source of "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:873 ../src/surfer.c:876
|
||||||
|
msgid "Warning"
|
||||||
|
msgstr ""
|
77
po/fr.po
Normal file
77
po/fr.po
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# French translations for Surfer package.
|
||||||
|
# Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>
|
||||||
|
# This file is distributed under the same license as the Surfer package.
|
||||||
|
# Pierre Pronchery <khorben@defora.org>, 2010.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Surfer 0.1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2010-04-01 20:00+0200\n"
|
||||||
|
"PO-Revision-Date: 2010-04-01 19:40+0200\n"
|
||||||
|
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||||
|
"Language-Team: French\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=ISO-8859-15\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
|
#: ../src/main.c:42
|
||||||
|
msgid "Usage: surfer [URL]\n"
|
||||||
|
msgstr "Usage: surfer [URL]\n"
|
||||||
|
|
||||||
|
#: ../src/surfer.c:230
|
||||||
|
msgid " Location: "
|
||||||
|
msgstr " Adresse: "
|
||||||
|
|
||||||
|
#: ../src/surfer.c:252
|
||||||
|
msgid "Could not initialize HTML renderer"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:453 ../src/surfer.c:456
|
||||||
|
msgid "Question"
|
||||||
|
msgstr "Question"
|
||||||
|
|
||||||
|
#: ../src/surfer.c:473 ../src/surfer.c:707
|
||||||
|
msgid "Save file as..."
|
||||||
|
msgstr "Enregistrer sous..."
|
||||||
|
|
||||||
|
#: ../src/surfer.c:504 ../src/surfer.c:507
|
||||||
|
msgid "Error"
|
||||||
|
msgstr "Erreur"
|
||||||
|
|
||||||
|
#: ../src/surfer.c:506
|
||||||
|
msgid "Unknown error"
|
||||||
|
msgstr "Erreur inconnue"
|
||||||
|
|
||||||
|
#: ../src/surfer.c:527
|
||||||
|
msgid "Find text"
|
||||||
|
msgstr "Chercher du texte"
|
||||||
|
|
||||||
|
#: ../src/surfer.c:534
|
||||||
|
msgid "Text:"
|
||||||
|
msgstr "Texte: "
|
||||||
|
|
||||||
|
#: ../src/surfer.c:543
|
||||||
|
msgid "Case-sensitive"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:546
|
||||||
|
msgid "Wrap"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/surfer.c:574
|
||||||
|
msgid "Text not found"
|
||||||
|
msgstr "Texte non trouvé"
|
||||||
|
|
||||||
|
#: ../src/surfer.c:648
|
||||||
|
msgid "Open file..."
|
||||||
|
msgstr "Ouvrir un fichier..."
|
||||||
|
|
||||||
|
#: ../src/surfer.c:831
|
||||||
|
msgid "Web surfer - Source of "
|
||||||
|
msgstr "Web surfer - Source de "
|
||||||
|
|
||||||
|
#: ../src/surfer.c:873 ../src/surfer.c:876
|
||||||
|
msgid "Warning"
|
||||||
|
msgstr "Avertissement"
|
98
po/gettext.sh
Executable file
98
po/gettext.sh
Executable file
|
@ -0,0 +1,98 @@
|
||||||
|
#!/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()
|
||||||
|
{
|
||||||
|
lang="$2"
|
||||||
|
|
||||||
|
$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
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
$DEBUG $MSGINIT -l "$lang" -o "$lang.po" -i "$package.pot" \
|
||||||
|
|| return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#gettext_pot
|
||||||
|
_gettext_pot()
|
||||||
|
{
|
||||||
|
package="$1"
|
||||||
|
|
||||||
|
$DEBUG $XGETTEXT -d "$package" -o "$package.pot" --keyword="_" \
|
||||||
|
-f "$POTFILES" || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#main
|
||||||
|
if [ $# -eq 4 -a "$1" = "-p" -a "$3" = "install" ]; then
|
||||||
|
#PREFIX="$2" XXX doesn't work atm
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
*.po)
|
||||||
|
_gettext_po "$PACKAGE" "${1%%.po}" || exit 2
|
||||||
|
;;
|
||||||
|
*.pot)
|
||||||
|
_gettext_pot "${1%%.pot}" || exit 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0
|
40
po/project.conf
Normal file
40
po/project.conf
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
targets=Surfer.pot,de.po,de.mo,es.po,es.mo,fr.po,fr.mo
|
||||||
|
dist=Makefile,gettext.sh,POTFILES,de.po,es.po,fr.po
|
||||||
|
|
||||||
|
[Surfer.pot]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
depends=POTFILES
|
||||||
|
|
||||||
|
[de.po]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
depends=Surfer.pot
|
||||||
|
|
||||||
|
[de.mo]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
install=
|
||||||
|
depends=de.po
|
||||||
|
|
||||||
|
[es.po]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
depends=Surfer.pot
|
||||||
|
|
||||||
|
[es.mo]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
install=
|
||||||
|
depends=es.po
|
||||||
|
|
||||||
|
[fr.po]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
depends=Surfer.pot
|
||||||
|
|
||||||
|
[fr.mo]
|
||||||
|
type=script
|
||||||
|
script=./gettext.sh
|
||||||
|
install=
|
||||||
|
depends=fr.po
|
|
@ -1,6 +1,6 @@
|
||||||
package=Surfer
|
package=Surfer
|
||||||
version=0.1.0
|
version=0.1.0
|
||||||
config=h
|
config=h,sh
|
||||||
dist=Makefile,COPYING,config.h
|
dist=Makefile,COPYING,config.h,config.sh
|
||||||
|
|
||||||
subdirs=data,src
|
subdirs=data,po,src
|
||||||
|
|
23
src/main.c
23
src/main.c
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2009 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Surfer */
|
/* This file is part of DeforaOS Desktop Surfer */
|
||||||
/* Surfer is free software; you can redistribute it and/or modify it under the
|
/* Surfer is free software; you can redistribute it and/or modify it under the
|
||||||
* terms of the GNU General Public License version 2 as published by the Free
|
* terms of the GNU General Public License version 2 as published by the Free
|
||||||
|
@ -17,13 +17,29 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <libintl.h>
|
||||||
#include "surfer.h"
|
#include "surfer.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 */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: surfer [url]\n", stderr);
|
fputs(_("Usage: surfer [URL]\n"), stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +50,9 @@ int main(int argc, char * argv[])
|
||||||
int o;
|
int o;
|
||||||
Surfer * surfer;
|
Surfer * surfer;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
|
textdomain(PACKAGE);
|
||||||
#if defined(WITH_GTKHTML) || defined(WITH_GTKTEXTVIEW) || defined(WITH_WEBKIT)
|
#if defined(WITH_GTKHTML) || defined(WITH_GTKTEXTVIEW) || defined(WITH_WEBKIT)
|
||||||
if(g_thread_supported() == FALSE)
|
if(g_thread_supported() == FALSE)
|
||||||
g_thread_init(NULL);
|
g_thread_init(NULL);
|
||||||
|
|
39
src/surfer.c
39
src/surfer.c
|
@ -18,12 +18,14 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libintl.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <Desktop.h>
|
#include <Desktop.h>
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "ghtml.h"
|
#include "ghtml.h"
|
||||||
#include "surfer.h"
|
#include "surfer.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#define _(string) gettext(string)
|
||||||
|
|
||||||
|
|
||||||
/* Surfer */
|
/* Surfer */
|
||||||
|
@ -225,7 +227,7 @@ Surfer * surfer_new(char const * url)
|
||||||
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
|
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
|
||||||
#ifndef EMBEDDED
|
#ifndef EMBEDDED
|
||||||
toolitem = gtk_tool_item_new();
|
toolitem = gtk_tool_item_new();
|
||||||
widget = gtk_label_new(" Location: ");
|
widget = gtk_label_new(_(" Location: "));
|
||||||
gtk_container_add(GTK_CONTAINER(toolitem), widget);
|
gtk_container_add(GTK_CONTAINER(toolitem), widget);
|
||||||
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
|
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -247,7 +249,7 @@ Surfer * surfer_new(char const * url)
|
||||||
/* view */
|
/* view */
|
||||||
if((surfer->view = ghtml_new(surfer)) == NULL)
|
if((surfer->view = ghtml_new(surfer)) == NULL)
|
||||||
{
|
{
|
||||||
surfer_error(NULL, "Could not initialize HTML renderer", 0);
|
surfer_error(NULL, _("Could not initialize HTML renderer"), 0);
|
||||||
surfer_delete(surfer);
|
surfer_delete(surfer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -448,10 +450,10 @@ int surfer_confirm(Surfer * surfer, char const * message)
|
||||||
? GTK_WINDOW(surfer->window) : NULL,
|
? GTK_WINDOW(surfer->window) : NULL,
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s",
|
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s",
|
||||||
"Question");
|
_("Question"));
|
||||||
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
|
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
|
||||||
"%s", message);
|
"%s", message);
|
||||||
gtk_window_set_title(GTK_WINDOW(dialog), "Question");
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Question"));
|
||||||
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
|
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
|
||||||
gtk_widget_destroy), NULL);
|
gtk_widget_destroy), NULL);
|
||||||
ret = gtk_dialog_run(GTK_DIALOG(dialog));
|
ret = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
|
@ -468,7 +470,7 @@ void surfer_download(Surfer * surfer, char const * url, char const * suggested)
|
||||||
char * argv[] = { "download", "-O", NULL, NULL, NULL };
|
char * argv[] = { "download", "-O", NULL, NULL, NULL };
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
|
||||||
dialog = gtk_file_chooser_dialog_new("Save file as...",
|
dialog = gtk_file_chooser_dialog_new(_("Save file as..."),
|
||||||
GTK_WINDOW(surfer->window),
|
GTK_WINDOW(surfer->window),
|
||||||
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
|
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
|
||||||
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
|
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
|
||||||
|
@ -499,10 +501,10 @@ int surfer_error(Surfer * surfer, char const * message, int ret)
|
||||||
dialog = gtk_message_dialog_new((surfer != NULL)
|
dialog = gtk_message_dialog_new((surfer != NULL)
|
||||||
? GTK_WINDOW(surfer->window) : NULL,
|
? GTK_WINDOW(surfer->window) : NULL,
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", "Error");
|
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _("Error"));
|
||||||
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
|
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
|
||||||
"%s", (message != NULL) ? message : "Unknown error");
|
"%s", (message != NULL) ? message : _("Unknown error"));
|
||||||
gtk_window_set_title(GTK_WINDOW(dialog), "Error");
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
|
||||||
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
|
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
|
||||||
gtk_widget_destroy), NULL);
|
gtk_widget_destroy), NULL);
|
||||||
gtk_widget_show(dialog);
|
gtk_widget_show(dialog);
|
||||||
|
@ -522,14 +524,14 @@ void surfer_find(Surfer * surfer, char const * text)
|
||||||
|
|
||||||
if(surfer->fi_dialog == NULL)
|
if(surfer->fi_dialog == NULL)
|
||||||
{
|
{
|
||||||
surfer->fi_dialog = gtk_dialog_new_with_buttons("Find text",
|
surfer->fi_dialog = gtk_dialog_new_with_buttons(_("Find text"),
|
||||||
GTK_WINDOW(surfer->window),
|
GTK_WINDOW(surfer->window),
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
||||||
GTK_STOCK_FIND, GTK_RESPONSE_ACCEPT, NULL);
|
GTK_STOCK_FIND, GTK_RESPONSE_ACCEPT, NULL);
|
||||||
vbox = GTK_DIALOG(surfer->fi_dialog)->vbox;
|
vbox = GTK_DIALOG(surfer->fi_dialog)->vbox;
|
||||||
hbox = gtk_hbox_new(FALSE, 0);
|
hbox = gtk_hbox_new(FALSE, 0);
|
||||||
widget = gtk_label_new("Text:");
|
widget = gtk_label_new(_("Text:"));
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
|
||||||
surfer->fi_text = gtk_entry_new();
|
surfer->fi_text = gtk_entry_new();
|
||||||
g_signal_connect(G_OBJECT(surfer->fi_text), "activate",
|
g_signal_connect(G_OBJECT(surfer->fi_text), "activate",
|
||||||
|
@ -538,10 +540,10 @@ void surfer_find(Surfer * surfer, char const * text)
|
||||||
4);
|
4);
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
|
||||||
surfer->fi_case = gtk_check_button_new_with_label(
|
surfer->fi_case = gtk_check_button_new_with_label(
|
||||||
"Case-sensitive");
|
_("Case-sensitive"));
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), surfer->fi_case, TRUE, TRUE,
|
gtk_box_pack_start(GTK_BOX(vbox), surfer->fi_case, TRUE, TRUE,
|
||||||
4);
|
4);
|
||||||
surfer->fi_wrap = gtk_check_button_new_with_label("Wrap");
|
surfer->fi_wrap = gtk_check_button_new_with_label(_("Wrap"));
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), surfer->fi_wrap, TRUE, TRUE,
|
gtk_box_pack_start(GTK_BOX(vbox), surfer->fi_wrap, TRUE, TRUE,
|
||||||
4);
|
4);
|
||||||
gtk_widget_show_all(vbox);
|
gtk_widget_show_all(vbox);
|
||||||
|
@ -569,7 +571,7 @@ static void _on_find_activate(GtkWidget * widget, gpointer data)
|
||||||
surfer->fi_wrap));
|
surfer->fi_wrap));
|
||||||
if(ghtml_find(surfer->view, text, sensitive, wrap) == TRUE)
|
if(ghtml_find(surfer->view, text, sensitive, wrap) == TRUE)
|
||||||
return;
|
return;
|
||||||
surfer_error(surfer, "Text not found", 0);
|
surfer_error(surfer, _("Text not found"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _on_find_response(GtkWidget * widget, gint response, gpointer data)
|
static void _on_find_response(GtkWidget * widget, gint response, gpointer data)
|
||||||
|
@ -643,7 +645,7 @@ void surfer_open_dialog(Surfer * surfer)
|
||||||
GtkWidget * dialog;
|
GtkWidget * dialog;
|
||||||
char * filename = NULL;
|
char * filename = NULL;
|
||||||
|
|
||||||
dialog = gtk_file_chooser_dialog_new("Open file...",
|
dialog = gtk_file_chooser_dialog_new(_("Open file..."),
|
||||||
GTK_WINDOW(surfer->window),
|
GTK_WINDOW(surfer->window),
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
|
@ -702,7 +704,7 @@ void surfer_save(Surfer * surfer, char const * filename)
|
||||||
return; /* XXX report error */
|
return; /* XXX report error */
|
||||||
if(filename == NULL)
|
if(filename == NULL)
|
||||||
{
|
{
|
||||||
dialog = gtk_file_chooser_dialog_new("Save file as...",
|
dialog = gtk_file_chooser_dialog_new(_("Save file as..."),
|
||||||
GTK_WINDOW(surfer->window),
|
GTK_WINDOW(surfer->window),
|
||||||
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
|
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
|
||||||
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
|
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
|
||||||
|
@ -826,7 +828,7 @@ void surfer_view_source(Surfer * surfer)
|
||||||
GTK_ACCEL_VISIBLE, cc);
|
GTK_ACCEL_VISIBLE, cc);
|
||||||
gtk_window_add_accel_group(GTK_WINDOW(window), group);
|
gtk_window_add_accel_group(GTK_WINDOW(window), group);
|
||||||
gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
|
gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
|
||||||
snprintf(buf, sizeof(buf), "%s%s", "Web surfer - Source of ",
|
snprintf(buf, sizeof(buf), "%s%s", _("Web surfer - Source of "),
|
||||||
surfer->url);
|
surfer->url);
|
||||||
gtk_window_set_title(GTK_WINDOW(window), buf);
|
gtk_window_set_title(GTK_WINDOW(window), buf);
|
||||||
g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(
|
g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(
|
||||||
|
@ -867,10 +869,11 @@ void surfer_warning(Surfer * surfer, char const * message)
|
||||||
dialog = gtk_message_dialog_new((surfer != NULL)
|
dialog = gtk_message_dialog_new((surfer != NULL)
|
||||||
? GTK_WINDOW(surfer->window) : NULL,
|
? GTK_WINDOW(surfer->window) : NULL,
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s", "Warning");
|
GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s",
|
||||||
|
_("Warning"));
|
||||||
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
|
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
|
||||||
"%s", message);
|
"%s", message);
|
||||||
gtk_window_set_title(GTK_WINDOW(dialog), "Warning");
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Warning"));
|
||||||
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
|
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
|
||||||
gtk_widget_destroy), NULL);
|
gtk_widget_destroy), NULL);
|
||||||
gtk_widget_show(dialog);
|
gtk_widget_show(dialog);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user