shaggyz/laravel-gettext

Translation not shown

Closed this issue · 17 comments

And finally, everything is set up but unfortunately, strings are not translated. :(

Check your setup, it is working.

Well no, it isn't.

But honestly, I did everything exactly according to the readme. My translation mo and po files exist, translations were parsed and translated in poEdit, the language switcher works, setting the locale works but the translations are NOT shown.

Can you tell me where in the code the po file is loaded so I can set a breakpoint there?

Check this: https://github.com/xinax/laravel-gettext/blob/master/src/Xinax/LaravelGettext/Gettext.php (this is the gettext wrapper) and this: http://php.net/manual/en/book.gettext.php

Also, the other closed issues might help you. Good luck!

I don't see the line where the po file is actually loaded?

Cause this is an internal task of the php-gettext module. This package is just a wrapper to work with Laravel. This probably means that you have a problem with the gettext module.

I think so too but it might be the way the wrapper is written, it works with apache but not with nginx. I'll have to look into it... :/

phpinfo() shows that gettext is enabled with nginx... but still not working.

It seems it's actually a thing with Ubuntu: http://pof.eslack.org/2010/11/17/php-gettext-problems-on-ubuntu-server/ maybe that's going to solve it.

Nothing helps. Seems nginx, ubuntu and gettext don't get along very well.

After another restart of nginx and deleting compiled views in laravel, it finally works.

Seems that on CentOS with Apache it doesn't work properly either. Now that I read this http://stackoverflow.com/questions/3398113/php-gettext-problems I'm thinking I'll just go for PHP arrays or try to port Zend Translate to Laravel.

The same happens in Homestead. It doesn´t work. When using the PHP built in webserver in OS X, it worked perfectly. That's a shame, but I´ll have to ditch Homestead.....

I have the same issue here: #60

@markushausammann what was your final solution? Using PHP arrays, or did deleting compilde views in laravel + restart solve the issue? I have cleared cache several times + restart, but when I hit refresh, translations are back to fallback language (i.e. en_US).

@canfiax I think I gave up, don't know how I solved it. Probably by not using gettext.

An easy way to fix the issue

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:

sudo -s
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!