I have gone crazy until I found this… to have gettext functions working in ubuntu server you need to add the proper locales to the system first, for example, to translate text in spanish:
# cat /usr/share/i18n/SUPPORTED |grep -i "es_ES" > /var/lib/locales/supported.d/es
And repeat for every language you need…
when finished, run
dpkg-reconfigure locales and you are done!