GNU gettext is a tool for localizing or translating programs. You don't need it if you only care about English. Get the source here and compile it like this:
./configure --prefix=/mingw --enable-threads=win32 --enable-relocatable
cd gettext-runtime
make
make install
Previously I didn't change to the gettext-runtime directory, and the compile took much longer because it built everything. In most cases, only gettext-runtime is needed, so it's okay to type “cd gettext-runtime
.” If you need msgfmt.exe
, read the bottom of the page.
If you get an error regarding rpl_optind
, edit gettext-tools\woe32dll\gettextlib-exports.c
as follows:
/* VARIABLE(rpl_optarg)
VARIABLE(rpl_optind) */
The following files are copied to the system when gettext is installed:
bin/envsubst.exe
bin/gettext.exe
bin/gettext.sh
bin/libasprintf-0.dll
bin/libintl-8.dll
bin/ngettext.exe
include/autosprintf.h
include/libintl.h
lib/libasprintf.*
lib/libintl.*
share/doc/gettext/
share/doc/libasprintf/
share/locale/*/LC_MESSAGES/gettext-runtime.mo
Building Gettext-runtime Statically
Building gettext statically means your program won't look for intl.dll or libintl-8.dll at runtime. Just add the --disable-shared
option to configure:
./configure --prefix=/mingw --enable-threads=win32 --enable-relocatable --disable-shared
make
cd gettext-runtime/
make install
With static build, We get the following files:
include/autosprintf.h
include/libintl.h
include/localcharset.h
lib/charset.alias
lib/libasprintf.a
lib/libasprintf.la
lib/libintl.a
share/doc/gettext/
share/doc/libasprintf/
My static gettext build is available here.
Static msgfmt, msgmerge and xgettext
Some programs require msgfmt, msgmerge
and xgettext
during configure. I like to build these tools statically as they won't have dependency on rare libraries like libgettextlib-0-17.dll and libgettextsrc-0-17.dll. After you compile gettext statically following the section above, just copy the tools to /bin:
cp gettext-tools/src/msgfmt.exe /bin
cp gettext-tools/src/msgmerge.exe /bin
cp gettext-tools/src/xgettext.exe /bin
cp gettext-tools/autopoint /bin
Test: Get a message file in *.po format from somewhere and run msgfmt
like
this:
msgfmt.exe -o fr.mo fr.po
A binary message file fr.mo will be generated from fr.po in the example above.
No comments:
Post a Comment