I tried to get gettext() translations going on a Ubuntu 16.04.2 server and while the code was solid, there was one major bit missing – the locale was not available on the server.
So if you have the same problem – simply run for each locale you plan to support:
sudo locale-gen de_DE
So what does it do?
Compiled locale files take about 50MB of disk space, and most users only need few locales. In order to save disk space, compiled locale files are not distributed in the locales package, but selected locales are automatically generated when this package is installed by running the locale-gen program.