[[i18n-example]]
=== Internationalization

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

In the real situation, the package should be already 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 BTS system to the *po/* directory and to update the language list in the *po/LINGUAS*.

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 the 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* from the *po/Makevars.template*.

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

Let's update C sources for the i18n 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 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*.

.*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 Japanese translation.

.*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 the Makefile (v=3.0),
* the Python3 script with the distutils (v=3.1),
* the C source with the Makefile.in + configure (v=3.2),
* the C source with the Autotools (v=3.3), and
* the C source with the CMake (v=3.4).

