clusteramaryllis / laravel-gettext

https://packagist.org/packages/clusteramaryllis/gettext
GNU General Public License v2.0
4 stars 5 forks source link

All API throws #4

Closed rulatir closed 8 years ago

rulatir commented 8 years ago

ErrorException in GettextDriver.php line 264: setlocale(): Specified locale name is too long

in GettextDriver.php line 264
at HandleExceptions->handleError('2', 'setlocale(): Specified locale name is too long', '/srv/http/vhosts/[redacted]/website/vendor/clusteramaryllis/gettext/src/Driver/GettextDriver.php', '264', array('category' => '6', 'argsCount' => '2', 'strCategory' => 'LC_ALL', 'preLocales' => array('LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=pl_PL.UTF-8;LC_TIME=pl_PL.UTF-8;LC_COLLATE=C;LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8;LC_PAPER=pl_PL.UTF-8;LC_NAME=pl_PL.UTF-8;LC_ADDRESS=pl_PL.UTF-8;LC_TELEPHONE=pl_PL.UTF-8;LC_MEASUREMENT=pl_PL.UTF-8;LC_IDENTIFICATION=pl_PL.UTF-8'), 'locales' => array('LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=pl_PL.UTF-8;LC_TIME=pl_PL.UTF-8;LC_COLLATE=C;LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8;LC_PAPER=pl_PL.UTF-8;LC_NAME=pl_PL.UTF-8;LC_ADDRESS=pl_PL.UTF-8;LC_TELEPHONE=pl_PL.UTF-8;LC_MEASUREMENT=pl_PL.UTF-8;LC_IDENTIFICATION=pl_PL.UTF-8')))
at setlocale('6', array('LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=pl_PL.UTF-8;LC_TIME=pl_PL.UTF-8;LC_COLLATE=C;LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8;LC_PAPER=pl_PL.UTF-8;LC_NAME=pl_PL.UTF-8;LC_ADDRESS=pl_PL.UTF-8;LC_TELEPHONE=pl_PL.UTF-8;LC_MEASUREMENT=pl_PL.UTF-8;LC_IDENTIFICATION=pl_PL.UTF-8')) in GettextDriver.php line 264
at GettextDriver->setLocale('6', 'LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=pl_PL.UTF-8;LC_TIME=pl_PL.UTF-8;LC_COLLATE=C;LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8;LC_PAPER=pl_PL.UTF-8;LC_NAME=pl_PL.UTF-8;LC_ADDRESS=pl_PL.UTF-8;LC_TELEPHONE=pl_PL.UTF-8;LC_MEASUREMENT=pl_PL.UTF-8;LC_IDENTIFICATION=pl_PL.UTF-8')
at call_user_func_array(array(object(GettextDriver), 'setLocale'), array('6', 'LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=pl_PL.UTF-8;LC_TIME=pl_PL.UTF-8;LC_COLLATE=C;LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8;LC_PAPER=pl_PL.UTF-8;LC_NAME=pl_PL.UTF-8;LC_ADDRESS=pl_PL.UTF-8;LC_TELEPHONE=pl_PL.UTF-8;LC_MEASUREMENT=pl_PL.UTF-8;LC_IDENTIFICATION=pl_PL.UTF-8')) in Gettext.php line 47
at Gettext->setLocale('6', 'LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=pl_PL.UTF-8;LC_TIME=pl_PL.UTF-8;LC_COLLATE=C;LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8;LC_PAPER=pl_PL.UTF-8;LC_NAME=pl_PL.UTF-8;LC_ADDRESS=pl_PL.UTF-8;LC_TELEPHONE=pl_PL.UTF-8;LC_MEASUREMENT=pl_PL.UTF-8;LC_IDENTIFICATION=pl_PL.UTF-8') in Gettext.php line 26
at Gettext->__construct(object(GettextDriver)) in GettextServiceProvider.php line 104
at GettextServiceProvider->Clusteramaryllis\Gettext\{closure}(object(Application), array()) in Container.php line 734
at Container->build(object(Closure), array()) in Container.php line 627
at Container->make('gettext', array()) in Application.php line 674
at Application->make('gettext') in Container.php line 1159
at Container->offsetGet('gettext') in Facade.php line 149
at Facade::resolveFacadeInstance('gettext') in Facade.php line 118
at Facade::getFacadeRoot() in Facade.php line 203
at Facade::__callStatic('bindTextDomain', array('messages', '/srv/http/vhosts/[redacted]/website/resources/locale')) in Front.php line 20
at Gettext::bindTextDomain('messages', '/srv/http/vhosts/[redacted]/website/resources/locale') in Front.php line 20
at Front->index()

This happens during the second invocation of GettextDriver::setLocale() that is executed sometime during whatever is done when trying to call any API through the facade. On the first invocation of the setLocale() method the result of native setlocale() is stored in $this->currentLocale, and on the second invocation it is passed back to setLocale(). The long string you see in the backtrace is what native setlocale() returns the first time. I don't think this is what you expect.

As you can see near the bottom of the stack dump, all this happens during on-demand construction of the Gettext instance as a result of using the facade for the first time. The specific API attempted (bindTextDomain) doesn't even involve setting the locale.

rulatir commented 8 years ago

Probably relevant:

http://stackoverflow.com/questions/16110866/why-do-i-get-this-php-warning-setlocale-specified-locale-name-is-too-long

clusteramaryllis commented 8 years ago

I have added possible fix, please update & check if its working or not