gettext integration in NSIS
===========================

This document describes briefly how the integration of gettext and
NSIS works.


1. Preparation of sources

You can use gettextize, although it is overkill.  The following
modifications to the standard gettextize procedure should be done:

Remove the following files in m4/ unless needed otherwise:
gettext.m4, iconv.m4, lib-ld.m4, lib-link.m4, lib-prefix.m4

Use AM_PO_SUBDIRS in configure.ac instead of AM_GNU_GETTEXT([external]).

You don't need gettext.h.

Makevars needs to be modified as thus:

XGETTEXT_OPTIONS = -L c

XGETTEXT := /bin/bash $(srcdir)/nsis-xgettext.sh --srcdir=$(srcdir) $(XGETTEXT)

You also need the following files in po/:
nsis-msgfmt.c
nsis-xgettext.awk
nsis-xgettext.sh
Rules-nsis


2. xgettext wrapper

The script nsis-xgettext.sh is a wrapper for xgettext which extracts
all lines from the POFILES that start with "LangString" (with no
whitespace at the beginning of the line).  Language strings stretching
multiple lines via trailing backslashes are supported.  The AWK script
nsis-xgettext.awk transforms these into C function calls which are
then parsed by xgettext.  Because we use #line directives, positional
indicators (filename/line number) are preserved in the .po file.

The wrapper (currently) only supports input via --from-files, not via
standard input or file names as arguments.


3. msgfmt replacement

We let the standard Makefile produce LANG.gmo files, but we do not use
them (as gpg4win is never "make install"-ed).  Instead, the LANG.nsi
files are generated as a side effect of LANG.gmo generation.  The
LANG.nsi files replace the LANG.gmo files for all purposes of NSIS.

The LANG.nsi files are created from the respective LANG.po files with
the nsis-msgfmt.c program, which needs to be compiled on the build
platform and uses the libgettextpo library to parse the LANG.po files
and produces output suitable for NSIS.  The program can generate files
usable for vanilla NSIS and Modern UI (hard coded in a global variable
in the source code).

LANG.nsi files are included in the distribution, just as LANG.gmo files.


4. catalogs.nsi

As a side-effect of "make all" (that is, at normal compile time), the
Rules-nsis Makefile extension also creates a file catalogs.nsi, which
contains one !include directive for every language from the catalogs
the user selected at compile time.

The file catalogs.nsi needs to be included twice, once which PO_HEADER
defined and once without.  The header should be included early, while
the language strings should be included late.


5. Preparation of NSIS project

The NSIS project should only include the code for the English
language.  All .nsi files which contain LangString directives should
be added to POFILES.in.  The NSIS project should have a directive:

!addincludedir "${TOP_SRCDIR}/po"

so that inclusion of catalogs.nsi will find the LANG.nsi files.  Near
the end of the project's master NSI file you should include all
translation strings:

!include "catalogs.nsi"

That's it.  Enjoy!

Marcus Brinkmann
mb@g10code.com


This file
=========

Copyright 2007 g10 Code GmbH

This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.

This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
