[[i18n-example]]
=== Internationalization

Here is an example of updating the simple upstream C source *debhello-2.0.tar.gz* presented in <<autotools-multi>> for internationalization (i18n) and creating the updated upstream C source *debhello-2.0.tar.gz*.

In the real situation, the package should already be internationalized.  So this example is educational for you to understand how this internationalization is implemented.

TIP: The routine maintainer activity for the i18n is simply to add translation po files reported to you via the Bug Tracking System (BTS) to the *po/* directory and to update the language list in the *po/LINGUAS* file.

Let's get the source and make the Debian package.

.Download *debhello-2.0.tar.gz* (i18n)
----
include::../debhello-2.0-pkg2/step000.slog[]
----

Internationalize this source tree with the *gettextize* command and remove files auto-generated by Autotools.

.run *gettextize* (i18n):
----
include::../debhello-2.0-pkg2/step150.slog[]
----

Let's check generated files under the *po/* directory.

.files in *po* (i18n):
----
include::../debhello-2.0-pkg2/step151.slog[]
----

Let's update the *configure.ac* by adding ``*AM_GNU_GETTEXT([external])*'', etc..

.*configure.ac* (i18n):
----
include::../debhello-2.0-pkg2/step152.slog[]
----

Let's create the *po/Makevars* file from the *po/Makevars.template* file.

.*po/Makevars* (i18n):
----
include::../debhello-2.0-pkg2/step153.slog[]
----

Let's update C sources for the i18n version by wrapping strings with *_(...)*.

.*src/hello.c* (i18n):
----
include::../debhello-2.0-pkg2/step154.slog[]
----

.*lib/sharedlib.c* (i18n):
----
include::../debhello-2.0-pkg2/step155.slog[]
----

The new *gettext* (v=0.19) can handle the i18n version of the desktop file directly.

.*data/hello.desktop.in* (i18n):
----
include::../debhello-2.0-pkg2/step156.slog[]
----

Let's list the input files to extract translatable strings in *po/POTFILES.in*.

.*po/POTFILES.in* (i18n):
----
include::../debhello-2.0-pkg2/step157.slog[]
----

Here is the updated root *Makefile.am* with *po* added to the *SUBDIRS* environment variable.

.*Makefile.am* (i18n):
----
include::../debhello-2.0-pkg2/step158.slog[]
----

Let's make a translation template file, *debhello.pot*.

.*po/debhello.pot* (i18n):
----
include::../debhello-2.0-pkg2/step160.slog[]
----

Let's add a translation for French.

.*po/LINGUAS* and *po/fr.po* (i18n):
----
include::../debhello-2.0-pkg2/step161.slog[]
----

The packaging activities are practically the same as the one in <<autotools-multi>>.

You can find more i18n examples in <<details>> for

* the POSIX shell script with Makefile (v=3.0),
* the Python3 script with distutils (v=3.1),
* the C source with Makefile.in + configure (v=3.2),
* the C source with Autotools (v=3.3), and
* the C source with CMake (v=3.4).

