Using and Testing Translations

Applications that provide translations for different languages will be build with an additional .Local runtime extension that contains the files the application will use to display text in the user’s language. As with debug information, this cannot be exported as a binary bundle in the same way as for application flatpaks themselves, so we first need to find another way to install it.

Installing the Locale Package

In Installing from a Local Repository, we installed an application from a local repository by adding its repository to those registered with Flatpak on the system:

flatpak remote-add --no-gpg-verify my-local-repo myrepo

Once this repository has been added with the my-local-repo remote, we can list its contents:

flatpak remote-ls my-local-repo -a

The -a option ensures that the debug runtime extension is also listed. For the Pictures example, the above command produces this output:

Description                          Application                          Version          Branch
com.example.pictures                 com.example.pictures                                  master
com.example.pictures.Debug           com.example.pictures.Debug                            master
com.example.pictures.Locale          com.example.pictures.Locale                           master

We install both the application and the locale runtime extension from the repository:

flatpak install my-local-repo com.example.pictures com.example.pictures.Locale

We can now test the application using the locales for which we have translations available.

Testing Translations

One way to test the translation of an application into a language is to run it from the command line, specifying the language to use with the LANGUAGE environment variable.

For example, the Pictures example can be run in the following way:

LANGUAGE=nb flatpak run com.example.pictures

The window title should be shown in Norwegian Bokmål instead of the default English.

A screenshot of the translated Pictures application

A screenshot of the translated Pictures application

If a .Locale extension is installed but the specified translation is not used by the application, it can be useful to run a debug shell inside the sandbox and check whether the relevant translation files are installed within.

For example, we can inspect the translation files for the Pictures example by first starting the shell:

flatpak run --devel --command=bash com.example.pictures

At the debug prompt, look for the translation files within the /app directory:

[📦 com.example.pictures ~]$ ls /app/share/locale/*
/app/share/locale/en_GB:
LC_MESSAGES

/app/share/locale/nb:
LC_MESSAGES

If either en_GB or nb are not directories then the translation files have not been installed properly.