|
Packit |
1470ea |
|
|
Packit |
1470ea |
xmlns:its="http://www.w3.org/2005/11/its"
|
|
Packit |
1470ea |
type="topic" style="task"
|
|
Packit |
1470ea |
id="dev-translate-build">
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<link type="next" xref="dev-translate-tools"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2013-06-19" status="review"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author">
|
|
Packit |
1470ea |
<name>Ekaterina Gerasimova</name>
|
|
Packit |
1470ea |
<email its:translate="no">kittykat3756@gmail.com</email>
|
|
Packit |
1470ea |
<years>2013</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<include href="cc-by-sa-3-0.xml" xmlns="http://www.w3.org/2001/XInclude"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc></desc>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Set up your build system for translation</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<links type="series" style="floatend">
|
|
Packit |
1470ea |
<title>Set up translations</title>
|
|
Packit |
1470ea |
</links>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
You will need to set up your project and build system to work with
|
|
Packit |
1470ea |
translations.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Create a <file>po/</file> subdirectory in your project directory and list
|
|
Packit |
1470ea |
the files which have translatable strings in <file>po/POTFILES.in</file>.
|
|
Packit |
1470ea |
List files without translatable strings in
|
|
Packit |
1470ea |
<file>po/POTFILES.skip</file>.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Add the following lines to your <file>configure.ac</file>:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
IT_PROG_INTLTOOL([0.50.0])
|
|
Packit |
1470ea |
AC_SUBST([GETTEXT_PACKAGE], [$PACKAGE_TARNAME])
|
|
Packit |
1470ea |
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Package name for gettext])
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Add the following lines to your <file>Makefile.am</file>:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
SUBDIRS = po
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
AM_CPPFLAGS = -DPACKAGE_LOCALEDIR=\""$(datadir)/locale"\"
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
@INTLTOOL_DESKTOP_RULE@
|
|
Packit |
1470ea |
desktopdir = $(datadir)/applications
|
|
Packit |
1470ea |
desktop_in_files = data/<input>applicationname</input>.desktop.in
|
|
Packit |
1470ea |
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Run <cmd>intltoolize</cmd> to copy the intltool build infrastructure to
|
|
Packit |
1470ea |
the build tree before running <cmd>autoreconf</cmd>.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Now that your build system and your source strings are ready for
|
|
Packit |
1470ea |
translation, you need to tell <app>gettext</app> three things:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item>the translation domain, generally the same as the
|
|
Packit |
1470ea |
application name</item>
|
|
Packit |
1470ea |
<item>the location where the built translations are installed </item>
|
|
Packit |
1470ea |
<item>the character encoding of the translations, generally
|
|
Packit |
1470ea |
UTF-8</item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<example>
|
|
Packit |
1470ea |
<note>
|
|
Packit |
1470ea |
This example assumes that your application is written in C. It will be
|
|
Packit |
1470ea |
slightly different for other programming languages.
|
|
Packit |
1470ea |
</note>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Add the following line to the source file which contains your
|
|
Packit |
1470ea |
main() function:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#include "config.h"
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Then, add the following lines to your main() function:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
|
|
Packit |
1470ea |
bind_textdomain_codeset (PACKAGE_TARNAME, "UTF-8");
|
|
Packit |
1470ea |
textdomain (GETTEXT_PACKAGE);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
</example>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Run <cmd>make <input>projectname</input>.pot</cmd> in the <file>po</file>
|
|
Packit |
1470ea |
directory. This runs <cmd>intltool-extract</cmd> to extract the translatable
|
|
Packit |
1470ea |
strings and put them in a po template (POT) file.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
</page>
|