A first step towards localization.

This commit is contained in:
Sebastian Ramacher 2012-03-04 18:35:16 +01:00
parent 51d927c6da
commit 9ac4bdf0b0
8 changed files with 139 additions and 9 deletions

View file

@ -21,6 +21,7 @@ OBJECTS = $(patsubst %.c, %.o, $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))
all: options ${PROJECT}
$(MAKE) -C po
options:
@echo ${PROJECT} build options:
@ -60,6 +61,7 @@ clean:
${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
*gcda *gcno $(PROJECT).info gcov
$(QUIET)make -C tests clean
$(QUIET)make -C po clean
${PROJECT}-debug: ${DOBJECTS}
$(ECHO) CC -o $@
@ -89,12 +91,14 @@ test: ${OBJECTS}
dist: clean
$(QUIET)mkdir -p ${PROJECT}-${VERSION}
$(QUIET)mkdir -p ${PROJECT}-${VERSION}/tests
$(QUIET)mkdir -p ${PROJECT}-${VERSION}/po
$(QUIET)cp LICENSE Makefile config.mk common.mk README AUTHORS Doxyfile \
${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \
${PROJECT}.desktop version.h.in database-*.c \
${PROJECT}-${VERSION}
$(QUIET)cp tests/Makefile tests/config.mk tests/*.c \
${PROJECT}-${VERSION}/tests
$(QUIET)cp po/Makefile po/*.po ${PROJECT}-${VERSION}/po
$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
$(QUIET)gzip ${PROJECT}-${VERSION}.tar
$(QUIET)rm -rf ${PROJECT}-${VERSION}
@ -134,6 +138,7 @@ install: all ${PROJECT}.pc
$(ECHO) installing pkgconfig file
$(QUIET)mkdir -p ${DESTDIR}${PREFIX}/lib/pkgconfig
$(QUIET)cp -f ${PROJECT}.pc ${DESTDIR}${PREFIX}/lib/pkgconfig
$(MAKE) -C po install
uninstall:
$(ECHO) removing executable file

View file

@ -14,12 +14,12 @@ ZATHURA_GTK_VERSION ?= 2
PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man
DESKTOPPREFIX ?= ${PREFIX}/share/applications
# list of : seperated values
# plugin directory
PLUGINDIR ?= ${PREFIX}/lib/zathura
# locale directory
LOCALEDIR ?= ${PREFIX}/share/locale
# libs
# set this to 0 if you don't need to link against dl
GTK_INC ?= $(shell pkg-config --cflags gtk+-${ZATHURA_GTK_VERSION}.0)
GTK_LIB ?= $(shell pkg-config --libs gtk+-${ZATHURA_GTK_VERSION}.0 gthread-2.0)
@ -37,7 +37,7 @@ LIBS = ${GIRARA_LIB} ${GTK_LIB} ${DL_LIB} -lpthread -lm
# flags
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)
CPPFLAGS += -DZATHURA_PLUGINDIR=\"${PLUGINDIR}\"
CPPFLAGS += -DZATHURA_PLUGINDIR=\"${PLUGINDIR}\" -DGETTEXT_PACKAGE=\"${PROJECT}\" -DLOCALEDIR=\"${LOCALEDIR}\"
# debug
DFLAGS ?= -g

6
main.c
View file

@ -2,12 +2,18 @@
#include <stdio.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "zathura.h"
/* main function */
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
g_thread_init(NULL);
gdk_threads_init();
gtk_init(&argc, &argv);

2
po/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
POTFILES.in*
*.mo

40
po/Makefile Normal file
View file

@ -0,0 +1,40 @@
# See LICENSE file for license and copyright information
PROJECT = zathura
CATALOGS = $(wildcard *.po)
MOS = $(patsubst %.po, %/LC_MESSAGES/${PROJECT}.mo, $(CATALOGS))
include ../config.mk
include ../common.mk
all: ${MOS}
clean:
rm -rf POTFILES.in POTFILES.in.tmp $(patsubst %.po, %, $(CATALOGS))
POTFILES.in: $(wildcard ../*.c)
$(QUIET) set -e && rm -f $@.tmp && touch $@.tmp && \
for f in $(^F) ; do \
echo $$f >> $@.tmp ; \
done && \
mv $@.tmp $@
${PROJECT}.pot: POTFILES.in
$(ECHO) regenerate ${PROJECT}.pot
$(QUIET)intltool-update --pot --gettext-package=${PROJECT}
%.po: ${PROJECT}.pot
$(ECHO) updating language $(shell echo $@ | sed 's/\.po//')
$(QUIET)intltool-update --dist --gettext-package=${PROJECT} $(shell echo $@ | sed 's/\.po//')
%/LC_MESSAGES/${PROJECT}.mo: %.po
@mkdir -p $(@D)
$(ECHO) msgfmt $(shell echo $< | sed 's/\.po//')
$(QUIET)msgfmt $< -o $@ -f
install: ${MOS}
$(ECHO) installing translations
$(QUIET)set -e && for f in $^ ; do \
mkdir -p $(DESTDIR)$(LOCALEDIR)/`dirname $$f`; \
install -m 644 $$f $(DESTDIR)$(LOCALEDIR)/`dirname $$f` ; \
done

38
po/de_DE.po Normal file
View file

@ -0,0 +1,38 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-03-04 18:29+0100\n"
"PO-Revision-Date: 2012-03-04 17:77+0100\n"
"Last-Translator: Sebastian Ramacher <s.ramacher@gmx.at>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../zathura.c:52
msgid "Reparents to window specified by xid"
msgstr ""
#: ../zathura.c:53
msgid "Path to the config directory"
msgstr "Pfad des Konfigurationsverzeichnisses"
#: ../zathura.c:54
msgid "Path to the data directory"
msgstr ""
#: ../zathura.c:55
msgid "Path to the directories containing plugins"
msgstr ""
#: ../zathura.c:56
msgid "Fork into the background"
msgstr ""

38
po/zathura.pot Normal file
View file

@ -0,0 +1,38 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-03-04 18:29+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../zathura.c:52
msgid "Reparents to window specified by xid"
msgstr ""
#: ../zathura.c:53
msgid "Path to the config directory"
msgstr ""
#: ../zathura.c:54
msgid "Path to the data directory"
msgstr ""
#: ../zathura.c:55
msgid "Path to the directories containing plugins"
msgstr ""
#: ../zathura.c:56
msgid "Fork into the background"
msgstr ""

View file

@ -13,6 +13,7 @@
#include <girara/statusbar.h>
#include <girara/settings.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "bookmarks.h"
#include "callbacks.h"
@ -48,11 +49,11 @@ zathura_init(int argc, char* argv[])
bool forkback = false;
GOptionEntry entries[] =
{
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, "Reparents to window specified by xid", "xid" },
{ "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, "Path to the config directory", "path" },
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, "Path to the data directory", "path" },
{ "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, "Path to the directories containing plugins", "path" },
{ "fork", '\0', 0, G_OPTION_ARG_NONE, &forkback, "Fork into the background" , NULL },
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" },
{ "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" },
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" },
{ "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, _("Path to the directories containing plugins"), "path" },
{ "fork", '\0', 0, G_OPTION_ARG_NONE, &forkback, _("Fork into the background") , NULL },
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
};